Re: [PATCH v14 13/22] KVM: selftests: Support guest_memfd in-place conversion
From: Sean Christopherson
Date: Mon Oct 12 2026 - 16:14:02 EST
On Mon, Oct 12, 2026, Ackerley Tng wrote:
> Sean Christopherson <seanjc@xxxxxxxxxx> writes:
> > The alternative would be to take sev_cmd_mutex around the kvm_gmem_populate() call
> > in snp_launch_update(), but even if the CPP maintainers were willing to provide hooks
>
> I realized you meant CCP/PSP instead of CPP :)
>
> > to allow that, I'm not willing to take such a hack in KVM.
> >
>
> Is this a hack because sev_cmd_mutex() would be held for a long time
> while the populate loop executes?
It would also bleed CCP internals into KVM, and in general doesn't pass a basic
"is this the right thing to do" test.
> > So, very sadly, I think in-place conversion is dead for 7.4, and will need to be
> > revived on top of an overhaul of sev_cmd_mutex locking.
> >
> > Or I guess maybe a less painful temporary workaround would be to disable support
> > for SNP if in-place conversion is enabled. That would avoid extending the in-place
> > conversion bottleneck for TDX, pKVM, and CCA, without having to take a gross hack
> > to make SNP play nice.
> >
> > E.g. this as a workaround for 7.4 (not yet tested)
> >
> > diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> > index fad72cab76cf..df885b8214d4 100644
> > --- a/arch/x86/kvm/svm/sev.c
> > +++ b/arch/x86/kvm/svm/sev.c
> > @@ -3213,6 +3213,14 @@ void __init sev_hardware_setup(void)
> > sev_snp_supported = sev_snp_enabled && cc_platform_has(CC_ATTR_HOST_SEV_SNP);
> >
> > out:
> > + /*
> > + * FIXME: Allow SNP with in-place guest_memfd conversion once the PSP
> > + * driver no longer takes its global mutex outside of mmap_lock (which
> > + * leads to deadlock with sev_gmem_post_populate()).
> > + */
> > + if (gmem_in_place_conversion)
> > + sev_snp_supported = false;
> > +
>
> If we go with something like this, when SNP and gmem_in_place_conversion
> starts to work together, would we need some kind of new CAP or other way
> to advertise that guest_memfd and SNP are now friends?
I don't think so? KVM already enumerates support for SNP, so reverting the
block should tell userspace everything it needs. We'd need to document that
enabling in-place conversion disables SNP support, but I think it's purely a
documentation problem.