]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
vfio: Permit VFIO to work with pinned importers
authorLeon Romanovsky <leonro@nvidia.com>
Sat, 31 Jan 2026 05:34:17 +0000 (07:34 +0200)
committerChristian König <christian.koenig@amd.com>
Mon, 23 Feb 2026 18:51:41 +0000 (19:51 +0100)
Till now VFIO has rejected pinned importers, largely to avoid being used
with the RDMA pinned importer that cannot handle a move_notify() to revoke
access.

Using dma_buf_attach_revocable() it can tell the difference between pinned
importers that support the flow described in dma_buf_invalidate_mappings()
and those that don't.

Thus permit compatible pinned importers.

This is one of two items IOMMUFD requires to remove its private interface
to VFIO's dma-buf.

Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Alex Williamson <alex@shazbot.org>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Link: https://lore.kernel.org/r/20260131-dmabuf-revoke-v7-7-463d956bd527@nvidia.com
drivers/vfio/pci/vfio_pci_dmabuf.c

index d7712d68ff2b6f5aa0464f45e67e045c3d2b79f7..3a803923141be32e878c3ec18fc69f34a07d4e5f 100644 (file)
@@ -22,16 +22,6 @@ struct vfio_pci_dma_buf {
        u8 revoked : 1;
 };
 
-static int vfio_pci_dma_buf_pin(struct dma_buf_attachment *attachment)
-{
-       return -EOPNOTSUPP;
-}
-
-static void vfio_pci_dma_buf_unpin(struct dma_buf_attachment *attachment)
-{
-       /* Do nothing */
-}
-
 static int vfio_pci_dma_buf_attach(struct dma_buf *dmabuf,
                                   struct dma_buf_attachment *attachment)
 {
@@ -43,6 +33,9 @@ static int vfio_pci_dma_buf_attach(struct dma_buf *dmabuf,
        if (priv->revoked)
                return -ENODEV;
 
+       if (!dma_buf_attach_revocable(attachment))
+               return -EOPNOTSUPP;
+
        return 0;
 }
 
@@ -107,8 +100,6 @@ static void vfio_pci_dma_buf_release(struct dma_buf *dmabuf)
 }
 
 static const struct dma_buf_ops vfio_pci_dmabuf_ops = {
-       .pin = vfio_pci_dma_buf_pin,
-       .unpin = vfio_pci_dma_buf_unpin,
        .attach = vfio_pci_dma_buf_attach,
        .map_dma_buf = vfio_pci_dma_buf_map,
        .unmap_dma_buf = vfio_pci_dma_buf_unmap,