From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE676C00140 for ; Tue, 2 Aug 2022 16:39:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239070AbiHBQjX (ORCPT ); Tue, 2 Aug 2022 12:39:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239085AbiHBQjK (ORCPT ); Tue, 2 Aug 2022 12:39:10 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCD38E93 for ; Tue, 2 Aug 2022 09:39:00 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d16so5867433pll.11 for ; Tue, 02 Aug 2022 09:39:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc; bh=YLolmPC/4W6Ekt5KXSGhTlaQ+SvTrN9uL1784FHTktA=; b=DEczoNtVTMwIsaw8yg11wYkQuI9LeTuQwFeOQ0oJ03m1tMW/YgHdOnTv17v8+A6WTV U7hpMystc0MLLmDXYDMaROWkoGrECN3+IY7Ia+Z09cQyp/+2thONhPGLIYnqECJRrXhr dDHRlXhlBA0o0w24sHNoK99DkncCME85F/XcNTjXnZbY1/vtUg34rxTUMG/OWYQ4HMcI iIFe/Qw/lNcBgMnxPgPuAhy90CFyCy84wOdE8NkRPB91ulC5zTuJcdVgjk8H0EgOjoUm FnlRd5MiMQxVvv/M1kuZRL91q7QvdBIT05QOREIPMw2HWyehKvsTbH9WC464J4D8ov37 YsWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=YLolmPC/4W6Ekt5KXSGhTlaQ+SvTrN9uL1784FHTktA=; b=YrNw/pB8pXXPlSXSkcScl7o5O5wd6WySGULuSEYwD521CxoHgUoYRCckxlJzhTtDNd n2QeohGsOAcORZytpHZyc9X0CGmqVkk2dOcQr23uvr4dH95HKHLvrN4rkV9JhVNcCXGD IqCRlM0b0s65YG7AmfAb36sqULImO3Q4/XnQuckezTH8c3i7F6RBLYwYRIbDcWDYsUdo a4ZnO/ZFNGESovCLGMzgEAAJnZQvwy5mmK9+Nz6Um1fp2yPLNhU8bfxIFpfOGhrqGSZ3 4TM+OZwYZeJ+jE4ouP70GAfn6abCA/GEVfJn3FEQ1n1zmdoH0KlLLJxf2E02pTchq0Aa vf7Q== X-Gm-Message-State: ACgBeo0y4uBvY+08A4diN8TH5Yrpb0RH+e9jFkWz4Du0vOewIdeoK3vn et466fGp9A9EmTtJtctVfQVq1w== X-Google-Smtp-Source: AA6agR5iAjFP2q7X1PbZvwrW6P6B4ILkh92ieVBGwE4LPz6Qma2k0ZREMBEhxOJKazpAhnjrSGkWTg== X-Received: by 2002:a17:902:dac6:b0:16d:bdf5:7084 with SMTP id q6-20020a170902dac600b0016dbdf57084mr22165713plx.55.1659458340177; Tue, 02 Aug 2022 09:39:00 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id l15-20020a17090aec0f00b001f216407204sm11136513pjy.36.2022.08.02.09.38.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 09:38:59 -0700 (PDT) Date: Tue, 2 Aug 2022 16:38:55 +0000 From: Sean Christopherson To: Chao Peng Cc: Wei Wang , "Gupta, Pankaj" , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, qemu-devel@nongnu.org, linux-kselftest@vger.kernel.org, Paolo Bonzini , Jonathan Corbet , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H . Peter Anvin" , Hugh Dickins , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Shuah Khan , Mike Rapoport , Steven Price , "Maciej S . Szmigiero" , Vlastimil Babka , Vishal Annapurve , Yu Zhang , "Kirill A . Shutemov" , luto@kernel.org, jun.nakajima@intel.com, dave.hansen@intel.com, ak@linux.intel.com, david@redhat.com, aarcange@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, Quentin Perret , Michael Roth , mhocko@suse.com, Muchun Song Subject: Re: [PATCH v7 11/14] KVM: Register/unregister the guest private memory regions Message-ID: References: <36e671d2-6b95-8e4f-c2ac-fee4b2670c6e@amd.com> <20220720150706.GB124133@chaop.bj.intel.com> <45ae9f57-d595-f202-abb5-26a03a2ca131@linux.intel.com> <20220721092906.GA153288@chaop.bj.intel.com> <20220725130417.GA304216@chaop.bj.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-api@vger.kernel.org On Tue, Aug 02, 2022, Sean Christopherson wrote: > I think we should avoid UNMAPPABLE even on the KVM side of things for the core > memslots functionality and instead be very literal, e.g. > > KVM_HAS_FD_BASED_MEMSLOTS > KVM_MEM_FD_VALID > > We'll still need KVM_HAS_USER_UNMAPPABLE_MEMORY, but it won't be tied directly to > the memslot. Decoupling the two thingis will require a bit of extra work, but the > code impact should be quite small, e.g. explicitly query and propagate > MEMFILE_F_USER_INACCESSIBLE to kvm_memory_slot to track if a memslot can be private. > And unless I'm missing something, it won't require an additional memslot flag. > The biggest oddity (if we don't also add KVM_MEM_PRIVATE) is that KVM would > effectively ignore the hva for fd-based memslots for VM types that don't support > private memory, i.e. userspace can't opt out of using the fd-based backing, but that > doesn't seem like a deal breaker. Hrm, but basing private memory on top of a generic FD_VALID would effectively require shared memory to use hva-based memslots for confidential VMs. That'd yield a very weird API, e.g. non-confidential VMs could be backed entirely by fd-based memslots, but confidential VMs would be forced to use hva-based memslots. Ignore this idea for now. If there's an actual use case for generic fd-based memory then we'll want a separate flag, fd, and offset, i.e. that support could be added independent of KVM_MEM_PRIVATE.