From: Naman Gulati <namangulati@google.com>
To: qemu-devel@nongnu.org
Cc: "John Levon" <john.levon@nutanix.com>,
"Thanos Makatos" <thanos.makatos@nutanix.com>,
"Cédric Le Goater" <clg@redhat.com>,
"Alex Williamson" <alex@shazbot.org>,
"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
"Matt Evans" <matt@ozlabs.org>,
"Naman Gulati" <namangulati@google.com>
Subject: [PATCH v5 0/4] vfio-user: support multiple FDs backing region mmaps
Date: Wed, 14 Oct 2026 21:10:37 +0000 [thread overview]
Message-ID: <20261014211041.1087331-1-namangulati@google.com> (raw)
This series extends the vfio-user protocol specification to allow
servers to pass multiple file descriptors for different sparse memory
areas to be mmap'ed within a single device region.
This extension is intended for exposing paravirtualized PCI devices via
a vfio-user server that may have multiple unique sub-regions in a BAR
backed by some mmap'able buffers sourced from distinct file descriptors.
This change introduces a new capability:
VFIO_REGION_INFO_CAP_SPARSE_MMAP_FDS
Unlike VFIO_REGION_INFO_CAP_SPARSE_MMAP (which maps all sparse areas
from a single open file descriptor), this new capability defines an
array of sparse mmap areas where each area contains an index into the
array of file descriptors.
When all sparse areas share a single file descriptor, servers may
continue to emit VFIO_REGION_INFO_CAP_SPARSE_MMAP and send exactly one
file descriptor in SCM_RIGHTS for backwards compatibility with older
clients.
The extensions in this series also lays the groundwork to make use of
the in-development series [1] extending vfio-pci to return distinct
dmabuf FDs for discrete regions of a device's BAR. A vfio-user server
may choose to return dmabuf FDs for various regions of a device's BAR to
map a vfio passthrough device into the guest, in order to retain control
of the device and be able to revoke mappings passed to the VM.
libvfio-user server side changes WIP on github [2].
[1] https://lore.kernel.org/all/20260715174737.15287-1-matt@ozlabs.org
[2] https://github.com/NamanGulati/libvfio-user/tree/multi-region-fd
---
Changes from v4:
- Set .setup_sparse_mmaps = vfio_default_setup_sparse_mmaps in
vfio_device_io_ops_ioctl. (Cedric)
- Return -EINVAL in vfio_user_device_io_get_region_info() when
VFIO_REGION_INFO_CAP_SPARSE_MMAP_FDS is present without received
FDs. (Cedric)
- Dropped redundant VFIO_USER_MAX_REGIONS bounds checks in
vfio_user_device_io_get_region_info() and
vfio_user_device_io_setup_sparse_mmaps(). (Thanos)
- Validated sparse_fds->nr_areas against info->argsz and switched to
g_try_new0() for region->mmaps. (Thanos)
- Included area info in invalid area error message and added comments
for recv_fds resets in hw/vfio-user/proxy.c. (Thanos)
- Link to v4: https://lore.kernel.org/qemu-devel/20261009175314.1823347-1-namangulati@google.com
Changes from v3:
- Added "sparse_mmap_fds" capability to VFIO_USER_VERSION so servers
know whether the client supports
VFIO_REGION_INFO_CAP_SPARSE_MMAP_FDS. (Thanos)
- Changed VFIO_REGION_INFO_CAP_SPARSE_MMAP_FDS capability ID to 0x8001. (Thanos)
- Clarified and enforced that VFIO_REGION_INFO_CAP_SPARSE_MMAP and
VFIO_REGION_INFO_CAP_SPARSE_MMAP_FDS are mutually exclusive per region,
number of FDs in SCM_RIGHTS must not exceed nr_areas, zero-sized areas
are not permitted, offset + size must not exceed the region size, and
areas must not overlap. (Thanos)
- Link to v3: https://lore.kernel.org/qemu-devel/20261007000833.2445641-1-namangulati@google.com
Changes from v2:
- As suggested by Cedric: kept core VFIO changes minimal by only
extending VFIOMMmap to hold each mmap subregion's fd & fd_offset.
- Moved multi-FD management and capability parsing into hw/vfio-user,
and using VFIOUserProxy to hold region multi-fds.
- Resend: rebased to head.
- Link to v2: https://lore.kernel.org/qemu-devel/20260826050039.2068138-1-namangulati@google.com
Changes from RFC:
- Refactored the get_region_info callback to keep vbasedev constant
and take in a VFIORegionFDs* out parameter to store the received fds.
- Link to RFC: https://lore.kernel.org/qemu-devel/20260811233930.401797-1-namangulati@google.com
---
Naman Gulati (4):
vfio-user: add multi-fd region mmap capability
vfio: add 'fd' and 'fd_offset' to VFIOMmap
vfio: add setup_sparse_mmaps hook to VFIODeviceIOOps
vfio-user: support multiple FDs for sparse mmap regions
docs/interop/vfio-user.rst | 86 ++++++++++++++++++++++--
hw/vfio-user/protocol.h | 35 ++++++++--
hw/vfio-user/proxy.h | 2 +
hw/vfio/vfio-region.h | 9 ++-
include/hw/vfio/vfio-device.h | 16 +++++
hw/vfio-user/device.c | 121 ++++++++++++++++++++++++++++++++--
hw/vfio-user/proxy.c | 52 +++++++++++++--
hw/vfio/device.c | 1 +
hw/vfio/pci.c | 2 +
hw/vfio/region.c | 45 ++++++++++---
10 files changed, 337 insertions(+), 32 deletions(-)
--
2.56.0.385.gd3acb90ef8-goog
next reply other threads:[~2026-10-14 21:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 21:10 Naman Gulati [this message]
2026-10-14 21:10 ` [PATCH v5 1/4] vfio-user: add multi-fd region mmap capability Naman Gulati
2026-10-20 15:37 ` John Levon
2026-10-14 21:10 ` [PATCH v5 2/4] vfio: add 'fd' and 'fd_offset' to VFIOMmap Naman Gulati
2026-10-15 7:39 ` Cédric Le Goater
2026-10-20 15:37 ` John Levon
2026-10-14 21:10 ` [PATCH v5 3/4] vfio: add setup_sparse_mmaps hook to VFIODeviceIOOps Naman Gulati
2026-10-15 7:39 ` Cédric Le Goater
2026-10-15 7:41 ` Cédric Le Goater
2026-10-20 15:38 ` John Levon
2026-10-14 21:10 ` [PATCH v5 4/4] vfio-user: support multiple FDs for sparse mmap regions Naman Gulati
2026-10-15 7:45 ` Cédric Le Goater
2026-10-20 15:35 ` John Levon
2026-10-20 21:27 ` Thanos Makatos
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=20261014211041.1087331-1-namangulati@google.com \
--to=namangulati@google.com \
--cc=alex@shazbot.org \
--cc=clg@redhat.com \
--cc=john.levon@nutanix.com \
--cc=matt@ozlabs.org \
--cc=pierrick.bouvier@oss.qualcomm.com \
--cc=qemu-devel@nongnu.org \
--cc=thanos.makatos@nutanix.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.