Skip to content

Add guest_memfd support for arm64

Fuad Tabba kvm kvmarm 3 versions – Applied

Status from this message: Applied to kvmtool (master), thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest4 patches 3 repliesApplied
  2. v24 patches 4 repliesSuperseded
  3. v15 patches 16 repliesSuperseded

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/4Initialize the return value in kvm__for_each_mem_bank()kvm.c+3 -20 replies
2/4Remove newline from end of die() abortsutil/util.c+5 -50 replies
3/4Add support for registering guest_memfd-backed memory regionshw/cfi_flash.c include/kvm/kvm.h kvm.c+41 -130 replies
4/4arm64: Add --guest-memfd option to back guest RAM with guest_memfdarm64/include/kvm/kvm-config-arch.h arm64/kvm.c include/kvm/kvm.h +3 more+82 -70 replies

Reviews trailers per patch

2 of 4 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchSuzuki K PouloseAlexandru Elisei
SeriesR-b R-b T-b
1/4
2/4R-b
3/4R-b
4/4

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH kvmtool v3 0/4] Add guest_memfd support for arm64

Hi folks,

Changes since v2 [1]:
- Assert guest_memfd >= 0 in kvm__register_ram_guest_memfd() (Alexandru)
- Don't split line after = sign (Alexandru)
- Disable MTE when --guest-memfd is used (Alexandru)
- Carried Reviewed-bys

Changes since v1 [2]:
- Use kvm_userspace_memory_region2 only for guest_memfd slots (Suzuki)
- Check KVM_CAP_GUEST_MEMFD before KVM_CAP_GUEST_MEMFD_FLAGS (Alexandru)
- Close guest_memfd fd after unmapping at teardown (Alexandru)
- Carried Reviewed-bys

Due to popular demand, i.e., Alexandru asking me about it, I repolished my guest_memfd support series. The one I sent years ago was stale and over-engineered, so this is a fresh start instead.

This series adds support for backing guest RAM with guest_memfd on arm64, for non-protected VMs under both regular KVM and pKVM.

The first two patches are standalone fixes in the code this series builds on: an uninitialized return value in kvm__for_each_mem_bank(), and doubled newlines in die() messages. Patch 3 adds guest_memfd plumbing to kvm__register_mem(), using kvm_userspace_memory_region2 only for guest_memfd-backed slots.

A new --guest-memfd option creates guest RAM from a guest_memfd with mmap support (GUEST_MEMFD_FLAG_MMAP and GUEST_MEMFD_FLAG_INIT_SHARED, Linux 6.18+), maps it to provide the userspace mapping, and registers it with KVM_SET_USER_MEMORY_REGION2.

Protected VMs need in-place shared/private conversion of guest_memfd, which is still in progress in the kernel [3], so --protected rejects the option.

Based on kvmtool master (ca0ddafa941d).

Cheers,
/fuad

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/[email protected]/

Fuad Tabba (4):
Initialize the return value in kvm__for_each_mem_bank() Remove newline from end of die() aborts
Add support for registering guest_memfd-backed memory regions
arm64: Add --guest-memfd option to back guest RAM with guest_memfd

 arm64/include/kvm/kvm-config-arch.h |  5 ++-
 arm64/kvm.c                         | 44 +++++++++++++++++++++++----
 hw/cfi_flash.c                      |  2 +-
 include/kvm/kvm.h                   | 17 +++++++++--
 include/kvm/util.h                  |  1 +
 kvm.c                               | 42 ++++++++++++++++++--------
 util/util.c                         | 47 ++++++++++++++++++++++++++---
 7 files changed, 131 insertions(+), 27 deletions(-)
Signature · 1 line
2.39.5