Ackerley Tng via B4 Relay <[email protected]> writes:
> From: Sean Christopherson <[email protected]> > > Now that guest_memfd supports tracking private vs. shared within gmem > itself, allow userspace to specify INIT_SHARED on a guest_memfd instance > for x86 Confidential Computing (CoCo) VMs, so long as per-VM attributes > are disabled, i.e. when it's actually possible for a guest_memfd instance > to contain shared memory. > > Signed-off-by: Sean Christopherson <[email protected]> > Signed-off-by: Ackerley Tng <[email protected]> > --- > arch/x86/kvm/x86.c | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 1560de1e95be0..6609957ecfea3 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -14172,14 +14172,13 @@ bool kvm_arch_no_poll(struct kvm_vcpu *vcpu) > } > > #ifdef CONFIG_KVM_GUEST_MEMFD > -/* > - * KVM doesn't yet support initializing guest_memfd memory as shared for VMs > - * with private memory (the private vs. shared tracking needs to be moved > into > - * guest_memfd). > - */ > bool kvm_arch_supports_gmem_init_shared(struct kvm *kvm) > { > - return !kvm_arch_has_private_mem(kvm); > + /* > + * INIT_SHARED isn't supported if the memory attributes are per-VM, > + * in which case guest_memfd can _only_ be used for private memory. > + */ > + return !vm_memory_attributes || !kvm_arch_has_private_mem(kvm); Adding a note here from PUCK on 2026-05-20: Michael pointed out that it's odd that when vm_memory_attributes is available, guest_memfd still can only be used for private memory. It is a little odd, but we don't want to investigate the complexities of supporting it, and Sean says this is working as intended, in line with deprecating vm_memory_attributes=true. > } > > #ifdef CONFIG_HAVE_KVM_ARCH_GMEM_PREPARE > > -- > 2.54.0.563.g4f69b47b94-goog
