summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/vfio/lib/include
diff options
context:
space:
mode:
authorAlex Mastro <amastro@fb.com>2026-01-14 10:57:17 -0800
committerAlex Williamson <alex@shazbot.org>2026-01-19 10:06:30 -0700
commit557dbdf6c4e9c2dc3d4a4476c67ef14dca32378d (patch)
treeccf91df662c70513326a45c4cfa74cb49158b14e /tools/testing/selftests/vfio/lib/include
parent03b7c2d763c907f508edf8c317c0e920ce072a33 (diff)
downloadlinux-557dbdf6c4e9c2dc3d4a4476c67ef14dca32378d.tar.gz
linux-557dbdf6c4e9c2dc3d4a4476c67ef14dca32378d.zip
vfio: selftests: Align BAR mmaps for efficient IOMMU mapping
Update vfio_pci_bar_map() to align BAR mmaps for efficient huge page mappings. The manual mmap alignment can be removed once mmap(!MAP_FIXED) on vfio device fds improves to automatically return well-aligned addresses. Also add MADV_HUGEPAGE, which encourages the kernel to use huge pages (e.g. when /sys/kernel/mm/transparent_hugepage/enabled is set to "madvise"). Drop MAP_FILE from mmap(). It is an ignored compatibility flag. Signed-off-by: Alex Mastro <amastro@fb.com> Reviewed-by: David Matlack <dmatlack@google.com> Tested-by: David Matlack <dmatlack@google.com> Link: https://lore.kernel.org/r/20260114-map-mmio-test-v3-2-44e036d95e64@fb.com Signed-off-by: Alex Williamson <alex@shazbot.org>
Diffstat (limited to 'tools/testing/selftests/vfio/lib/include')
-rw-r--r--tools/testing/selftests/vfio/lib/include/libvfio.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/testing/selftests/vfio/lib/include/libvfio.h b/tools/testing/selftests/vfio/lib/include/libvfio.h
index 279ddcd70194..1b6da54cc2cb 100644
--- a/tools/testing/selftests/vfio/lib/include/libvfio.h
+++ b/tools/testing/selftests/vfio/lib/include/libvfio.h
@@ -23,4 +23,13 @@
const char *vfio_selftests_get_bdf(int *argc, char *argv[]);
char **vfio_selftests_get_bdfs(int *argc, char *argv[], int *nr_bdfs);
+/*
+ * Reserve virtual address space of size at an address satisfying
+ * (vaddr % align) == offset.
+ *
+ * Returns the reserved vaddr. The caller is responsible for unmapping
+ * the returned region.
+ */
+void *mmap_reserve(size_t size, size_t align, size_t offset);
+
#endif /* SELFTESTS_VFIO_LIB_INCLUDE_LIBVFIO_H */