Thread (85 messages) flat view 85 messages, 8 authors, 9d ago

Re: [PATCH v12 23/45] KVM: Let userspace disable per-VM mem attributes, enable per-gmem attributes

From: Ackerley Tng <hidden>
Date: 2026-09-09 15:32:54
Also in: kvm, linux-coco, linux-doc, linux-kselftest, linux-mm, lkml

Sean Christopherson [off-list ref] writes:
On Tue, Sep 01, 2026, Fuad Tabba wrote:
quoted
Hi Sean, Ackerley,

On Mon, 31 Aug 2026 at 01:25, Ackerley Tng via B4 Relay
[off-list ref] wrote:
...
quoted
+       kvm.gmem_in_place_conversion=
+                       [KVM] Controls whether KVM enables in-place conversion
+                       support for guest_memfd and tracks the private/shared
+                       state of memory per guest_memfd instead of per VM.
+
+                       If enabled, KVM enables the KVM_SET_MEMORY_ATTRIBUTES2
+                       ioctl on guest_memfd file descriptors and disables the
+                       legacy VM-scoped KVM_SET_MEMORY_ATTRIBUTES ioctl for
+                       private memory state tracking. Only the
+                       KVM_MEMORY_ATTRIBUTE_PRIVATE attribute moves to
+                       per-guest_memfd tracking; other attributes remain
+                       per-VM.
+
+                       This parameter toggles KVM's in-place conversion
+                       capability support. Whether a VMM uses separate backends
+                       or out-of-place memory management is determined by
+                       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
+                       conversion is unconditionally enabled.
+
+                       Default is Y (on).
The parameter is only settable when CONFIG_KVM_VM_MEMORY_ATTRIBUTES=y, and
in that config gmem_in_place_conversion initialises to
!IS_ENABLED(CONFIG_KVM_VM_MEMORY_ATTRIBUTES), i.e. N, not Y. Is the doc line
wrong, or is N-by-default not what was intended here?
The doc is wrong.  The intent is to maintain backwards compatibility with existing
deployments if KVM_VM_MEMORY_ATTRIBUTES=y.
Thanks Fuad! I got confused, gmem_in_place_conversion the variable
defaults to true (because CONFIG_KVM_VM_MEMORY_ATTRIBUTES is by default
not set), but if the parameter exists, CONFIG_KVM_VM_MEMORY_ATTRIBUTES
must be set and so the parameter defaults to N.

Will fix in the next revision.
quoted
quoted
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 05c518c9b8078..929fd3e1a01e6 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -103,7 +103,10 @@ 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 = false;
+bool __ro_after_init gmem_in_place_conversion = !IS_ENABLED(CONFIG_KVM_VM_MEMORY_ATTRIBUTES);
+#ifdef CONFIG_KVM_VM_MEMORY_ATTRIBUTES
+module_param(gmem_in_place_conversion, bool, 0444);
+#endif
 EXPORT_SYMBOL_FOR_KVM_INTERNAL(gmem_in_place_conversion);
 #endif
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help