Re: [PATCH v8 04/46] KVM: Decouple kvm_has_arch_private_mem from CONFIG_KVM_VM_MEMORY_ATTRIBUTES
From: Ackerley Tng <hidden>
Date: 2026-06-24 00:13:36
Also in:
kvm, linux-coco, linux-doc, linux-kselftest, linux-mm, lkml
Binbin Wu [off-list ref] writes:
On 6/19/2026 8:31 AM, Ackerley Tng via B4 Relay wrote:quoted
From: Sean Christopherson <seanjc@google.com> When memory attributes become trackable in guest_memfd, the concept of having private memory is no longer dependent on CONFIG_KVM_VM_MEMORY_ATTRIBUTES. With this, on x86, kvm_arch_has_private_mem() is defined if some CoCo platform support (or the testing CONFIG_KVM_SW_PROTECTED_VM) is compiled in. Signed-off-by: Sean Christopherson <seanjc@google.com> Co-developed-by: Ackerley Tng <redacted> Signed-off-by: Ackerley Tng <redacted>Reviewed-by: Binbin Wu <redacted> One nit below.quoted
--- arch/x86/include/asm/kvm_host.h | 4 +++- include/linux/kvm_host.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 8e8eb8a5e8a6b..1bde67cf6eb0e 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h@@ -2394,7 +2394,9 @@ void kvm_configure_mmu(bool enable_tdp, int tdp_forced_root_level, int tdp_max_root_level, int tdp_huge_page_level); -#ifdef CONFIG_KVM_VM_MEMORY_ATTRIBUTES +#if defined(CONFIG_KVM_SW_PROTECTED_VM) || \ + defined(CONFIG_KVM_INTEL_TDX) || \ + defined(CONFIG_KVM_AMD_SEV)Nit: Vertically align the defined(XXX) statements for better readability?
Sean had this aligned with spaces, and checkpatch complained about having no spaces before tabs, so I switched it to tabs instead since I don't think alignment like that is officially documented either way. Either way is fine :)
quoted
#define kvm_arch_has_private_mem(kvm) ((kvm)->arch.has_private_mem) #endifdiff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 201d0f2143976..d370e834d619e 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h@@ -722,7 +722,7 @@ static inline int kvm_arch_vcpu_memslots_id(struct kvm_vcpu *vcpu) } #endif -#ifndef CONFIG_KVM_VM_MEMORY_ATTRIBUTES +#ifndef kvm_arch_has_private_mem static inline bool kvm_arch_has_private_mem(struct kvm *kvm) { return false;