Skip to content

Commit 61ceaf2

Browse files
rleonawilliam
authored andcommitted
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: 5d74781 ("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>
1 parent 24d479d commit 61ceaf2

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

drivers/vfio/pci/vfio_pci_dmabuf.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ struct vfio_pci_dma_buf {
2020
u8 revoked : 1;
2121
};
2222

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+
2333
static int vfio_pci_dma_buf_attach(struct dma_buf *dmabuf,
2434
struct dma_buf_attachment *attachment)
2535
{
@@ -76,6 +86,8 @@ static void vfio_pci_dma_buf_release(struct dma_buf *dmabuf)
7686
}
7787

7888
static const struct dma_buf_ops vfio_pci_dmabuf_ops = {
89+
.pin = vfio_pci_dma_buf_pin,
90+
.unpin = vfio_pci_dma_buf_unpin,
7991
.attach = vfio_pci_dma_buf_attach,
8092
.map_dma_buf = vfio_pci_dma_buf_map,
8193
.unmap_dma_buf = vfio_pci_dma_buf_unmap,

0 commit comments

Comments
 (0)