Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vfio: Prevent from pinned DMABUF importers to attach to VFIO DMABUF

Some pinned importers, such as non-ODP RDMA ones, cannot invalidate their
mappings and therefore must be prevented from attaching to this exporter.

Fixes: 5d74781ebc86 ("vfio/pci: Add dma-buf export support for MMIO regions")
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20260121-vfio-add-pin-v1-1-4e04916b17f1@nvidia.com
Signed-off-by: Alex Williamson <alex@shazbot.org>

authored by

Leon Romanovsky and committed by
Alex Williamson
61ceaf23 24d479d2

+12
+12
drivers/vfio/pci/vfio_pci_dmabuf.c
··· 20 20 u8 revoked : 1; 21 21 }; 22 22 23 + static int vfio_pci_dma_buf_pin(struct dma_buf_attachment *attachment) 24 + { 25 + return -EOPNOTSUPP; 26 + } 27 + 28 + static void vfio_pci_dma_buf_unpin(struct dma_buf_attachment *attachment) 29 + { 30 + /* Do nothing */ 31 + } 32 + 23 33 static int vfio_pci_dma_buf_attach(struct dma_buf *dmabuf, 24 34 struct dma_buf_attachment *attachment) 25 35 { ··· 86 76 } 87 77 88 78 static const struct dma_buf_ops vfio_pci_dmabuf_ops = { 79 + .pin = vfio_pci_dma_buf_pin, 80 + .unpin = vfio_pci_dma_buf_unpin, 89 81 .attach = vfio_pci_dma_buf_attach, 90 82 .map_dma_buf = vfio_pci_dma_buf_map, 91 83 .unmap_dma_buf = vfio_pci_dma_buf_unmap,