vfio-user: support multiple FDs backing region mmaps
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v6 Latest4 patches 1 replyIn review
- v54 patches 11 repliesSuperseded
- v44 patches 8 repliesSuperseded
Earlier versions · 4
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v3 posting 2/2 | 4 patches | 6 replies | Superseded | |
| v3 posting 1/2 | 4 patches | 0 replies | Superseded | |
| v2 | 3 patches | 4 replies | Superseded | |
| v1 RFC | 3 patches | 3 replies | Superseded |
Changes in v6 from the cover letter
- Renamed vfio_default_setup_sparse_mmaps() to
vfio_region_setup_sparse_mmaps(). (Cedric)
- Verified msgp->index == info->index in vfio_user_get_region_info()
before copying the reply into info. (Cedric)
- Documented the 0x8000 capability ID namespace in relation to kernel
VFIO in hw/vfio-user/protocol.h. (John)
- Link to v5: https://lore.kernel.org/qemu-devel/[email protected]
Patches in v6 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | vfio-user: add multi-fd region mmap capabilitydocs/ | +82 | 0 replies | |
| 2/4 | vfio: add 'fd' and 'fd_offset' to VFIOMmaphw/ hw/ hw/ | +24 | 0 replies | |
| 3/4 | vfio: add setup_sparse_mmaps hook to VFIODeviceIOOpshw/ hw/ hw/ +1 more | +38 | 0 replies | |
| 4/4 | vfio-user: support multiple FDs for sparse mmap regionshw/ hw/ hw/ +1 more | +202 | 0 replies |
Reviews trailers per patch
All 4 patches have a Reviewed-by or Acked-by.
| Patch | Thanos Makatos | John Levon | Cédric Le Goater |
|---|---|---|---|
| 1/4 | R-b | R-b | |
| 2/4 | R-b | R-b | R-b |
| 3/4 | R-b | R-b | R-b |
| 4/4 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.
Cover letter [PATCH v6 0/4] vfio-user: support multiple FDs backing region mmaps
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/[email protected]
[2] https://github.com/NamanGulati/libvfio-user/tree/multi-region-fd
---
Changes from v5:
- Renamed vfio_default_setup_sparse_mmaps() to
vfio_region_setup_sparse_mmaps(). (Cedric)
- Verified msgp->index == info->index in vfio_user_get_region_info()
before copying the reply into info. (Cedric)
- Documented the 0x8000 capability ID namespace in relation to kernel
VFIO in hw/vfio-user/protocol.h. (John)
- Link to v5: https://lore.kernel.org/qemu-devel/[email protected]
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/[email protected]
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/[email protected]
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/[email protected]
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/[email protected]
---
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 | 39 +++++++++-- hw/vfio-user/proxy.h | 2 + hw/vfio/vfio-region.h | 9 ++- include/hw/vfio/vfio-device.h | 16 +++++ hw/vfio-user/device.c | 126 ++++++++++++++++++++++++++++++++-- hw/vfio-user/proxy.c | 52 ++++++++++++-- hw/vfio/device.c | 1 + hw/vfio/pci.c | 2 + hw/vfio/region.c | 45 +++++++++--- 10 files changed, 346 insertions(+), 32 deletions(-)
Signature · 1 line
2.56.0.307.g5fe7bd680c-goog