On Wed, Jun 10, 2026 at 04:43:17PM +0100, Matt Evans wrote:
This helper, vfio_pci_core_mmap_prep_dmabuf(), creates a single-range DMABUF for the purpose of mapping a PCI BAR. This is used in a future commit by VFIO's ordinary mmap() path.
This function transfers ownership of the VFIO device fd to the DMABUF, which fput()s when it's released.
Refactor the existing vfio_pci_core_feature_dma_buf() to split out export code common to the two paths, VFIO_DEVICE_FEATURE_DMA_BUF and this new VFIO_BAR mmap().
Signed-off-by: Matt Evans matt@ozlabs.org
drivers/vfio/pci/vfio_pci_dmabuf.c | 142 +++++++++++++++++++++++------ drivers/vfio/pci/vfio_pci_priv.h | 5 + 2 files changed, 117 insertions(+), 30 deletions(-)
[...]
- /*
* Ownership of the DMABUF file transfers to the VMA so that* other users can locate the DMABUF via a VA. Ownership of* the original VFIO device file being mmap()ed transfers to* priv, and is put when the DMABUF is released. This* intentionally does not use get_file()/vma_set_file()* because the references are already held, and ownership* moves.*/- priv->vfile = vma->vm_file;
- vma->vm_file = priv->dmabuf->file;
- vma->vm_private_data = priv;
I appreciate this comment. Thanks for being clear!
Reviewed-by: Pranjal Shrivastava praan@google.com
Thanks, Praan
linaro-mm-sig@lists.linaro.org