From: Josh Hilke <jrhilke@google.com>
To: David Matlack <dmatlack@google.com>, Alex Williamson <alex@shazbot.org>
Cc: Sean Christopherson <seanjc@google.com>,
Vipin Sharma <vipinsh@google.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Josh Hilke <jrhilke@google.com>
Subject: [PATCH v6] vfio: selftests: Find devices that have VFIO selftest drivers
Date: Tue, 2 Jun 2026 22:29:41 +0000 [thread overview]
Message-ID: <20260602222941.3133236-1-jrhilke@google.com> (raw)
Add a new script, list_supported_devices.sh, which prints out the
segment:bus:device.function (SBDF) numbers and names 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.
Includes a -q (quiet) argument which prints just the SBDFs so that the
output can be passed to tools/testing/selftests/vfio/scripts/setup.sh
(e.g. via xargs) to bind the devices to VFIO to use in VFIO selftests.
Examples:
$ ./list_supported_devices.sh
0000:6a:01.0 - Intel DSA SPR [8086:0b25]
0000:6f:01.0 - Intel DSA SPR [8086:0b25]
0000:74:01.0 - Intel DSA SPR [8086:0b25]
$ ./list_supported_devices.sh -q
0000:6a:01.0
0000:6f:01.0
0000:74:01.0
Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Josh Hilke <jrhilke@google.com>
---
Changelog
v5 -> v6
- Fix typos in commit message (Sashiko)
- Remove unused variable (Sashiko)
v5: https://lore.kernel.org/kvm/20260602185615.3025904-1-jrhilke@google.com/
tools/testing/selftests/vfio/Makefile | 1 +
.../vfio/scripts/list_supported_devices.sh | 43 +++++++++++++++++++
2 files changed, 44 insertions(+)
create mode 100755 tools/testing/selftests/vfio/scripts/list_supported_devices.sh
diff --git a/tools/testing/selftests/vfio/Makefile b/tools/testing/selftests/vfio/Makefile
index 0684932d91bf..127e70b996a9 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_supported_devices.sh
TEST_FILES += scripts/run.sh
TEST_FILES += scripts/setup.sh
diff --git a/tools/testing/selftests/vfio/scripts/list_supported_devices.sh b/tools/testing/selftests/vfio/scripts/list_supported_devices.sh
new file mode 100755
index 000000000000..4a4a2bc41901
--- /dev/null
+++ b/tools/testing/selftests/vfio/scripts/list_supported_devices.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+# List of devices which have a VFIO selftest driver. Device IDs are found in the
+# drivers in selftests/vfio/lib/drivers.
+readonly DEVICES=(
+ "8086:0b25,Intel DSA SPR"
+ "8086:11fb,Intel DSA GNR-D"
+ "8086:1212,Intel DSA DMR"
+ "8086:2021,Intel IOAT SKX"
+)
+
+# Print the segment:bus:device.function numbers of PCI devices that can be used
+# to run VFIO selftests.
+function main() {
+ local id_name
+ local quiet=""
+ local name
+ local bdfs
+ local id
+
+ while getopts "q" opt; do
+ case $opt in
+ q) quiet="true" ;;
+ \?) echo "Usage: $0 [-q]" >&2; exit 1 ;;
+ esac
+ done
+
+ for id_name in "${DEVICES[@]}"; do
+ IFS=',' read -r id name <<< "$id_name"
+ bdfs=$(lspci -D -d "${id}" | awk '{print $1}')
+
+ [[ -z $bdfs ]] && continue
+
+ if [ "$quiet" ]; then
+ echo "${bdfs}"
+ else
+ echo "${bdfs}" | sed "s|$| - ${name} [${id}]|"
+ fi
+ done
+}
+
+main "$@"
--
2.54.0.1013.g208068f2d8-goog
next reply other threads:[~2026-06-02 22:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-02 22:29 Josh Hilke [this message]
2026-06-04 19:50 ` Sean Christopherson
2026-06-04 20:30 ` David Matlack
2026-06-05 16:11 ` David Matlack
2026-06-05 18:19 ` Sean Christopherson
2026-06-17 15:37 ` David Matlack
2026-06-17 16:28 ` Vipin Sharma
2026-06-17 16:34 ` David Matlack
2026-06-17 19:07 ` Vipin Sharma
2026-06-17 19:38 ` Sean Christopherson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260602222941.3133236-1-jrhilke@google.com \
--to=jrhilke@google.com \
--cc=alex@shazbot.org \
--cc=dmatlack@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=seanjc@google.com \
--cc=vipinsh@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox