* [PATCH v8] vfio: selftests: Find devices that have VFIO selftest drivers
@ 2026-11-18 6:43 Josh Hilke
2026-11-19 0:43 ` David Matlack
0 siblings, 1 reply; 2+ messages in thread
From: Josh Hilke @ 2026-11-18 6:43 UTC (permalink / raw)
To: Alex Williamson
Cc: David Matlack, Josh Hilke, kvm, linux-kernel,
Sean Christopherson, Vipin Sharma
Add list_supported_devices.sh to print the PCI addresses and names of
devices on the host that have a VFIO selftest driver. Group the output
into supported and unusable sections based on whether vfio-pci is loaded
and whether the vfio-pci denylist blocks the device.
Add -q to print only the PCI addresses of usable devices so the output
can go straight to setup.sh. Add -a for use with -q to include unusable
devices as well.
When vfio-pci is loaded with disable_denylist=Y, the script lists the
denylisted devices under "Supported (on denylist, but denylist
disabled):" and includes them in the -q output. When vfio-pci is not
loaded, the script lists all devices as unusable and omits them from -q
unless -a is also passed.
Example on a host with Intel IOAT and Intel DSA devices when vfio-pci is
loaded with disable_denylist=N:
$ ./list_supported_devices.sh
Supported:
0000:00:04.0 - Intel IOAT SKX [8086:2021]
...
Unusable (available, but denylisted by the kernel):
0000:6a:01.0 - Intel DSA SPR [8086:0b25]
...
To use denylisted devices, load vfio-pci with disable_denylist=1
(or boot the kernel with vfio_pci.disable_denylist=1).
$ ./list_supported_devices.sh -q
0000:00:04.0
...
$ ./list_supported_devices.sh -q -a
0000:00:04.0
...
0000:6a:01.0
...
Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Josh Hilke <jrhilke@google.com>
---
Changelog
v7 -> v8
- Group devices under Supported and Unusable headers instead of
repeating denylist state on every line, and shorten the denylist hint
at the end of the denylisted section. Suggested by Sean.
- Check /sys/bus/pci/drivers/vfio-pci to verify that vfio-pci is loaded,
mark devices as unusable when it is not loaded, and omit them from -q
unless -a is passed. Suggested by Sean.
- Add -a for use with -q to include unusable devices in the SBDF output.
Suggested by Sean.
v7: https://lore.kernel.org/kvm/20261106051726.3964374-1-jrhilke@google.com/
v6: https://lore.kernel.org/kvm/20260602222941.3133236-1-jrhilke@google.com/
v5: https://lore.kernel.org/kvm/20260602185615.3025904-1-jrhilke@google.com/
tools/testing/selftests/vfio/Makefile | 1 +
.../vfio/scripts/list_supported_devices.sh | 199 ++++++++++++++++++
2 files changed, 200 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 2c32c48db509..160aa989828f 100644
--- a/tools/testing/selftests/vfio/Makefile
+++ b/tools/testing/selftests/vfio/Makefile
@@ -16,6 +16,7 @@ TEST_GEN_PROGS += vfio_pci_sriov_uapi_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..c909b2aedd01
--- /dev/null
+++ b/tools/testing/selftests/vfio/scripts/list_supported_devices.sh
@@ -0,0 +1,199 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+# Devices that have a driver 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"
+ "8086:10c9,Intel 82576 Gigabit Ethernet Controller"
+ "15b3:1011,Mellanox Connect-IB"
+ "15b3:1012,Mellanox Connect-IB VF"
+ "15b3:1013,Mellanox ConnectX-4"
+ "15b3:1014,Mellanox ConnectX-4 VF"
+ "15b3:1015,Mellanox ConnectX-4LX"
+ "15b3:1016,Mellanox ConnectX-4LX VF"
+ "15b3:1017,Mellanox ConnectX-5"
+ "15b3:1018,Mellanox ConnectX-5 VF"
+ "15b3:1019,Mellanox ConnectX-5 Ex"
+ "15b3:101a,Mellanox ConnectX-5 Ex VF"
+ "15b3:101b,Mellanox ConnectX-6"
+ "15b3:101c,Mellanox ConnectX-6 VF"
+ "15b3:101d,Mellanox ConnectX-6 Dx"
+ "15b3:101e,Mellanox ConnectX-6 Dx VF"
+ "15b3:101f,Mellanox ConnectX-6 LX"
+ "15b3:1021,Mellanox ConnectX-7"
+ "15b3:1023,Mellanox ConnectX-8"
+ "15b3:1025,Mellanox ConnectX-9"
+ "15b3:1027,Mellanox ConnectX-10"
+ "15b3:2101,Mellanox ConnectX-10 NVLink-C2C"
+ "15b3:a2d2,Mellanox BlueField integrated ConnectX-5"
+ "15b3:a2d3,Mellanox BlueField integrated ConnectX-5 VF"
+ "15b3:a2d6,Mellanox BlueField-2 integrated ConnectX-6 Dx"
+ "15b3:a2dc,Mellanox BlueField-3 integrated ConnectX-7"
+ "15b3:a2df,Mellanox BlueField-4 integrated ConnectX-8"
+)
+
+# Devices in DEVICES that are also on the vfio-pci denylist. The denylist is
+# in vfio_pci_dev_in_denylist() in drivers/vfio/pci/vfio_pci.c.
+readonly DENYLIST=(
+ "8086:0b25"
+)
+
+readonly DISABLE_DENYLIST=/sys/module/vfio_pci/parameters/disable_denylist
+readonly VFIO_PCI_DRIVER=/sys/bus/pci/drivers/vfio-pci
+
+function vfio_pci_loaded() {
+ [ -d ${VFIO_PCI_DRIVER} ]
+}
+
+function denylisted() {
+ local id
+
+ for id in "${DENYLIST[@]}"; do
+ [ "${id}" = "${1}" ] && return 0
+ done
+
+ return 1
+}
+
+function denylist_enforced() {
+ local value
+
+ read -r value 2>/dev/null < ${DISABLE_DENYLIST}
+ [ "${value}" != "Y" ]
+}
+
+function is_blocked() {
+ if ! vfio_pci_loaded; then
+ return 0
+ fi
+
+ denylisted ${1} && denylist_enforced
+}
+
+function device_name() {
+ local entry
+
+ for entry in "${DEVICES[@]}"; do
+ if [ "${entry%%,*}" = "${1}" ]; then
+ echo "${entry#*,}"
+ return 0
+ fi
+ done
+
+ return 1
+}
+
+function print_allowed_devices() {
+ local device
+
+ if vfio_pci_loaded; then
+ echo "Supported:"
+ else
+ echo "Unusable (available, but vfio-pci not loaded):"
+ fi
+
+ for device in "$@"; do
+ echo " ${device}"
+ done
+}
+
+function print_denylisted_devices() {
+ local device
+
+ if ! vfio_pci_loaded; then
+ echo "Unusable (available, but vfio-pci not loaded, and denylisted by the kernel):"
+ elif denylist_enforced; then
+ echo "Unusable (available, but denylisted by the kernel):"
+ else
+ echo "Supported (on denylist, but denylist disabled):"
+ fi
+
+ for device in "$@"; do
+ echo " ${device}"
+ done
+
+ if ! vfio_pci_loaded || denylist_enforced; then
+ echo
+ echo " To use denylisted devices, load vfio-pci with disable_denylist=1"
+ echo " (or boot the kernel with vfio_pci.disable_denylist=1)."
+ fi
+}
+
+function usage() {
+ echo "Usage: $0 [-q] [-a]" >&2
+ echo >&2
+ echo "Options:" >&2
+ echo " -q Print only the PCI addresses of usable devices." >&2
+ echo " -a Include unusable devices when used with -q." >&2
+ exit 1
+}
+
+# Print the segment:bus:device.function numbers of PCI devices that can be used
+# to run VFIO selftests.
+function main() {
+ local denylisted_devices=()
+ local allowed_devices=()
+ local quiet=""
+ local all=""
+ local vendor
+ local device
+ local name
+ local bdf
+ local opt
+ local id
+
+ while getopts "qa" opt; do
+ case $opt in
+ q) quiet="true" ;;
+ a) all="true" ;;
+ \?) usage ;;
+ esac
+ done
+
+ if [ "${all}" ] && [ -z "${quiet}" ]; then
+ usage
+ fi
+
+ for bdf in $(ls /sys/bus/pci/devices); do
+ read -r vendor < /sys/bus/pci/devices/${bdf}/vendor
+ read -r device < /sys/bus/pci/devices/${bdf}/device
+ printf -v id "%04x:%04x" ${vendor} ${device}
+
+ name=$(device_name ${id}) || continue
+
+ if [ "${quiet}" ]; then
+ if [ "${all}" ] || ! is_blocked ${id}; then
+ echo "${bdf}"
+ fi
+ continue
+ fi
+
+ if denylisted ${id}; then
+ denylisted_devices+=("${bdf} - ${name} [${id}]")
+ else
+ allowed_devices+=("${bdf} - ${name} [${id}]")
+ fi
+ done
+
+ if [ "${quiet}" ]; then
+ return 0
+ fi
+
+ if [ ${#allowed_devices[@]} -eq 0 ] && [ ${#denylisted_devices[@]} -eq 0 ]; then
+ echo "No devices with a VFIO selftest driver found." >&2
+ return 0
+ fi
+
+ if [ ${#allowed_devices[@]} -gt 0 ]; then
+ print_allowed_devices "${allowed_devices[@]}"
+ fi
+
+ if [ ${#denylisted_devices[@]} -gt 0 ]; then
+ print_denylisted_devices "${denylisted_devices[@]}"
+ fi
+}
+
+main "$@"
--
2.56.0.679.gc527c65306-goog
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH v8] vfio: selftests: Find devices that have VFIO selftest drivers
2026-11-18 6:43 [PATCH v8] vfio: selftests: Find devices that have VFIO selftest drivers Josh Hilke
@ 2026-11-19 0:43 ` David Matlack
0 siblings, 0 replies; 2+ messages in thread
From: David Matlack @ 2026-11-19 0:43 UTC (permalink / raw)
To: Josh Hilke, Alex Williamson
Cc: David Matlack, kvm, linux-kernel, Sean Christopherson, Vipin Sharma
On Tue Nov 17, 2026 at 10:43 PM PST, Josh Hilke wrote:
> +# Devices that have a driver in selftests/vfio/lib/drivers.
> +readonly DEVICES=(
> + "8086:0b25,Intel DSA SPR"
> [...]
> + "15b3:a2df,Mellanox BlueField-4 integrated ConnectX-8"
> +)
This is missing GPUs that are supported by the nv_falcon driver.
I saw in the v7 changelog that you left them out because
nv_falcon_probe() matches on PMC_BOOT_0 rather than PCI ID. But the
first thing nv_falcon_probe() does is check vendor == 0x10de and base
class == PCI_BASE_CLASS_DISPLAY, and the script can get both of those
from sysfs. And past that, nv_falcon_probe() only rejects GPUs with an
unknown architecture; unverified GPUs are accepted with a "possibly not
supported" message. So matching on vendor and class gets the script
about as close as the driver itself gets.
e.g. something like:
read -r class < /sys/bus/pci/devices/${bdf}/class
if [ "${vendor}" = "0x10de" ] && [ $((class >> 16)) -eq 3 ]; then
...
fi
Also, nv_falcon does not implement send_msi(), so on NVIDIA GPUs the
send_msi tests in vfio_pci_driver_test are skipped and kvm/irq_test
does not run at all. The script should make this clear when it reports
an NVIDIA GPU so users know they're getting reduced coverage.
Since the script can't check the GPU architecture itself, it would also
help to tell the user which architectures nv_falcon supports, so they
can check their GPU themselves. e.g. something like:
Supported:
0000:00:04.0 - Intel IOAT SKX [8086:2021]
Possibly supported (depends on GPU architecture):
0000:3b:00.0 - NVIDIA GPU [10de:1eb8]
nv_falcon supports Kepler, Maxwell, Pascal, Volta, Turing, Ampere,
Ada, and Hopper GPUs. It does not support send_msi().
Please add a comment next to the list of architectures pointing at
nv_gpu_arch_lookup() so the two stay in sync.
I think it's fine to include these GPUs in the -q output. If the GPU
turns out to be unsupported, vfio_pci_driver_test will just skip.
Printing the selftest driver name for each device might also help
here, and would make it easier to tie the list back to lib/drivers/.
> +function vfio_pci_loaded() {
> + [ -d ${VFIO_PCI_DRIVER} ]
> +}
> +
> +function denylisted() {
> [...]
> +function denylist_enforced() {
> [...]
> +function is_blocked() {
Please consistently use is_*() for functions that check a condition,
e.g. is_vfio_pci_loaded(), is_denylisted(), is_denylist_enforced(), and
is_blocked(). That makes call sites like this one read more clearly:
if [ "${all}" ] || ! is_blocked ${id}; then
> + if [ ${#allowed_devices[@]} -gt 0 ]; then
> + print_allowed_devices "${allowed_devices[@]}"
> + fi
> +
> + if [ ${#denylisted_devices[@]} -gt 0 ]; then
> + print_denylisted_devices "${denylisted_devices[@]}"
> + fi
nit: When both groups have devices, there's no blank line between the
last "Supported:" entry and the "Unusable ...:" header, which makes the
output harder to scan.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-19 0:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 6:43 [PATCH v8] vfio: selftests: Find devices that have VFIO selftest drivers Josh Hilke
2026-11-19 0:43 ` David Matlack
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®