Re: [PATCH v3 01/11] KVM: arm64: guest_memfd: Check mmap support when preparing memslot

From: Sean Christopherson

Date: Thu Nov 19 2026 - 09:55:45 EST


On Thu, Nov 19, 2026, Suzuki K Poulose wrote:
> I see, thanks Steven. For context:
>
> Arm64 currently (without inplace conversion support) only allows GMEM
> with MMAP flags only and relies on kvm_slot_gmem_only() to detect that
> the GMEM has MMAP flag. But, when we enable inplace conversion,
> we can't reliably reject the slots by kvm_slot_gmem_only(), because
> all GMEM slots are marked GMEM only with inplace conversion.
>
> Also, from the API Documentation,
>
> "When the KVM MMU performs a PFN lookup to service a guest fault, the fault
> will always be consumed from guest_memfd, regardless of whether it is a shared
> or a private fault (unless in-place conversion is disabled and the backing
> guest_memfd does not have the GUEST_MEMFD_FLAG_MMAP flag set)."
>
> So, in effect, with in-place conversion enabled a KVM_CREATE_GUEST_MEMFD
> without GUEST_MEMFD_FLAG_MMAP is an error

It's only an error if (a) the userspace address in the memslot points at the
gmem fd and (b) something in KVM tries to actually GUP the memslot using the
userspace virtual address.

> and thats what this patch is trying to fix in arm64 KVM. The question is:
>
> 1) Should this be fixed ? How does TDX/SNP support older VMMs with
> inplace conversion ? What was the conclusion on this breakage ?

There is no "breakage". If userspace doesn't point the userspace address at a
valid VMA, that userspace's problem. The only thing the early check would do is
prevent weird use cases that may or may not be valid (and for which KVM doesn't
care), and error out earlier if KVM guesses right and userspace really did goof.

> 2) If it should be, then shouldn't it be done in kvm_gmem_create() ?

No. As above, I don't see any reason to have the check at all.