From: David Laight <david.laight.linux@gmail.com>
To: David Matlack <dmatlack@google.com>
Cc: "Matt Evans" <matt@ozlabs.org>,
"Alex Williamson" <alex@shazbot.org>,
"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>,
"Kevin Tian" <kevin.tian@intel.com>,
"Pranjal Shrivastava" <praan@google.com>,
"Longfang Liu" <liulongfang@huawei.com>,
"Mahmoud Adam" <mngyadam@amazon.de>,
"Björn Töpel" <bjorn@kernel.org>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Ankit Agrawal" <ankita@nvidia.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
Subject: Re: [PATCH v5 0/9] vfio/pci: Add mmap() for DMABUFs
Date: Fri, 17 Jul 2026 09:42:30 +0100 [thread overview]
Message-ID: <20260717094230.21829508@pumpkin> (raw)
In-Reply-To: <allLypOmtbnPrgbw@google.com>
On Thu, 16 Jul 2026 21:23:22 +0000
David Matlack <dmatlack@google.com> wrote:
> On 2026-07-16 03:51 PM, Matt Evans wrote:
> > Hi David,
> >
> > On 15/07/2026 19:12, David Matlack wrote:
> > > On Wed, Jul 15, 2026 at 10:47 AM Matt Evans <matt@ozlabs.org> wrote:
> > >
> > >> This is based on v7.2-rc3.
> > >>
> > >> These commits are on GitHub for easier browsing, along with
> > >> "[RFC ONLY] selftests: vfio: Add standalone vfio_dmabuf_mmap_test":
> > >>
> > >> https://github.com/metamev/linux/compare/v7.2-rc3...dev/mev/vfio-dmabuf-mmap-v5
> > >
> > > It'd be great to have this test upstream. I'm happy to review it when
> > > you're ready. Looks like it just needs to be redone to use the VFIO
> > > selftests library and kselftests harness. AI could probably do the
> > > conversion pretty quick :)
> >
> > For sure, I'd intended to catch up with you on best approach here. :)
> >
> > Aside from the organic structure of the test (the open-coded VFIO
> > device/group setup/init needs to go), the main issue is that it relies
> > on a hacked/out of tree QEMU "EDU++" device with a second larger BAR
> > (containing freely read-writable memory). A subset of tests run with
> > the in-tree EDU device, but coverage is too low.
> >
> > The desirable properties are:
> >
> > - Having a BAR that is pure memory (all locations present, writable
> > without disruptive side-effects) so that mapping aliases can be
> > constructed and detected. This is good to test things like non-zero
> > vm_pgoffs and VA space presentation of physically-discontiguous DMABUFs.
> >
> > - BAR >> hugepage size so we can eyeball huge mappings work (or better,
> > mechanically test for them). At least 32MB would tick this box for 4K,
> > 16K page systems.
> >
> > - Something QEMU supports*, so one can run the test in a VM/TCG system.
> >
> > There were some real device models in QEMU that could be used this way,
> > but needed a fair bit of setup; I didn't want to rathole
> > vfio_dmabuf_mmap_test on including a ton of device-specific code for
> > some video card or similar.
> >
> > I'll dig more for a simple target that provides these properties --
> > obviously it would be better to point this test at an off-the-shelf
> > device (including silicon!). And, proposing EDU extensions to the QEMU
> > folks may be useful (there're uses for a better EDU in other contexts too).
> >
> > Since this test uses MMIO for a specific [class of] function, my first
> > thought is it should be another VFIO driver-type test sibling of
> > vfio_pci_driver_test. For example, we could extend the driver-type
> > tests' backend struct vfio_pci_driver_ops for functions capable of
> > providing a Big Memory BAR, like QEMU EDU++. EDU can also memcpy, so
> > could also support vfio_pci_driver_test.
> >
> > The spirit of the device backends hiding setup of a complex device is
> > handy, and it's plausible that several backends could provide this "big
> > memory BAR" service. What do you think, any concerns with extending
> > vfio_pci_driver_ops like that?
>
> I wouldn't recommend leveraging the driver framework unless absolutely
> necessary. It makes the test harder to run.
>
> The biggest issue I see with the proposed properties is being able to
> treat the BAR as memory. That obviously will depend on the device and
> may require device-specific setup. If we decide that treating the BAR as
> memory is truly required then using the driver framework is the way to
> go. But I'm hoping we can avoid that requirement.
Could you run a test where only a known part of the BAR can be treated
as memory?
A large BAR is likely to have some areas that can be accessed as memory.
David
>
> Instead, I think you can get pretty far by inspecting /proc/pid/pagemap
> to determine if the mmap() set things up correctly, without actually
> accessing the BAR. You can use /proc/pid/pagemap to look up the PFN and
> PAGEMAP_SCAN to detect huge pages.
>
> With that requirement gone, then all you really need is a device with a
> large enough BAR. And even that it not a hard requirement. I'm sure
> there are plenty of test cases that could work with smaller BARs. The
> few tests that want to exercise huge mappings can inspect the device BAR
> sizes first, and if they're all too small, SKIP() the test.
>
> If you structure the test this way, then it's easy for the test to be
> used. It can be run against any device for the basic functional
> coverage, and can be run against a device with a larger BAR for full
> coverage of huge mappings.
>
> Does QEMU emulate any devices that have 32MB or larger BARs?
>
prev parent reply other threads:[~2026-07-17 8:42 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 17:47 [PATCH v5 0/9] vfio/pci: Add mmap() for DMABUFs Matt Evans
2026-07-15 17:47 ` [PATCH v5 1/9] PCI/P2PDMA: Split pool-related cleanup out of pci_p2pdma_release() Matt Evans
2026-07-17 8:02 ` Tian, Kevin
2026-07-15 17:47 ` [PATCH v5 2/9] PCI/P2PDMA: Add CONFIG_PCI_P2PDMA_CORE Matt Evans
2026-07-17 8:02 ` Tian, Kevin
2026-07-15 17:47 ` [PATCH v5 3/9] vfio/pci: Add a helper to look up PFNs for DMABUFs Matt Evans
2026-07-17 8:02 ` Tian, Kevin
2026-07-15 17:47 ` [PATCH v5 4/9] vfio/pci: Add a helper to create a DMABUF for a BAR-map VMA Matt Evans
2026-07-15 17:47 ` [PATCH v5 5/9] vfio/pci: Convert BAR mmap() to use a DMABUF Matt Evans
2026-07-15 17:47 ` [PATCH v5 6/9] vfio/pci: Provide a user-facing name for BAR mappings Matt Evans
2026-07-17 8:03 ` Tian, Kevin
2026-07-15 17:47 ` [PATCH v5 7/9] vfio/pci: Clean up BAR zap and revocation Matt Evans
2026-07-17 8:03 ` Tian, Kevin
2026-07-15 17:47 ` [PATCH v5 8/9] vfio/pci: Support mmap() of a VFIO DMABUF Matt Evans
2026-07-17 8:03 ` Tian, Kevin
2026-07-15 17:47 ` [PATCH v5 9/9] vfio/pci: Permanently revoke a DMABUF on request Matt Evans
2026-07-17 8:03 ` Tian, Kevin
2026-07-15 18:12 ` [PATCH v5 0/9] vfio/pci: Add mmap() for DMABUFs David Matlack
2026-07-16 14:51 ` Matt Evans
2026-07-16 21:23 ` David Matlack
2026-07-17 8:42 ` David Laight [this message]
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=20260717094230.21829508@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=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=liulongfang@huawei.com \
--cc=logang@deltatee.com \
--cc=matt@ozlabs.org \
--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