[PATCH v2 1/1] vfio: selftests: Find devices that have VFIO selftest drivers

From: Josh Hilke

Date: Tue Apr 14 2026 - 19:10:23 EST


Add a new script, list_devices.sh, which prints out the
segment:bus:device.function numbers of devices on a machine that have a VFIO
selftest driver. This makes it easier to determine if the system is capable of
running VFIO selftests, because devices that have a VFIO selftest driver are
compatible with all VFIO selftests.

Example:
$ ./tools/testing/selftests/vfio/scripts/list_devices.sh
0000:6a:01.0
0000:6f:01.0
0000:74:01.0

Signed-off-by: Josh Hilke <jrhilke@xxxxxxxxxx>
Suggested-by: Sean Christopherson <seanjc@xxxxxxxxxx>
---
tools/testing/selftests/vfio/Makefile | 1 +
.../selftests/vfio/scripts/list_devices.sh | 22 +++++++++++++++++++
2 files changed, 23 insertions(+)
create mode 100755 tools/testing/selftests/vfio/scripts/list_devices.sh

diff --git a/tools/testing/selftests/vfio/Makefile b/tools/testing/selftests/vfio/Makefile
index 8e90e409e91d..d48ac967f1dc 100644
--- a/tools/testing/selftests/vfio/Makefile
+++ b/tools/testing/selftests/vfio/Makefile
@@ -15,6 +15,7 @@ TEST_GEN_PROGS += vfio_pci_driver_test

TEST_FILES += scripts/cleanup.sh
TEST_FILES += scripts/lib.sh
+TEST_FILES += scripts/list_devices.sh
TEST_FILES += scripts/run.sh
TEST_FILES += scripts/setup.sh

diff --git a/tools/testing/selftests/vfio/scripts/list_devices.sh b/tools/testing/selftests/vfio/scripts/list_devices.sh
new file mode 100755
index 000000000000..b56fa23d5657
--- /dev/null
+++ b/tools/testing/selftests/vfio/scripts/list_devices.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+# List of devices which have a VFIO selftest driver
+DEVICES=(
+ "8086:0b25" # Intel SPR DSA
+ "8086:11fb" # Intel GNR-D DSA
+ "8086:1212" # Intel DR DSA
+ "8086:0cf8" # Intel CBDMA
+)
+
+# Print the segment:bus:device.function numbers of PCI devices that can be used
+# to run VFIO selftests.
+function main() {
+ local vendor_device_id
+
+ for vendor_device_id in "${DEVICES[@]}"; do
+ lspci -D -d "${vendor_device_id}" | awk '{print $1}'
+ done
+}
+
+main "$@"
--
2.54.0.rc0.605.g598a273b03-goog