Re: [PATCH v3 01/11] KVM: arm64: guest_memfd: Check mmap support when preparing memslot
From: Suzuki K Poulose
Date: Thu Nov 19 2026 - 05:10:58 EST
Cc: Ackerley, Sean
On 18/11/2026 15:18, Steven Price wrote:
On 18/11/2026 12:04, Suzuki K Poulose wrote:
On 18/11/2026 11:14, Steven Price wrote:
On 18/11/2026 10:34, Suzuki K Poulose wrote:
Hi Steven
On 17/11/2026 14:05, Fuad Tabba wrote:
Hi Steven,
On Mon, 16 Nov 2026 16:43:47 +0000, Steven Price
<steven.price@xxxxxxx> wrote:
Check the guest_memfd backing file when deciding whether an arm64
memslot has mappable memory rather than checking whether the slot is
gmem only. A public helper function is added to be able to reuse the
static kvm_gmem_supports_mmap() function.
nit: could the message say why this is needed? It's a no-op until
patch 8 defines kvm_arch_has_private_mem(), which makes every
guest_memfd slot gmem-only.
I still don't understand why this is needed. For arm64 we have always
prevented guest_memfd without MMAP, in kvm_arch_prepare_memory_region().
Fuad is correct, this isn't really needed until patch 8. Patch 8 defines
kvm_arch_has_private_mem() - that means that gmem_in_place_conversion
becomes true (see include/linux/kvm_host.h). That in turn means that
every guest_memfd slot is KVM_MEMSLOT_GMEM_ONLY including slots backed
by a file without mmap support.
But we dont support slots without MMAP anyways even without this series.
So, does it really matter for arm64 ?
So ChatGPT produced the attached test. It creates a non-mappable gmem
and tries to add it to a normal (non-realm/non-pkvm) VM. With v7.4-rc1
it is rejected. However without this patch it succeeds.
The issue is that gmem_in_place_conversion changes the behaviour for
normal VMs.
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 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 ?
2) If it should be, then shouldn't it be done in kvm_gmem_create() ?
Suzuki
Thanks,
Steve