lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aRJo0LT6Bd2rEjcn@devgpu015.cco6.facebook.com>
Date: Mon, 10 Nov 2025 14:36:00 -0800
From: Alex Mastro <amastro@...com>
To: Alex Williamson <alex@...zbot.org>
CC: David Matlack <dmatlack@...gle.com>, Shuah Khan <shuah@...nel.org>,
        <kvm@...r.kernel.org>, <linux-kselftest@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>, Jason Gunthorpe <jgg@...pe.ca>
Subject: Re: [PATCH 4/4] vfio: selftests: update vfio_dma_mapping_test to
 allocate iovas

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@...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@...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, &region);
> > 
> 
> There's another in the driver test.  Thanks,

Oops -- thank you. Will add.

> 
> Alex

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ