]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
vfio: selftests: add iova allocator
authorAlex Mastro <amastro@fb.com>
Tue, 11 Nov 2025 18:48:26 +0000 (10:48 -0800)
committerAlex Williamson <alex@shazbot.org>
Wed, 12 Nov 2025 15:04:42 +0000 (08:04 -0700)
commitce0e3c403e00e9e03e80aca6570bf936a44279e2
treef52ad6e5dccdb0a36f841b8efc6f8f310a678d9e
parenta77fa0b9222d2f23a764061a3be18e6bc738672e
vfio: selftests: add iova allocator

Add struct iova_allocator, which gives tests a convenient way to generate
legally-accessible IOVAs to map. This allocator traverses the sorted
available IOVA ranges linearly, requires power-of-two size allocations,
and does not support freeing iova allocations. The assumption is that
tests are not IOVA space-bounded, and will not need to recycle IOVAs.

This is based on Alex Williamson's patch series for adding an IOVA
allocator [1].

[1] https://lore.kernel.org/all/20251108212954.26477-1-alex@shazbot.org/

Reviewed-by: David Matlack <dmatlack@google.com>
Tested-by: David Matlack <dmatlack@google.com>
Signed-off-by: Alex Mastro <amastro@fb.com>
Link: https://lore.kernel.org/r/20251111-iova-ranges-v3-3-7960244642c5@fb.com
Signed-off-by: Alex Williamson <alex@shazbot.org>
tools/testing/selftests/vfio/lib/include/vfio_util.h
tools/testing/selftests/vfio/lib/vfio_pci_device.c