mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: Ackerley Tng <ackerleytng@google.com>,
	Fuad Tabba <tabba@google.com>, Xiaoyao Li <xiaoyao.li@intel.com>,
	Binbin Wu <binbin.wu@linux.intel.com>,
	Shivank Garg <shivankg@amd.com>, Yan Zhao <yan.y.zhao@intel.com>,
	Sean Christopherson <seanjc@google.com>
Subject: [PATCH 1/3] KVM: split CONFIG_KVM_PRIVATE_MEMATTR_VM out of KVM_VM_MEMORY_ATTRIBUTES
Date: Tue, 20 Oct 2026 09:14:45 -0400	[thread overview]
Message-ID: <20261020131447.122096-2-pbonzini@redhat.com> (raw)
In-Reply-To: <20261020131447.122096-1-pbonzini@redhat.com>

With Linux 7.4 the "private" memory attribute was moved from the VM
to the individual guest_memfd file descriptor.  The old semantics are
available for backwards compatibility via CONFIG_KVM_VM_MEMORY_ATTRIBUTES.

However, this ties support for VM memory attributes entirely to
a backwards compatibility symbol, which is a problem when adding
VM memory attributes other than PRIVATE.  Thus, make
CONFIG_KVM_VM_MEMORY_ATTRIBUTES the equivalent of the old
CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES, and use a more descriptive name
for the private memory attribute.  Do this now, instead of waiting
for more attributes to come, before distros start adjusting
their build configuration.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 Documentation/admin-guide/kernel-parameters.txt | 4 ++--
 arch/x86/kvm/Kconfig                            | 3 ++-
 include/linux/kvm_host.h                        | 4 +++-
 virt/kvm/Kconfig                                | 3 +++
 virt/kvm/kvm_main.c                             | 6 +++---
 5 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 410a3eed3a3d..42ff19defe16 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -3178,8 +3178,8 @@ Kernel parameters
 			userspace VMM design.
 
 			Note, this parameter is only available when
-			CONFIG_KVM_VM_MEMORY_ATTRIBUTES=y. When
-			CONFIG_KVM_VM_MEMORY_ATTRIBUTES is not set, in-place
+			CONFIG_KVM_PRIVATE_MEMATTR_VM=y. When
+			CONFIG_KVM_PRIVATE_MEMATTR_VM is not set, in-place
 			conversion is enabled (and cannot be disabled) if KVM
 			is built with private memory support.
 
diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig
index 796d33f629d3..01a683a9042a 100644
--- a/arch/x86/kvm/Kconfig
+++ b/arch/x86/kvm/Kconfig
@@ -76,9 +76,10 @@ config KVM_WERROR
 
 	  If in doubt, say "N".
 
-config KVM_VM_MEMORY_ATTRIBUTES
+config KVM_PRIVATE_MEMATTR_VM
 	bool "Enable per-VM PRIVATE vs. SHARED attributes (for CoCo VMs)"
 	depends on KVM_SW_PROTECTED_VM || KVM_INTEL_TDX || KVM_AMD_SEV
+	select KVM_VM_MEMORY_ATTRIBUTES
 	help
 	  Enable support for tracking PRIVATE vs. SHARED memory using per-VM
 	  memory attributes.  Using per-VM attributes is deprecated in favor of
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 4d4e76a50d77..09c57d31d153 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -2582,12 +2582,14 @@ bool kvm_arch_pre_set_vm_memory_attributes(struct kvm *kvm,
 					   struct kvm_gfn_range *range);
 bool kvm_arch_post_set_vm_memory_attributes(struct kvm *kvm,
 					    struct kvm_gfn_range *range);
+#endif  /* CONFIG_KVM_VM_MEMORY_ATTRIBUTES */
 
+#ifdef CONFIG_KVM_PRIVATE_MEMATTR_VM
 static inline bool kvm_vm_is_private_gfn(struct kvm *kvm, gfn_t gfn)
 {
 	return kvm_get_vm_memory_attributes(kvm, gfn) & KVM_MEMORY_ATTRIBUTE_PRIVATE;
 }
-#endif  /* CONFIG_KVM_VM_MEMORY_ATTRIBUTES */
+#endif  /* CONFIG_KVM_PRIVATE_MEMATTR_VM */
 
 #ifdef kvm_arch_has_private_mem
 extern bool gmem_in_place_conversion;
diff --git a/virt/kvm/Kconfig b/virt/kvm/Kconfig
index c5bfaa1f7749..99c9969e77a4 100644
--- a/virt/kvm/Kconfig
+++ b/virt/kvm/Kconfig
@@ -101,3 +101,6 @@ config HAVE_KVM_ARCH_GMEM_INVALIDATE
 config HAVE_KVM_ARCH_GMEM_POPULATE
        bool
        depends on KVM_GUEST_MEMFD
+
+config KVM_VM_MEMORY_ATTRIBUTES
+       bool
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index a97aa5b92616..3e35766f5c7e 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -105,8 +105,8 @@ static bool __ro_after_init allow_unsafe_mappings;
 module_param(allow_unsafe_mappings, bool, 0444);
 
 #ifdef kvm_arch_has_private_mem
-bool __ro_after_init gmem_in_place_conversion = !IS_ENABLED(CONFIG_KVM_VM_MEMORY_ATTRIBUTES);
-#ifdef CONFIG_KVM_VM_MEMORY_ATTRIBUTES
+bool __ro_after_init gmem_in_place_conversion = !IS_ENABLED(CONFIG_KVM_PRIVATE_MEMATTR_VM);
+#ifdef CONFIG_KVM_PRIVATE_MEMATTR_VM
 module_param(gmem_in_place_conversion, bool, 0444);
 #endif
 EXPORT_SYMBOL_FOR_KVM_INTERNAL(gmem_in_place_conversion);
@@ -2713,7 +2713,7 @@ static void kvm_init_memory_attributes(void)
 {
 	if (gmem_in_place_conversion)
 		static_call_update(__kvm_is_private_gfn, kvm_gmem_is_private_gfn);
-#ifdef CONFIG_KVM_VM_MEMORY_ATTRIBUTES
+#ifdef CONFIG_KVM_PRIVATE_MEMATTR_VM
 	else
 		static_call_update(__kvm_is_private_gfn, kvm_vm_is_private_gfn);
 #endif
-- 
2.52.0



  reply	other threads:[~2026-10-20 13:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20 13:14 [PATCH 0/3] KVM: Kconfig fixes for the VM-wide private memory attribute Paolo Bonzini
2026-10-20 13:14 ` Paolo Bonzini [this message]
2026-10-20 13:14 ` [PATCH 2/3] KVM: x86: leave the legacy private attribute in for TDX and SEV Paolo Bonzini
2026-10-20 13:14 ` [PATCH 3/3] KVM: always make in-place conversion a compile-time constant when possible Paolo Bonzini

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=20261020131447.122096-2-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=ackerleytng@google.com \
    --cc=binbin.wu@linux.intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=seanjc@google.com \
    --cc=shivankg@amd.com \
    --cc=tabba@google.com \
    --cc=xiaoyao.li@intel.com \
    --cc=yan.y.zhao@intel.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

all inboxes | Powered by JetHome®