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 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.
  - 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    | 71 +++++++++++++++++++++++++--
 hw/vfio-user/protocol.h       | 22 +++++++++
 hw/vfio-user/proxy.h          |  2 +
 hw/vfio/vfio-region.h         |  9 +++-
 include/hw/vfio/vfio-device.h | 16 +++++++
 hw/vfio-user/device.c         | 90 ++++++++++++++++++++++++++++++++---
 hw/vfio-user/proxy.c          | 32 +++++++++++--
 hw/vfio/pci.c                 |  2 +
 hw/vfio/region.c              | 51 ++++++++++++++++----
 9 files changed, 269 insertions(+), 26 deletions(-)

-- 
2.55.0.1082.g2b9226bbc0-goog


Reply via email to