From: Alex Williamson <alex@shazbot.org>
To: Matt Evans <mattev@meta.com>
Cc: "Leon Romanovsky" <leon@kernel.org>,
"Jason Gunthorpe" <jgg@nvidia.com>,
"Alex Mastro" <amastro@fb.com>,
"Christian König" <christian.koenig@amd.com>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Logan Gunthorpe" <logang@deltatee.com>,
"Mahmoud Adam" <mngyadam@amazon.de>,
"David Matlack" <dmatlack@google.com>,
"Björn Töpel" <bjorn@kernel.org>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Kevin Tian" <kevin.tian@intel.com>,
"Ankit Agrawal" <ankita@nvidia.com>,
"Pranjal Shrivastava" <praan@google.com>,
"Alistair Popple" <apopple@nvidia.com>,
"Vivek Kasireddy" <vivek.kasireddy@intel.com>,
linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org,
kvm@vger.kernel.org, linux-pci@vger.kernel.org, alex@shazbot.org
Subject: Re: [PATCH v2 7/9] vfio/pci: Support mmap() of a VFIO DMABUF
Date: Tue, 2 Jun 2026 13:03:26 -0600 [thread overview]
Message-ID: <20260602130326.6b7a8d0c@shazbot.org> (raw)
In-Reply-To: <49c3554f-8ba7-4a00-aa20-a311b173fc0f@meta.com>
On Tue, 2 Jun 2026 18:35:25 +0100
Matt Evans <mattev@meta.com> wrote:
> On 29/05/2026 00:15, Alex Williamson wrote:
> > On Wed, 27 May 2026 03:23:10 -0700
> > Matt Evans <mattev@meta.com> wrote:
> >> diff --git a/drivers/vfio/pci/vfio_pci_dmabuf.c b/drivers/vfio/pci/vfio_pci_dmabuf.c
> >> index 733607371082..4b3b15655f1d 100644
> >> --- a/drivers/vfio/pci/vfio_pci_dmabuf.c
> >> +++ b/drivers/vfio/pci/vfio_pci_dmabuf.c
> >> @@ -27,6 +27,32 @@ static int vfio_pci_dma_buf_attach(struct dma_buf *dmabuf,
> >>
> >> return 0;
> >> }
> >> +
> >> +static int vfio_pci_dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma)
> >> +{
> >> + struct vfio_pci_dma_buf *priv = dmabuf->priv;
> >> +
> >> + if (priv->revoked)
> >> + return -ENODEV;
> >
> > Questionable validity to testing revoked without a lock, but doesn't
> > this also fail to follow the "map regardless, sort it out on fault"
> > paradigm used elsewhere in vfio-pci? Thanks,
>
> Kind of, though this was intentional. (I had removed a crappy comment
> here from the RFC, but should re-add something better...)
>
> You're right that, if we don't test this here, the fault handler ensures
> safety.
>
> In the revoke ioctl^Wfeature header UAPI comment I'd suggested a
> revocation prevents a new map (in addition to prevents access to an
> existing map) with the intention of making userspace easier to debug:
>
> - I'd rather trace an mmap() failure than a SIGBUS (eg. if another
> process has revoked my DMABUF and I didn't get the memo). For a
> prior revoke this is a reliable & useful test.
>
> - Even if there's an active race such as userspace doing an
> ioctl(RESET) at the same time as an mmap() (!) then obviously this
> check won't always catch it, but when it does then that's useful.
>
> I'd prefer to keep this belt-and-braces check to early-fail (with
> comment), if you don't mind much. It _is_ testing revoked outside of
> any synchronisation as anything we can lock against here doesn't have a
> useful effect AFAICT. (Taking the example of a concurrent ioctl(RESET),
> a revoke still manifests "before" (caught here) or "after" (caught in
> fault handler).) Maybe READ_ONCE() wouldn't hurt, if only to indicate this.
Hey Matt,
I think only the permanently revoked semantics are up for
interpretation here, mmap with memory disabled or across reset is
currently allowed and better debug'ability is not sufficient to risk
breaking compatibility. Thanks,
Alex
next prev parent reply other threads:[~2026-06-02 19:03 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-27 10:23 [PATCH v2 0/9] vfio/pci: Add mmap() for DMABUFs Matt Evans
2026-05-27 10:23 ` [PATCH v2 1/9] PCI/P2PDMA: Add CONFIG_PCI_P2PDMA_CORE Matt Evans
2026-05-27 16:07 ` Logan Gunthorpe
2026-05-27 17:13 ` Matt Evans
2026-05-27 21:09 ` Alex Williamson
2026-05-29 23:05 ` Jason Gunthorpe
2026-06-09 22:45 ` Bjorn Helgaas
2026-06-10 15:27 ` Pranjal Shrivastava
2026-06-10 16:00 ` Matt Evans
2026-06-12 8:28 ` Tian, Kevin
2026-05-27 10:23 ` [PATCH v2 2/9] vfio/pci: Add a helper to look up PFNs for DMABUFs Matt Evans
2026-05-27 22:38 ` Alex Williamson
2026-06-02 16:37 ` Matt Evans
2026-05-27 10:23 ` [PATCH v2 3/9] vfio/pci: Add a helper to create a DMABUF for a BAR-map VMA Matt Evans
2026-05-27 22:59 ` Alex Williamson
2026-06-02 16:39 ` Matt Evans
2026-05-27 10:23 ` [PATCH v2 4/9] vfio/pci: Convert BAR mmap() to use a DMABUF Matt Evans
2026-05-28 23:15 ` Alex Williamson
2026-06-02 18:01 ` Matt Evans
2026-05-27 10:23 ` [PATCH v2 5/9] vfio/pci: Provide a user-facing name for BAR mappings Matt Evans
2026-05-27 10:23 ` [PATCH v2 6/9] vfio/pci: Clean up BAR zap and revocation Matt Evans
2026-05-28 23:15 ` Alex Williamson
2026-05-27 10:23 ` [PATCH v2 7/9] vfio/pci: Support mmap() of a VFIO DMABUF Matt Evans
2026-05-28 23:15 ` Alex Williamson
2026-06-02 17:35 ` Matt Evans
2026-06-02 19:03 ` Alex Williamson [this message]
2026-05-27 10:23 ` [PATCH v2 8/9] vfio/pci: Permanently revoke a DMABUF on request Matt Evans
2026-05-28 23:14 ` Alex Williamson
2026-06-02 17:02 ` Matt Evans
2026-05-27 10:23 ` [PATCH v2 9/9] vfio/pci: Add mmap() attributes to DMABUF feature Matt Evans
2026-05-28 23:14 ` Alex Williamson
2026-06-02 16:50 ` Matt Evans
2026-06-02 19:14 ` Alex Williamson
2026-06-03 14:22 ` Matt Evans
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260602130326.6b7a8d0c@shazbot.org \
--to=alex@shazbot.org \
--cc=amastro@fb.com \
--cc=ankita@nvidia.com \
--cc=apopple@nvidia.com \
--cc=bhelgaas@google.com \
--cc=bjorn@kernel.org \
--cc=christian.koenig@amd.com \
--cc=dmatlack@google.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jgg@nvidia.com \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=leon@kernel.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=logang@deltatee.com \
--cc=mattev@meta.com \
--cc=mngyadam@amazon.de \
--cc=praan@google.com \
--cc=sumit.semwal@linaro.org \
--cc=vivek.kasireddy@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome