public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vfio: selftests: Skip vfio_dma_map_limit_test if mapping returns -EINVAL
@ 2025-11-07 22:20 David Matlack
  2025-11-08  0:17 ` Alex Mastro
  0 siblings, 1 reply; 11+ messages in thread
From: David Matlack @ 2025-11-07 22:20 UTC (permalink / raw)
  To: Alex Williamson
  Cc: Alex Mastro, Alex Williamson, David Matlack, Jason Gunthorpe, kvm,
	linux-kernel

Skip vfio_dma_map_limit_test.{unmap_range,unmap_all} (instead of
failing) on systems that do not support mapping in the page-sized region
at the top of the u64 address space. Use -EINVAL as the signal for
detecting systems with this limitation, as that is what both VFIO Type1
and iommufd return.

A more robust solution that could be considered in the future would be
to explicitly check the range of supported IOVA regions and key off
that, instead of inferring from -EINVAL.

Fixes: de8d1f2fd5a5 ("vfio: selftests: add end of address space DMA map/unmap tests")
Signed-off-by: David Matlack <dmatlack@google.com>
---
 .../testing/selftests/vfio/vfio_dma_mapping_test.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/vfio/vfio_dma_mapping_test.c b/tools/testing/selftests/vfio/vfio_dma_mapping_test.c
index 4f1ea79a200c..52b49cae58fe 100644
--- a/tools/testing/selftests/vfio/vfio_dma_mapping_test.c
+++ b/tools/testing/selftests/vfio/vfio_dma_mapping_test.c
@@ -249,7 +249,12 @@ TEST_F(vfio_dma_map_limit_test, unmap_range)
 	u64 unmapped;
 	int rc;
 
-	vfio_pci_dma_map(self->device, region);
+	rc = __vfio_pci_dma_map(self->device, region);
+	if (rc == -EINVAL)
+		SKIP(return, "Unable to map at iova 0x%lx\n", region->iova);
+	else
+		ASSERT_EQ(rc, 0);
+
 	ASSERT_EQ(region->iova, to_iova(self->device, region->vaddr));
 
 	rc = __vfio_pci_dma_unmap(self->device, region, &unmapped);
@@ -263,7 +268,12 @@ TEST_F(vfio_dma_map_limit_test, unmap_all)
 	u64 unmapped;
 	int rc;
 
-	vfio_pci_dma_map(self->device, region);
+	rc = __vfio_pci_dma_map(self->device, region);
+	if (rc == -EINVAL)
+		SKIP(return, "Unable to map at iova 0x%lx\n", region->iova);
+	else
+		ASSERT_EQ(rc, 0);
+
 	ASSERT_EQ(region->iova, to_iova(self->device, region->vaddr));
 
 	rc = __vfio_pci_dma_unmap_all(self->device, &unmapped);

base-commit: a1388fcb52fcad3e0b06e2cdd0ed757a82a5be30
-- 
2.51.2.1041.gc1ab5b90ca-goog


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

end of thread, other threads:[~2025-11-10 23:11 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-07 22:20 [PATCH] vfio: selftests: Skip vfio_dma_map_limit_test if mapping returns -EINVAL David Matlack
2025-11-08  0:17 ` Alex Mastro
2025-11-08 20:19   ` Alex Mastro
2025-11-08 21:37     ` Alex Williamson
2025-11-09  1:20       ` Alex Mastro
2025-11-10 15:17         ` Alex Williamson
2025-11-10 16:48           ` Alex Mastro
2025-11-10 18:00             ` David Matlack
2025-11-10 18:37               ` Alex Williamson
2025-11-10 19:45                 ` David Matlack
2025-11-10 23:10                   ` David Matlack

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