From: "Roy, Patrick" <roypat@amazon.co.uk>
To: "ackerleytng@google.com" <ackerleytng@google.com>,
Sean Christopherson <seanjc@google.com>,
Fuad Tabba <tabba@google.com>
Cc: "akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"amoorthy@google.com" <amoorthy@google.com>,
"anup@brainfault.org" <anup@brainfault.org>,
"aou@eecs.berkeley.edu" <aou@eecs.berkeley.edu>,
"brauner@kernel.org" <brauner@kernel.org>,
"catalin.marinas@arm.com" <catalin.marinas@arm.com>,
"chao.p.peng@linux.intel.com" <chao.p.peng@linux.intel.com>,
"chenhuacai@kernel.org" <chenhuacai@kernel.org>,
"david@redhat.com" <david@redhat.com>,
"dmatlack@google.com" <dmatlack@google.com>,
"fvdl@google.com" <fvdl@google.com>,
"hch@infradead.org" <hch@infradead.org>,
"hughd@google.com" <hughd@google.com>,
"ira.weiny@intel.com" <ira.weiny@intel.com>,
"isaku.yamahata@gmail.com" <isaku.yamahata@gmail.com>,
"isaku.yamahata@intel.com" <isaku.yamahata@intel.com>,
"james.morse@arm.com" <james.morse@arm.com>,
"jarkko@kernel.org" <jarkko@kernel.org>,
"jgg@nvidia.com" <jgg@nvidia.com>,
"jhubbard@nvidia.com" <jhubbard@nvidia.com>,
"jthoughton@google.com" <jthoughton@google.com>,
"keirf@google.com" <keirf@google.com>,
"kirill.shutemov@linux.intel.com"
<kirill.shutemov@linux.intel.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"kvmarm@lists.linux.dev" <kvmarm@lists.linux.dev>,
"liam.merwick@oracle.com" <liam.merwick@oracle.com>,
"linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"mail@maciej.szmigiero.name" <mail@maciej.szmigiero.name>,
"maz@kernel.org" <maz@kernel.org>,
"mic@digikod.net" <mic@digikod.net>,
"michael.roth@amd.com" <michael.roth@amd.com>,
"mpe@ellerman.id.au" <mpe@ellerman.id.au>,
"oliver.upton@linux.dev" <oliver.upton@linux.dev>,
"palmer@dabbelt.com" <palmer@dabbelt.com>,
"pankaj.gupta@amd.com" <pankaj.gupta@amd.com>,
"paul.walmsley@sifive.com" <paul.walmsley@sifive.com>,
"pbonzini@redhat.com" <pbonzini@redhat.com>,
"peterx@redhat.com" <peterx@redhat.com>,
"qperret@google.com" <qperret@google.com>,
"quic_cvanscha@quicinc.com" <quic_cvanscha@quicinc.com>,
"quic_eberman@quicinc.com" <quic_eberman@quicinc.com>,
"quic_mnalajal@quicinc.com" <quic_mnalajal@quicinc.com>,
"quic_pderrin@quicinc.com" <quic_pderrin@quicinc.com>,
"quic_pheragu@quicinc.com" <quic_pheragu@quicinc.com>,
"quic_svaddagi@quicinc.com" <quic_svaddagi@quicinc.com>,
"quic_tsoni@quicinc.com" <quic_tsoni@quicinc.com>,
"rientjes@google.com" <rientjes@google.com>,
"Roy, Patrick" <roypat@amazon.co.uk>,
"shuah@kernel.org" <shuah@kernel.org>,
"steven.price@arm.com" <steven.price@arm.com>,
"suzuki.poulose@arm.com" <suzuki.poulose@arm.com>,
"vannapurve@google.com" <vannapurve@google.com>,
"vbabka@suse.cz" <vbabka@suse.cz>,
"viro@zeniv.linux.org.uk" <viro@zeniv.linux.org.uk>,
"wei.w.wang@intel.com" <wei.w.wang@intel.com>,
"will@kernel.org" <will@kernel.org>,
"willy@infradead.org" <willy@infradead.org>,
"xiaoyao.li@intel.com" <xiaoyao.li@intel.com>,
"yilun.xu@intel.com" <yilun.xu@intel.com>,
"yuzenghui@huawei.com" <yuzenghui@huawei.com>
Subject: Re: [PATCH v12 04/18] KVM: x86: Rename kvm->arch.has_private_mem to kvm->arch.supports_gmem
Date: Wed, 25 Jun 2025 06:33:31 +0000 [thread overview]
Message-ID: <20250625063328.28063-1-roypat@amazon.co.uk> (raw)
In-Reply-To: <diqzh604lv6n.fsf@ackerleytng-ctop.c.googlers.com>
Hi Ackerley!
On Tue, 2025-06-24 at 21:51 +0100, Ackerley Tng wrote:> Sean Christopherson <seanjc@google.com> writes:
>
[...]
>> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
>> index 3d69da6d2d9e..4bc50c1e21bd 100644
>> --- a/arch/x86/include/asm/kvm_host.h
>> +++ b/arch/x86/include/asm/kvm_host.h
>> @@ -1341,7 +1341,7 @@ struct kvm_arch {
>> unsigned int indirect_shadow_pages;
>> u8 mmu_valid_gen;
>> u8 vm_type;
>> - bool has_private_mem;
>> + bool supports_gmem;
>> bool has_protected_state;
>> bool pre_fault_allowed;
>> struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES];
>> @@ -2270,7 +2270,7 @@ void kvm_configure_mmu(bool enable_tdp, int tdp_forced_root_level,
>>
>>
>> #ifdef CONFIG_KVM_GMEM
>> -#define kvm_arch_supports_gmem(kvm) ((kvm)->arch.has_private_mem)
>> +#define kvm_arch_supports_gmem(kvm) ((kvm)->arch.supports_gmem)
>> #else
>> #define kvm_arch_supports_gmem(kvm) false
>> #endif
>> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
>> index e7ecf089780a..c4e10797610c 100644
>> --- a/arch/x86/kvm/mmu/mmu.c
>> +++ b/arch/x86/kvm/mmu/mmu.c
>> @@ -3488,7 +3488,7 @@ static bool page_fault_can_be_fast(struct kvm *kvm, struct kvm_page_fault *fault
>> * on RET_PF_SPURIOUS until the update completes, or an actual spurious
>> * case might go down the slow path. Either case will resolve itself.
>> */
>> - if (kvm->arch.has_private_mem &&
>> + if (kvm->arch.supports_gmem &&
>> fault->is_private != kvm_mem_is_private(kvm, fault->gfn))
>> return false;
>>
>
> This check should remain as a check on has_private_mem.
>
> If the VM supports private memory, skip fast page faults on fault type
> and KVM memory privacy status mismatches.
...
> Patrick, Nikita, am I right that for KVM_X86_DEFAULT_VM to work with
> mmap-able guest_memfd, the usage in page_fault_can_be_fast() need not be
> updated, and that patch 10/18 in this series will be sufficient?
Yeah, since KVM_X86_DEFAULT_VM does not and won't ever (?) support private
memory in guest_memfd (e.g. it always has to be used in all-shared mode) from
my understanding, the fault->is_private != kvm_mem_is_private(kvm, fault->gfn))
check should never succeed anyway. kvm_mem_is_private() will always return
false, and fault->is_private should always be false, too (unless the guest does
something it should not be doing, and even then the worst case is that we won't
be handling this weirdness "fast").
In my testing with earlier iterations of this series where
page_fault_can_be_fast() was untouched I also never saw any problems related to
page faults on x86.
Best,
Patrick
next prev parent reply other threads:[~2025-06-25 6:33 UTC|newest]
Thread overview: 75+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-11 13:33 [PATCH v12 00/18] KVM: Mapping guest_memfd backed memory at the host for software protected VMs Fuad Tabba
2025-06-11 13:33 ` [PATCH v12 01/18] KVM: Rename CONFIG_KVM_PRIVATE_MEM to CONFIG_KVM_GMEM Fuad Tabba
2025-06-11 13:33 ` [PATCH v12 02/18] KVM: Rename CONFIG_KVM_GENERIC_PRIVATE_MEM to CONFIG_KVM_GENERIC_GMEM_POPULATE Fuad Tabba
2025-06-11 13:33 ` [PATCH v12 03/18] KVM: Rename kvm_arch_has_private_mem() to kvm_arch_supports_gmem() Fuad Tabba
2025-06-11 13:33 ` [PATCH v12 04/18] KVM: x86: Rename kvm->arch.has_private_mem to kvm->arch.supports_gmem Fuad Tabba
2025-06-13 13:57 ` Ackerley Tng
2025-06-13 20:35 ` Sean Christopherson
2025-06-16 7:13 ` Fuad Tabba
2025-06-16 14:20 ` David Hildenbrand
2025-06-24 20:51 ` Ackerley Tng
2025-06-25 6:33 ` Roy, Patrick [this message]
2025-06-11 13:33 ` [PATCH v12 05/18] KVM: Rename kvm_slot_can_be_private() to kvm_slot_has_gmem() Fuad Tabba
2025-06-11 13:33 ` [PATCH v12 06/18] KVM: Fix comments that refer to slots_lock Fuad Tabba
2025-06-11 13:33 ` [PATCH v12 07/18] KVM: Fix comment that refers to kvm uapi header path Fuad Tabba
2025-06-11 13:33 ` [PATCH v12 08/18] KVM: guest_memfd: Allow host to map guest_memfd pages Fuad Tabba
2025-06-12 16:16 ` Shivank Garg
2025-06-13 21:03 ` Sean Christopherson
2025-06-13 21:18 ` David Hildenbrand
2025-06-13 22:48 ` Sean Christopherson
2025-06-16 6:52 ` Fuad Tabba
2025-06-16 14:16 ` David Hildenbrand
2025-06-17 23:04 ` Sean Christopherson
2025-06-18 11:18 ` Fuad Tabba
2025-06-16 13:44 ` Ira Weiny
2025-06-16 14:03 ` David Hildenbrand
2025-06-16 14:16 ` Fuad Tabba
2025-06-16 14:25 ` David Hildenbrand
2025-06-18 0:40 ` Sean Christopherson
2025-06-18 8:15 ` David Hildenbrand
2025-06-18 9:20 ` Xiaoyao Li
2025-06-18 9:27 ` David Hildenbrand
2025-06-18 9:44 ` Xiaoyao Li
2025-06-18 9:59 ` David Hildenbrand
2025-06-18 10:42 ` Xiaoyao Li
2025-06-18 11:14 ` David Hildenbrand
2025-06-18 12:17 ` Xiaoyao Li
2025-06-18 13:16 ` David Hildenbrand
2025-06-19 1:48 ` Sean Christopherson
2025-06-19 1:50 ` Sean Christopherson
2025-06-18 9:25 ` David Hildenbrand
2025-06-25 21:47 ` Ackerley Tng
2025-06-11 13:33 ` [PATCH v12 09/18] KVM: guest_memfd: Track shared memory support in memslot Fuad Tabba
2025-06-11 13:33 ` [PATCH v12 10/18] KVM: x86/mmu: Handle guest page faults for guest_memfd with shared memory Fuad Tabba
2025-06-13 22:08 ` Sean Christopherson
2025-06-24 23:40 ` Ackerley Tng
2025-06-27 15:01 ` Ackerley Tng
2025-06-30 8:07 ` Fuad Tabba
2025-06-30 14:44 ` Ackerley Tng
2025-06-30 15:08 ` Fuad Tabba
2025-06-30 19:26 ` Shivank Garg
2025-06-30 20:03 ` David Hildenbrand
2025-07-01 14:15 ` Ackerley Tng
2025-07-01 14:44 ` David Hildenbrand
2025-07-08 0:05 ` Sean Christopherson
2025-07-08 13:44 ` Ackerley Tng
2025-06-11 13:33 ` [PATCH v12 11/18] KVM: x86: Consult guest_memfd when computing max_mapping_level Fuad Tabba
2025-06-11 13:33 ` [PATCH v12 12/18] KVM: x86: Enable guest_memfd shared memory for non-CoCo VMs Fuad Tabba
2025-06-11 13:33 ` [PATCH v12 13/18] KVM: arm64: Refactor user_mem_abort() Fuad Tabba
2025-06-11 13:33 ` [PATCH v12 14/18] KVM: arm64: Handle guest_memfd-backed guest page faults Fuad Tabba
2025-06-12 17:33 ` James Houghton
2025-06-11 13:33 ` [PATCH v12 15/18] KVM: arm64: Enable host mapping of shared guest_memfd memory Fuad Tabba
2025-06-11 13:33 ` [PATCH v12 16/18] KVM: Introduce the KVM capability KVM_CAP_GMEM_SHARED_MEM Fuad Tabba
2025-06-11 13:33 ` [PATCH v12 17/18] KVM: selftests: Don't use hardcoded page sizes in guest_memfd test Fuad Tabba
2025-06-12 16:24 ` Shivank Garg
2025-06-11 13:33 ` [PATCH v12 18/18] KVM: selftests: guest_memfd mmap() test when mapping is allowed Fuad Tabba
2025-06-12 16:23 ` Shivank Garg
2025-06-12 17:38 ` [PATCH v12 00/18] KVM: Mapping guest_memfd backed memory at the host for software protected VMs David Hildenbrand
2025-06-24 10:02 ` Fuad Tabba
2025-06-24 10:16 ` David Hildenbrand
2025-06-24 10:25 ` Fuad Tabba
2025-06-24 11:44 ` David Hildenbrand
2025-06-24 11:58 ` Fuad Tabba
2025-06-24 17:50 ` Sean Christopherson
2025-06-25 8:00 ` Fuad Tabba
2025-06-25 14:07 ` Sean Christopherson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250625063328.28063-1-roypat@amazon.co.uk \
--to=roypat@amazon.co.uk \
--cc=ackerleytng@google.com \
--cc=akpm@linux-foundation.org \
--cc=amoorthy@google.com \
--cc=anup@brainfault.org \
--cc=aou@eecs.berkeley.edu \
--cc=brauner@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=chao.p.peng@linux.intel.com \
--cc=chenhuacai@kernel.org \
--cc=david@redhat.com \
--cc=dmatlack@google.com \
--cc=fvdl@google.com \
--cc=hch@infradead.org \
--cc=hughd@google.com \
--cc=ira.weiny@intel.com \
--cc=isaku.yamahata@gmail.com \
--cc=isaku.yamahata@intel.com \
--cc=james.morse@arm.com \
--cc=jarkko@kernel.org \
--cc=jgg@nvidia.com \
--cc=jhubbard@nvidia.com \
--cc=jthoughton@google.com \
--cc=keirf@google.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=liam.merwick@oracle.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mail@maciej.szmigiero.name \
--cc=maz@kernel.org \
--cc=mic@digikod.net \
--cc=michael.roth@amd.com \
--cc=mpe@ellerman.id.au \
--cc=oliver.upton@linux.dev \
--cc=palmer@dabbelt.com \
--cc=pankaj.gupta@amd.com \
--cc=paul.walmsley@sifive.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=qperret@google.com \
--cc=quic_cvanscha@quicinc.com \
--cc=quic_eberman@quicinc.com \
--cc=quic_mnalajal@quicinc.com \
--cc=quic_pderrin@quicinc.com \
--cc=quic_pheragu@quicinc.com \
--cc=quic_svaddagi@quicinc.com \
--cc=quic_tsoni@quicinc.com \
--cc=rientjes@google.com \
--cc=seanjc@google.com \
--cc=shuah@kernel.org \
--cc=steven.price@arm.com \
--cc=suzuki.poulose@arm.com \
--cc=tabba@google.com \
--cc=vannapurve@google.com \
--cc=vbabka@suse.cz \
--cc=viro@zeniv.linux.org.uk \
--cc=wei.w.wang@intel.com \
--cc=will@kernel.org \
--cc=willy@infradead.org \
--cc=xiaoyao.li@intel.com \
--cc=yilun.xu@intel.com \
--cc=yuzenghui@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox