Re: [PATCH v3 01/11] KVM: arm64: guest_memfd: Check mmap support when preparing memslot
From: Suzuki K Poulose
Date: Mon Nov 23 2026 - 06:13:49 EST
On 19/11/2026 14:54, Sean Christopherson wrote:
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
I don't understand this part. With inplace conversion, we mark the slot
as GMEM_ONLY and always resolve shared faults from the gmem (on arm64
as described by the API). So, isn't it a usage error from the VMM if it
plans to use GUEST_MEMFD_FLAG_MMAP=false with inplace conversion ?
In other words, do you mean to say, passing a non-gmem fd userspace
address is fine with GUEST_MEMFD_FLAG_MMAP=false ? But the API
documentation and the GMEM_ONLY flags contradict the usage.
Now, should we reject that in KVM or not is the secondary question.
(b) something in KVM tries to actually GUP the memslot using the
userspace virtual address.
Agreed
Suzuki
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.