public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH vfio-rc] vfio: Prevent from pinned DMABUF importers to attach to VFIO DMABUF
@ 2026-01-21 15:45 Leon Romanovsky
  2026-01-21 16:03 ` Jason Gunthorpe
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Leon Romanovsky @ 2026-01-21 15:45 UTC (permalink / raw)
  To: Alex Williamson, Ankit Agrawal, Jason Gunthorpe, Kevin Tian,
	Vivek Kasireddy
  Cc: kvm, linux-kernel

From: Leon Romanovsky <leonro@nvidia.com>

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>
---
This is an outcome of this discussion about revoke functionality.
https://lore.kernel.org/all/20260121134712.GZ961572@ziepe.ca

Thanks
---
 drivers/vfio/pci/vfio_pci_dmabuf.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/vfio/pci/vfio_pci_dmabuf.c b/drivers/vfio/pci/vfio_pci_dmabuf.c
index d4d0f7d08c53..4be4a85005cb 100644
--- a/drivers/vfio/pci/vfio_pci_dmabuf.c
+++ b/drivers/vfio/pci/vfio_pci_dmabuf.c
@@ -20,6 +20,16 @@ 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)
 {
@@ -76,6 +86,8 @@ 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,

---
base-commit: acf44a2361b8d6356b71a970ab016065b5123b0e
change-id: 20260121-vfio-add-pin-2229148da56e

Best regards,
--  
Leon Romanovsky <leonro@nvidia.com>


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH vfio-rc] vfio: Prevent from pinned DMABUF importers to attach to VFIO DMABUF
  2026-01-21 15:45 [PATCH vfio-rc] vfio: Prevent from pinned DMABUF importers to attach to VFIO DMABUF Leon Romanovsky
@ 2026-01-21 16:03 ` Jason Gunthorpe
  2026-01-22  6:14 ` Pranjal Shrivastava
  2026-01-23 17:34 ` Alex Williamson
  2 siblings, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2026-01-21 16:03 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Alex Williamson, Ankit Agrawal, Kevin Tian, Vivek Kasireddy, kvm,
	linux-kernel

On Wed, Jan 21, 2026 at 05:45:02PM +0200, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@nvidia.com>
> 
> 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>
> ---
> This is an outcome of this discussion about revoke functionality.
> https://lore.kernel.org/all/20260121134712.GZ961572@ziepe.ca
> 
> Thanks
> ---
>  drivers/vfio/pci/vfio_pci_dmabuf.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>

Alex this is quite important to pick up this cycle.

Thanks,
Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH vfio-rc] vfio: Prevent from pinned DMABUF importers to attach to VFIO DMABUF
  2026-01-21 15:45 [PATCH vfio-rc] vfio: Prevent from pinned DMABUF importers to attach to VFIO DMABUF Leon Romanovsky
  2026-01-21 16:03 ` Jason Gunthorpe
@ 2026-01-22  6:14 ` Pranjal Shrivastava
  2026-01-23 17:34 ` Alex Williamson
  2 siblings, 0 replies; 4+ messages in thread
From: Pranjal Shrivastava @ 2026-01-22  6:14 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Alex Williamson, Ankit Agrawal, Jason Gunthorpe, Kevin Tian,
	Vivek Kasireddy, kvm, linux-kernel

On Wed, Jan 21, 2026 at 05:45:02PM +0200, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@nvidia.com>
> 
> 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>
> ---
> This is an outcome of this discussion about revoke functionality.
> https://lore.kernel.org/all/20260121134712.GZ961572@ziepe.ca
> 
> Thanks
> ---
>  drivers/vfio/pci/vfio_pci_dmabuf.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 

Reviewed-by: Pranjal Shrivastava <praan@google.com>

Thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH vfio-rc] vfio: Prevent from pinned DMABUF importers to attach to VFIO DMABUF
  2026-01-21 15:45 [PATCH vfio-rc] vfio: Prevent from pinned DMABUF importers to attach to VFIO DMABUF Leon Romanovsky
  2026-01-21 16:03 ` Jason Gunthorpe
  2026-01-22  6:14 ` Pranjal Shrivastava
@ 2026-01-23 17:34 ` Alex Williamson
  2 siblings, 0 replies; 4+ messages in thread
From: Alex Williamson @ 2026-01-23 17:34 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Ankit Agrawal, Jason Gunthorpe, Kevin Tian, Vivek Kasireddy, kvm,
	linux-kernel

On Wed, 21 Jan 2026 17:45:02 +0200
Leon Romanovsky <leon@kernel.org> wrote:

> From: Leon Romanovsky <leonro@nvidia.com>
> 
> 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>
> ---
> This is an outcome of this discussion about revoke functionality.
> https://lore.kernel.org/all/20260121134712.GZ961572@ziepe.ca
> 
> Thanks
> ---
>  drivers/vfio/pci/vfio_pci_dmabuf.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)

Applied to vfio for-linus branch for v6.19.  Thanks,

Alex


> 
> diff --git a/drivers/vfio/pci/vfio_pci_dmabuf.c b/drivers/vfio/pci/vfio_pci_dmabuf.c
> index d4d0f7d08c53..4be4a85005cb 100644
> --- a/drivers/vfio/pci/vfio_pci_dmabuf.c
> +++ b/drivers/vfio/pci/vfio_pci_dmabuf.c
> @@ -20,6 +20,16 @@ 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)
>  {
> @@ -76,6 +86,8 @@ 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,
> 
> ---
> base-commit: acf44a2361b8d6356b71a970ab016065b5123b0e
> change-id: 20260121-vfio-add-pin-2229148da56e
> 
> Best regards,
> --  
> Leon Romanovsky <leonro@nvidia.com>
> 
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-01-23 17:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-21 15:45 [PATCH vfio-rc] vfio: Prevent from pinned DMABUF importers to attach to VFIO DMABUF Leon Romanovsky
2026-01-21 16:03 ` Jason Gunthorpe
2026-01-22  6:14 ` Pranjal Shrivastava
2026-01-23 17:34 ` Alex Williamson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox