From: Alex Mastro <amastro@fb.com>
To: Alex Williamson <alex@shazbot.org>
Cc: David Matlack <dmatlack@google.com>,
Shuah Khan <shuah@kernel.org>, <kvm@vger.kernel.org>,
<linux-kselftest@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Jason Gunthorpe <jgg@ziepe.ca>
Subject: Re: [PATCH 4/4] vfio: selftests: update vfio_dma_mapping_test to allocate iovas
Date: Mon, 10 Nov 2025 14:36:00 -0800 [thread overview]
Message-ID: <aRJo0LT6Bd2rEjcn@devgpu015.cco6.facebook.com> (raw)
In-Reply-To: <20251110143156.08d1859b.alex@shazbot.org>
On Mon, Nov 10, 2025 at 02:31:56PM -0700, Alex Williamson wrote:
> On Mon, 10 Nov 2025 13:10:44 -0800
> Alex Mastro <amastro@fb.com> wrote:
>
> > vfio_dma_mapping_test currently uses iova=vaddr as part of DMA mapping
> > validation. The assumption that these IOVAs are legal has held up on all
> > the hardware we've tested so far, but but is not guaranteed. Make the
> > test more robust by using iova_allocator to vend IOVAs, which queries
> > legally accessible IOVAs from the underlying IOMMUFD or VFIO container.
> >
> > Signed-off-by: Alex Mastro <amastro@fb.com>
> > ---
> > tools/testing/selftests/vfio/vfio_dma_mapping_test.c | 8 +++++++-
> > 1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/testing/selftests/vfio/vfio_dma_mapping_test.c b/tools/testing/selftests/vfio/vfio_dma_mapping_test.c
> > index 37c2a342df8d..c1a015385b0f 100644
> > --- a/tools/testing/selftests/vfio/vfio_dma_mapping_test.c
> > +++ b/tools/testing/selftests/vfio/vfio_dma_mapping_test.c
> > @@ -95,6 +95,7 @@ static int iommu_mapping_get(const char *bdf, u64 iova,
> >
> > FIXTURE(vfio_dma_mapping_test) {
> > struct vfio_pci_device *device;
> > + struct iova_allocator iova_allocator;
> > };
> >
> > FIXTURE_VARIANT(vfio_dma_mapping_test) {
> > @@ -118,11 +119,16 @@ FIXTURE_VARIANT_ADD_ALL_IOMMU_MODES(anonymous_hugetlb_1gb, SZ_1G, MAP_HUGETLB |
> >
> > FIXTURE_SETUP(vfio_dma_mapping_test)
> > {
> > + int ret;
> > +
> > self->device = vfio_pci_device_init(device_bdf, variant->iommu_mode);
> > + ret = iova_allocator_init(self->device, &self->iova_allocator);
> > + VFIO_ASSERT_EQ(ret, 0);
> > }
> >
> > FIXTURE_TEARDOWN(vfio_dma_mapping_test)
> > {
> > + iova_allocator_deinit(&self->iova_allocator);
> > vfio_pci_device_cleanup(self->device);
> > }
> >
> > @@ -144,7 +150,7 @@ TEST_F(vfio_dma_mapping_test, dma_map_unmap)
> > else
> > ASSERT_NE(region.vaddr, MAP_FAILED);
> >
> > - region.iova = (u64)region.vaddr;
> > + region.iova = iova_allocator_alloc(&self->iova_allocator, size);
> > region.size = size;
> >
> > vfio_pci_dma_map(self->device, ®ion);
> >
>
> There's another in the driver test. Thanks,
Oops -- thank you. Will add.
>
> Alex
next prev parent reply other threads:[~2025-11-10 22:36 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-10 21:10 [PATCH 0/4] vfio: selftests: update DMA mapping tests to use queried IOVA ranges Alex Mastro
2025-11-10 21:10 ` [PATCH 1/4] vfio: selftests: add iova range query helpers Alex Mastro
2025-11-10 21:31 ` Alex Williamson
2025-11-10 22:35 ` Alex Mastro
2025-11-10 22:03 ` David Matlack
2025-11-10 22:32 ` Alex Mastro
2025-11-10 23:02 ` David Matlack
2025-11-10 23:08 ` Alex Mastro
2025-11-10 21:10 ` [PATCH 2/4] vfio: selftests: fix map limit tests to use last available iova Alex Mastro
2025-11-10 21:31 ` Alex Williamson
2025-11-10 22:38 ` Alex Mastro
2025-11-11 0:09 ` David Matlack
2025-11-10 21:10 ` [PATCH 3/4] vfio: selftests: add iova allocator Alex Mastro
2025-11-10 21:31 ` Alex Williamson
2025-11-10 22:37 ` Alex Mastro
2025-11-10 22:54 ` David Matlack
2025-11-10 23:14 ` Alex Mastro
2025-11-10 21:10 ` [PATCH 4/4] vfio: selftests: update vfio_dma_mapping_test to allocate iovas Alex Mastro
2025-11-10 21:31 ` Alex Williamson
2025-11-10 22:36 ` Alex Mastro [this message]
2025-11-10 23:06 ` [PATCH 0/4] vfio: selftests: update DMA mapping tests to use queried IOVA ranges David Matlack
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=aRJo0LT6Bd2rEjcn@devgpu015.cco6.facebook.com \
--to=amastro@fb.com \
--cc=alex@shazbot.org \
--cc=dmatlack@google.com \
--cc=jgg@ziepe.ca \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=shuah@kernel.org \
/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