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

- From: David Hildenbrand (Arm) \<david@kernel.org\>
- Date: 2026-09-09 15:47:28 
- List: linux-trace-kernel
- Page: https://ratatoskr.run/linux-trace-kernel/2026/09/17540679
- Thread: https://ratatoskr.run/kvm/2026/08/17480489/t/2.md

```text
On 8/31/26 02:25, Ackerley Tng via B4 Relay wrote:
> From: Sean Christopherson <seanjc@google.com>
> 
> Allow the user to disable KVM_VM_MEMORY_ATTRIBUTES even when KVM supports
> PRIVATE and SHARED attributes, and expose gmem_in_place_conversion as a
> module parameter when per-VM attributes are supported.  I.e. let userspace
> enable in-place PRIVATE<=>SHARED conversion of guest_memfd pages.
> 
> Provide both a Kconfig option and a (conditional) module param so that
> deployments that use a custom kernel can fully disable per-VM tracking,
> while not forcing distros to ship two separate kernels in order to provide
> backwards compatibility for downstream users.
> 
> Don't allow running VMs with mixed tracking for a given instance of KVM,
> i.e. disallow toggling the module param after KVM is loaded, as the extra
> complexity needed to handle per-VM behavior far outweighs any potential
> benefit.  E.g. neither TDX nor SNP supports live migration, so in effect
> the requirement is that existing deployments that want to support both the
> old and the new models would need to tell their VMM which flavor of
> tracking to use.
> 
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> Reviewed-by: Fuad Tabba <redacted>
> Tested-by: Shivank Garg <redacted>
> [Define module_param only if CONFIG_KVM_VM_MEMORY_ATTRIBUTES is enabled]
> Suggested-by: Xiaoyao Li <redacted>
> Reviewed-by: Xiaoyao Li <redacted>
> Co-developed-by: Ackerley Tng <redacted>
> Signed-off-by: Ackerley Tng <redacted>
> ---
>  Documentation/admin-guide/kernel-parameters.txt | 25 +++++++++++++++++++++++++
>  arch/x86/include/asm/kvm_host.h                 |  4 +++-
>  arch/x86/kvm/Kconfig                            | 14 ++++++++++----
>  virt/kvm/kvm_main.c                             |  5 ++++-
>  4 files changed, 42 insertions(+), 6 deletions(-)
> 
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index 68647ff4bdd24..b5719714458fb 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -3156,6 +3156,31 @@ Kernel parameters
>  	kvm.enable_vmware_backdoor=[KVM] Support VMware backdoor PV interface.
>  				   Default is false (don't support).
>  
> +	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).

With the doc fixed

Acked-by: David Hildenbrand (Arm) <david@kernel.org>

-- 
Cheers,

David
```
