This series allows QEMU to consume guest-memfd in-place, to be a common
memory backend. Before this series, guest-memfd was only used in CoCo and
the fds will be created implicitly whenever CoCo environment is detected.
In the current patchset, I reused the memory-backend-memfd object, rather
than creating a new type of object. After all, guest-memfd (at least from
userspace POV) really works very similarly like a memfd, except that it was
tailored for VM's use case.
So instead of using a normal memfd backend using:
-object memory-backend-memfd,id=ID,size=SIZE,share=on
One can also boot a VM with guest-memfd:
-object memory-backend-memfd,id=ID,size=SIZE,share=on,guest-memfd=on
The in-place guest-memfd here relies on almost the latest linux, as the
mmap() support just landed v6.18-rc2. When run it on an older qemu, we'll
see errors like:
qemu-system-x86_64: KVM does not support guest_memfd
One thing to mention is live migration is by default supported, however
postcopy is still currently not supported. The postcopy support will have
some kernel dependency work that was still being reviewed on mm list, so it
will be a separate work TBD.
Thanks,
Peter Xu (8):
linux-headers: Update to v6.18-rc2
kvm: Allow kvm_guest_memfd_supported for non-private use case
kvm: Detect guest-memfd flags supported
memory: Rename RAM_GUEST_MEMFD to RAM_GUEST_MEMFD_PRIVATE
memory: Rename memory_region_has_guest_memfd() to *_private()
ramblock: Rename guest_memfd to guest_memfd_private
hostmem: Rename guest_memfd to guest_memfd_private
hostmem: Support in-place guest memfd to back a VM
qapi/qom.json | 6 +-
include/standard-headers/linux/ethtool.h | 1 +
include/standard-headers/linux/fuse.h | 22 +++++-
.../linux/input-event-codes.h | 1 +
include/standard-headers/linux/input.h | 22 +++++-
include/standard-headers/linux/pci_regs.h | 10 +++
include/standard-headers/linux/virtio_ids.h | 1 +
include/system/hostmem.h | 2 +-
include/system/memory.h | 16 ++---
include/system/ram_addr.h | 2 +-
include/system/ramblock.h | 7 +-
linux-headers/asm-loongarch/kvm.h | 1 +
linux-headers/asm-riscv/kvm.h | 23 ++++++-
linux-headers/asm-riscv/ptrace.h | 4 +-
linux-headers/asm-x86/kvm.h | 34 ++++++++++
linux-headers/asm-x86/unistd_64.h | 1 +
linux-headers/asm-x86/unistd_x32.h | 1 +
linux-headers/linux/kvm.h | 3 +
linux-headers/linux/psp-sev.h | 10 ++-
linux-headers/linux/stddef.h | 1 -
linux-headers/linux/vduse.h | 2 +-
linux-headers/linux/vhost.h | 4 +-
accel/kvm/kvm-all.c | 26 ++++---
backends/hostmem-file.c | 2 +-
backends/hostmem-memfd.c | 68 +++++++++++++++++--
backends/hostmem-ram.c | 2 +-
backends/hostmem.c | 2 +-
system/memory.c | 6 +-
system/physmem.c | 29 ++++----
29 files changed, 253 insertions(+), 56 deletions(-)
--
2.50.1