Skip to content

Commit 36cf63b

Browse files
Fuad Tabbabonzini
authored andcommitted
KVM: Rename CONFIG_KVM_GENERIC_PRIVATE_MEM to CONFIG_HAVE_KVM_ARCH_GMEM_POPULATE
The original name was vague regarding its functionality. This Kconfig option specifically enables and gates the kvm_gmem_populate() function, which is responsible for populating a GPA range with guest data. The new name, HAVE_KVM_ARCH_GMEM_POPULATE, describes the purpose of the option: to enable arch-specific guest_memfd population mechanisms. It also follows the same pattern as the other HAVE_KVM_ARCH_* configuration options. This improves clarity for developers and ensures the name accurately reflects the functionality it controls, especially as guest_memfd support expands beyond purely "private" memory scenarios. Temporarily keep KVM_GENERIC_PRIVATE_MEM as an x86-only config so as to minimize churn, and to hopefully make it easier to see what features require HAVE_KVM_ARCH_GMEM_POPULATE. On that note, omit GMEM_POPULATE for KVM_X86_SW_PROTECTED_VM, as regular ol' memset() suffices for software-protected VMs. As for KVM_GENERIC_PRIVATE_MEM, a future change will select KVM_GUEST_MEMFD for all 64-bit KVM builds, at which point the intermediate config will become obsolete and can/will be dropped. Reviewed-by: Ira Weiny <ira.weiny@intel.com> Reviewed-by: Gavin Shan <gshan@redhat.com> Reviewed-by: Shivank Garg <shivankg@amd.com> Reviewed-by: Vlastimil Babka <vbabka@suse.cz> Co-developed-by: David Hildenbrand <david@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Signed-off-by: Fuad Tabba <tabba@google.com> Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com> Co-developed-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Sean Christopherson <seanjc@google.com> Message-ID: <20250729225455.670324-6-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 924121e commit 36cf63b

4 files changed

Lines changed: 16 additions & 11 deletions

File tree

arch/x86/kvm/Kconfig

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,16 @@ config KVM_WERROR
7979

8080
If in doubt, say "N".
8181

82+
config KVM_X86_PRIVATE_MEM
83+
select KVM_GENERIC_MEMORY_ATTRIBUTES
84+
select KVM_GUEST_MEMFD
85+
bool
86+
8287
config KVM_SW_PROTECTED_VM
8388
bool "Enable support for KVM software-protected VMs"
8489
depends on EXPERT
8590
depends on KVM_X86 && X86_64
86-
select KVM_GENERIC_PRIVATE_MEM
91+
select KVM_X86_PRIVATE_MEM
8792
help
8893
Enable support for KVM software-protected VMs. Currently, software-
8994
protected VMs are purely a development and testing vehicle for
@@ -133,8 +138,8 @@ config KVM_INTEL_TDX
133138
bool "Intel Trust Domain Extensions (TDX) support"
134139
default y
135140
depends on INTEL_TDX_HOST
136-
select KVM_GENERIC_PRIVATE_MEM
137-
select KVM_GENERIC_MEMORY_ATTRIBUTES
141+
select KVM_X86_PRIVATE_MEM
142+
select HAVE_KVM_ARCH_GMEM_POPULATE
138143
help
139144
Provides support for launching Intel Trust Domain Extensions (TDX)
140145
confidential VMs on Intel processors.
@@ -157,9 +162,10 @@ config KVM_AMD_SEV
157162
depends on KVM_AMD && X86_64
158163
depends on CRYPTO_DEV_SP_PSP && !(KVM_AMD=y && CRYPTO_DEV_CCP_DD=m)
159164
select ARCH_HAS_CC_PLATFORM
160-
select KVM_GENERIC_PRIVATE_MEM
165+
select KVM_X86_PRIVATE_MEM
161166
select HAVE_KVM_ARCH_GMEM_PREPARE
162167
select HAVE_KVM_ARCH_GMEM_INVALIDATE
168+
select HAVE_KVM_ARCH_GMEM_POPULATE
163169
help
164170
Provides support for launching encrypted VMs which use Secure
165171
Encrypted Virtualization (SEV), Secure Encrypted Virtualization with

include/linux/kvm_host.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2534,7 +2534,7 @@ static inline int kvm_gmem_get_pfn(struct kvm *kvm,
25342534
int kvm_arch_gmem_prepare(struct kvm *kvm, gfn_t gfn, kvm_pfn_t pfn, int max_order);
25352535
#endif
25362536

2537-
#ifdef CONFIG_KVM_GENERIC_PRIVATE_MEM
2537+
#ifdef CONFIG_HAVE_KVM_ARCH_GMEM_POPULATE
25382538
/**
25392539
* kvm_gmem_populate() - Populate/prepare a GPA range with guest data
25402540
*

virt/kvm/Kconfig

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,14 @@ config KVM_GUEST_MEMFD
116116
select XARRAY_MULTI
117117
bool
118118

119-
config KVM_GENERIC_PRIVATE_MEM
120-
select KVM_GENERIC_MEMORY_ATTRIBUTES
121-
select KVM_GUEST_MEMFD
122-
bool
123-
124119
config HAVE_KVM_ARCH_GMEM_PREPARE
125120
bool
126121
depends on KVM_GUEST_MEMFD
127122

128123
config HAVE_KVM_ARCH_GMEM_INVALIDATE
129124
bool
130125
depends on KVM_GUEST_MEMFD
126+
127+
config HAVE_KVM_ARCH_GMEM_POPULATE
128+
bool
129+
depends on KVM_GUEST_MEMFD

virt/kvm/guest_memfd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ int kvm_gmem_get_pfn(struct kvm *kvm, struct kvm_memory_slot *slot,
627627
}
628628
EXPORT_SYMBOL_GPL(kvm_gmem_get_pfn);
629629

630-
#ifdef CONFIG_KVM_GENERIC_PRIVATE_MEM
630+
#ifdef CONFIG_HAVE_KVM_ARCH_GMEM_POPULATE
631631
long kvm_gmem_populate(struct kvm *kvm, gfn_t start_gfn, void __user *src, long npages,
632632
kvm_gmem_populate_cb post_populate, void *opaque)
633633
{

0 commit comments

Comments
 (0)