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 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 (3): vfio-user: add multi-fd region mmap capability vfio: mmap sparse regions backed by multiple FDs vfio-user: implement client support for multi-fd region mmap docs/interop/vfio-user.rst | 71 +++++++++++++++++++++++++++++++++-- hw/vfio-user/device.c | 66 ++++++++++++++++++++++++++++++-- hw/vfio-user/protocol.h | 20 ++++++++++ hw/vfio/device.c | 49 ++++++++++++++---------- hw/vfio/region.c | 41 ++++++++++++++++---- hw/vfio/vfio-region.h | 8 ++++ include/hw/vfio/vfio-device.h | 32 ++++++++++++++-- 7 files changed, 249 insertions(+), 38 deletions(-) -- 2.55.0.860.g4b6b3295ed-goog
