Re: [PATCH v5 01/11] KVM: arm64: guest_memfd: Drop mmap requirement for memslots
From: Steven Price
Date: Mon Nov 30 2026 - 10:41:35 EST
On 30/11/2026 14:25, Steven Price wrote:
> Arm64 rejects guest_memfd-backed memslots unless generic KVM marks
> them KVM_MEMSLOT_GMEM_ONLY. Without in-place conversion, that flag is
> set for mmap-capable guest_memfd files, reflecting the original arm64
> requirement for userspace-mappable backing.
>
> Realm VMs also need to bind private-only guest_memfd files, which do
> not support mmap. Their fault path obtains PFNs directly from
> guest_memfd through kvm_gmem_get_pfn(), without a userspace mapping.
> Remove the memslot restriction so these files can be used by Realms.
> Userspace remains responsible for supplying backing for shared IPAs.
>
> Suggested-by: Ackerley Tng <ackerleytng@xxxxxxxxxx>
> Fixes: 32e200bd6e44 ("KVM: arm64: Enable support for guest_memfd backed memory")
> Signed-off-by: Steven Price <steven.price@xxxxxxx>
Suzuki and I just had a chat, and I think I might have got the wrong end
of the stick with this patch. I think actually this patch can be dropped
altogether. It's not needed for CCA, and I'm now not convinced it's the
right change. But if other's disagree then please chime in!
Thanks,
Steve
>
> ---
> Changes since v4:
> - Remove the arm64 memslot check that requires mmap-capable guest_memfd;
> Realms can use private-only guest_memfd backing.
> ---
> arch/arm64/kvm/mmu.c | 7 -------
> 1 file changed, 7 deletions(-)
>
> diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
> index 1db10d8d6db7..40e6159f4aed 100644
> --- a/arch/arm64/kvm/mmu.c
> +++ b/arch/arm64/kvm/mmu.c
> @@ -2838,13 +2838,6 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
> if ((new->base_gfn + new->npages) > (kvm_phys_size(&kvm->arch.mmu) >> PAGE_SHIFT))
> return -EFAULT;
>
> - /*
> - * Only support guest_memfd backed memslots with mappable memory, since
> - * there aren't any CoCo VMs that support only private memory on arm64.
> - */
> - if (kvm_slot_has_gmem(new) && !kvm_memslot_is_gmem_only(new))
> - return -EINVAL;
> -
> /* guest_memfd is incompatible with MTE. */
> if (kvm_slot_has_gmem(new) && kvm_has_mte(kvm))
> return -EINVAL;