From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: peterx@redhat.com, Paolo Bonzini <pbonzini@redhat.com>,
Fabiano Rosas <farosas@suse.de>,
Chenyi Qiang <chenyi.qiang@intel.com>,
David Hildenbrand <david@redhat.com>,
Alexey Kardashevskiy <aik@amd.com>,
Li Xiaoyao <xiaoyao.li@intel.com>,
Juraj Marcin <jmarcin@redhat.com>
Subject: [PATCH 0/8] KVM/hostmem: Support in-place guest-memfd as VM backends
Date: Thu, 23 Oct 2025 14:59:05 -0400 [thread overview]
Message-ID: <20251023185913.2923322-1-peterx@redhat.com> (raw)
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
next reply other threads:[~2025-10-23 19:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-23 18:59 Peter Xu [this message]
2025-10-23 18:59 ` [PATCH 1/8] linux-headers: Update to v6.18-rc2 Peter Xu
2025-10-23 18:59 ` [PATCH 2/8] kvm: Allow kvm_guest_memfd_supported for non-private use case Peter Xu
2025-10-24 2:30 ` Xiaoyao Li
2025-10-23 18:59 ` [PATCH 3/8] kvm: Detect guest-memfd flags supported Peter Xu
2025-10-24 3:52 ` Xiaoyao Li
2025-10-23 18:59 ` [PATCH 4/8] memory: Rename RAM_GUEST_MEMFD to RAM_GUEST_MEMFD_PRIVATE Peter Xu
2025-10-24 9:17 ` Xiaoyao Li
2025-10-23 18:59 ` [PATCH 5/8] memory: Rename memory_region_has_guest_memfd() to *_private() Peter Xu
2025-10-23 18:59 ` [PATCH 6/8] ramblock: Rename guest_memfd to guest_memfd_private Peter Xu
2025-10-23 18:59 ` [PATCH 7/8] hostmem: " Peter Xu
2025-10-23 18:59 ` [PATCH 8/8] hostmem: Support in-place guest memfd to back a VM Peter Xu
2025-10-24 9:01 ` Xiaoyao Li
2025-10-24 15:22 ` Peter Xu
2025-10-27 5:24 ` Xiaoyao Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251023185913.2923322-1-peterx@redhat.com \
--to=peterx@redhat.com \
--cc=aik@amd.com \
--cc=chenyi.qiang@intel.com \
--cc=david@redhat.com \
--cc=farosas@suse.de \
--cc=jmarcin@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=xiaoyao.li@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).