Skip to content

Commit 32e200b

Browse files
Fuad Tabbabonzini
authored andcommitted
KVM: arm64: Enable support for guest_memfd backed memory
Now that the infrastructure is in place, enable guest_memfd for arm64. * Select CONFIG_KVM_GUEST_MEMFD in KVM/arm64 Kconfig. * Enforce KVM_MEMSLOT_GMEM_ONLY for guest_memfd on arm64: Ensure that guest_memfd-backed memory slots on arm64 are only supported if they are intended for shared memory use cases (i.e., kvm_memslot_is_gmem_only() is true). This design reflects the current arm64 KVM ecosystem where guest_memfd is primarily being introduced for VMs that support shared memory. Reviewed-by: James Houghton <[email protected]> Reviewed-by: Gavin Shan <[email protected]> Reviewed-by: Marc Zyngier <[email protected]> Acked-by: David Hildenbrand <[email protected]> Signed-off-by: Fuad Tabba <[email protected]> Signed-off-by: Sean Christopherson <[email protected]> Message-ID: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent f4e7403 commit 32e200b

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

arch/arm64/kvm/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ menuconfig KVM
3737
select HAVE_KVM_VCPU_RUN_PID_CHANGE
3838
select SCHED_INFO
3939
select GUEST_PERF_EVENTS if PERF_EVENTS
40+
select KVM_GUEST_MEMFD
4041
help
4142
Support hosting virtualized guest machines.
4243

arch/arm64/kvm/mmu.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2302,6 +2302,13 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
23022302
if ((new->base_gfn + new->npages) > (kvm_phys_size(&kvm->arch.mmu) >> PAGE_SHIFT))
23032303
return -EFAULT;
23042304

2305+
/*
2306+
* Only support guest_memfd backed memslots with mappable memory, since
2307+
* there aren't any CoCo VMs that support only private memory on arm64.
2308+
*/
2309+
if (kvm_slot_has_gmem(new) && !kvm_memslot_is_gmem_only(new))
2310+
return -EINVAL;
2311+
23052312
hva = new->userspace_addr;
23062313
reg_end = hva + (new->npages << PAGE_SHIFT);
23072314

0 commit comments

Comments
 (0)