Re: [PATCH v4 10/10] vfio/pci: Add dma-buf export support for MMIO regions

From: Jason Gunthorpe

Date: Tue Sep 30 2025 - 14:04:39 EST


On Tue, Sep 30, 2025 at 10:52:47AM -0600, Alex Williamson wrote:
> On Tue, 30 Sep 2025 11:34:08 -0300
> Jason Gunthorpe <jgg@xxxxxxxxxx> wrote:
>
> > On Tue, Sep 30, 2025 at 12:50:47PM +0000, Shameer Kolothum wrote:
> >
> > > This is where hisi_acc reports a different BAR size as it tries to hide
> > > the migration control region from Guest access.
> >
> > I think for now we should disable DMABUF for any PCI driver that
> > implements a VFIO_DEVICE_GET_REGION_INFO
> >
> > For a while I've wanted to further reduce the use of the ioctl
> > multiplexer, so maybe this series:
> >
> > https://github.com/jgunthorpe/linux/commits/vfio_get_region_info_op/
> >
> > And then the dmabuf code can check if the ops are set to the generic
> > or not and disable itself automatically.
> >
> > Otherwise perhaps route the dmabuf through an op and deliberately omit
> > it (with a comment!) from hisi, virtio, nvgrace.
> >
> > We need to route it through an op anyhow as those three drivers will
> > probably eventually want to implement their own version.
>
> Can't we basically achieve the same by testing the ioctl is
> vfio_pci_core_ioctl?

Could work to start! That's a good idea, then we don't have
dependencies.

> Your proposal would have better granularity, but

Yes, that was my thinking

> we'd probably want an ops callback that we can use without a userspace
> buffer to get the advertised region size if we ever want to support a
> device that both modifies the size of the region relative to the BAR
> and supports p2p.

Small steps..

I added some more commits that remove the userspace buffer and all the
duplicated code too.

Jason