[PATCH v3 RESEND 0/4] vfio-user: support multiple FDs backing region mmaps

Naman Gulati posted 4 patches 2 weeks, 4 days ago
There is a newer version of this series
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(-)
[PATCH v3 RESEND 0/4] vfio-user: support multiple FDs backing region mmaps
Posted by Naman Gulati 2 weeks, 4 days ago
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 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    | 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.56.0.rc1.315.gc6ed9934b7-goog
Re: [PATCH v3 RESEND 0/4] vfio-user: support multiple FDs backing region mmaps
Posted by Cédric Le Goater 2 weeks, 4 days ago
Naman,

On 10/7/26 02:08, Naman Gulati wrote:
> 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 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    | 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(-)
> 

There is no need to resend. We need some acks from the vfio-user team now.

Thanks,

C.