* [PATCH v7] vfio: selftests: Find devices that have VFIO selftest drivers
@ 2026-11-06 5:17 Josh Hilke
2026-11-11 16:51 ` Sean Christopherson
0 siblings, 1 reply; 2+ messages in thread
From: Josh Hilke @ 2026-11-06 5:17 UTC (permalink / raw)
To: Alex Williamson
Cc: David Matlack, Josh Hilke, kvm, linux-kernel,
Sean Christopherson, Vipin Sharma
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.
Some of these devices are on the vfio-pci denylist, so vfio-pci refuses
to bind them unless vfio_pci.disable_denylist=Y. The script marks such
devices as DENYLISTED and prints how to enable them, so the user is not
left wondering why the selftests cannot use a "supported" device.
Includes a -q (quiet) argument which prints just the SBDFs of devices
that vfio-pci can bind, so that the output can be passed directly to
tools/testing/selftests/vfio/scripts/setup.sh. Does not print the SBDF
of a device on the denylist.
Examples on a host with eight Intel DSA devices:
$ cat /sys/module/vfio_pci/parameters/disable_denylist
N
$ ./list_supported_devices.sh
0000:6a:01.0 - Intel DSA SPR [8086:0b25] (DENYLISTED)
0000:6f:01.0 - Intel DSA SPR [8086:0b25] (DENYLISTED)
...
vfio-pci does not bind DENYLISTED devices while
vfio_pci.disable_denylist=N. To use them, reload vfio-pci:
modprobe -r vfio-pci
modprobe vfio-pci disable_denylist=1
If vfio-pci is built into the kernel, boot with
vfio_pci.disable_denylist=1 instead.
With vfio_pci.disable_denylist=Y, the script lists the same devices with
"(DENYLISTED, but vfio_pci.disable_denylist=Y)", prints no hint, and
includes them in the -q output:
$ ./list_supported_devices.sh -q
0000:6a:01.0
0000:6f:01.0
...
Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Josh Hilke <jrhilke@google.com>
---
Changelog
v6 -> v7
- Mark devices on the vfio-pci denylist as DENYLISTED, and say when
vfio_pci.disable_denylist=Y allows them (Sean)
- Print how to enable denylisted devices when the denylist is on (Sean)
- Leave out denylisted devices from the -q output when the denylist is
on, so the -q output only has devices that setup.sh can bind (Sean)
- Add the igb and mlx5 devices. Leave out nv_falcon, because its probe
matches on a BAR0 register (PMC_BOOT_0), not on a PCI ID, so the script
cannot tell if a given NVIDIA GPU will work
- The mlx5 IDs and names are copied from mlx5st_probe(). They are not
tested on hardware
- Print a message on stderr when no device is found
- Read device IDs from sysfs instead of lspci, so the script no longer
needs pciutils
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 | 146 ++++++++++++++++++
2 files changed, 147 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..d1fad82f704a
--- /dev/null
+++ b/tools/testing/selftests/vfio/scripts/list_supported_devices.sh
@@ -0,0 +1,146 @@
+#!/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
+
+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() {
+ 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 denylist_note() {
+ if ! denylisted ${1}; then
+ return
+ elif denylist_enforced; then
+ echo " (DENYLISTED)"
+ else
+ echo " (DENYLISTED, but vfio_pci.disable_denylist=Y)"
+ fi
+}
+
+function print_denylist_hint() {
+ echo "vfio-pci does not bind DENYLISTED devices while"
+ echo "vfio_pci.disable_denylist=N. To use them, reload vfio-pci:"
+ echo " modprobe -r vfio-pci"
+ echo " modprobe vfio-pci disable_denylist=1"
+ echo "If vfio-pci is built into the kernel, boot with"
+ echo "vfio_pci.disable_denylist=1 instead."
+}
+
+# Print the segment:bus:device.function numbers of PCI devices that can be used
+# to run VFIO selftests.
+function main() {
+ local blocked=""
+ local quiet=""
+ local found=""
+ local vendor
+ local device
+ local name
+ local bdf
+ local opt
+ local id
+
+ while getopts "q" opt; do
+ case $opt in
+ q) quiet="true" ;;
+ \?) echo "Usage: $0 [-q]" >&2; exit 1 ;;
+ esac
+ done
+
+ 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
+ found="true"
+ if is_blocked ${id}; then
+ blocked="true"
+ fi
+
+ if [ -z "${quiet}" ]; then
+ echo "${bdf} - ${name} [${id}]$(denylist_note ${id})"
+ elif ! is_blocked ${id}; then
+ echo "${bdf}"
+ fi
+ done
+
+ if [ "${quiet}" ]; then
+ return 0
+ elif [ -z "${found}" ]; then
+ echo "No devices with a VFIO selftest driver found." >&2
+ elif [ "${blocked}" ]; then
+ print_denylist_hint >&2
+ fi
+}
+
+main "$@"
--
2.56.0.455.g6c5a503b38-goog
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH v7] vfio: selftests: Find devices that have VFIO selftest drivers
2026-11-06 5:17 [PATCH v7] vfio: selftests: Find devices that have VFIO selftest drivers Josh Hilke
@ 2026-11-11 16:51 ` Sean Christopherson
0 siblings, 0 replies; 2+ messages in thread
From: Sean Christopherson @ 2026-11-11 16:51 UTC (permalink / raw)
To: Josh Hilke
Cc: Alex Williamson, David Matlack, kvm, linux-kernel, Vipin Sharma
On Fri, Nov 06, 2026, Josh Hilke wrote:
> 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.
>
> Some of these devices are on the vfio-pci denylist, so vfio-pci refuses
> to bind them unless vfio_pci.disable_denylist=Y. The script marks such
> devices as DENYLISTED and prints how to enable them, so the user is not
> left wondering why the selftests cannot use a "supported" device.
>
> Includes a -q (quiet) argument which prints just the SBDFs of devices
> that vfio-pci can bind, so that the output can be passed directly to
> tools/testing/selftests/vfio/scripts/setup.sh. Does not print the SBDF
> of a device on the denylist.
>
> Examples on a host with eight Intel DSA devices:
>
> $ cat /sys/module/vfio_pci/parameters/disable_denylist
> N
>
> $ ./list_supported_devices.sh
> 0000:6a:01.0 - Intel DSA SPR [8086:0b25] (DENYLISTED)
> 0000:6f:01.0 - Intel DSA SPR [8086:0b25] (DENYLISTED)
> ...
> vfio-pci does not bind DENYLISTED devices while
> vfio_pci.disable_denylist=N. To use them, reload vfio-pci:
> modprobe -r vfio-pci
> modprobe vfio-pci disable_denylist=1
> If vfio-pci is built into the kernel, boot with
> vfio_pci.disable_denylist=1 instead.
>
> With vfio_pci.disable_denylist=Y, the script lists the same devices with
> "(DENYLISTED, but vfio_pci.disable_denylist=Y)", prints no hint, and
> includes them in the -q output:
Sorry for dragging this on, but I still find the output painful to read.
To me, this does not make it obvious that the devices are usable/available:
# ./list_supported_devices.sh
0000:6a:01.0 - Intel DSA SPR [8086:0b25] (DENYLISTED, but vfio_pci.disable_denylist=Y)
0000:6f:01.0 - Intel DSA SPR [8086:0b25] (DENYLISTED, but vfio_pci.disable_denylist=Y)
0000:74:01.0 - Intel DSA SPR [8086:0b25] (DENYLISTED, but vfio_pci.disable_denylist=Y)
0000:79:01.0 - Intel DSA SPR [8086:0b25] (DENYLISTED, but vfio_pci.disable_denylist=Y)
0000:e7:01.0 - Intel DSA SPR [8086:0b25] (DENYLISTED, but vfio_pci.disable_denylist=Y)
0000:ec:01.0 - Intel DSA SPR [8086:0b25] (DENYLISTED, but vfio_pci.disable_denylist=Y)
0000:f1:01.0 - Intel DSA SPR [8086:0b25] (DENYLISTED, but vfio_pci.disable_denylist=Y)
0000:f6:01.0 - Intel DSA SPR [8086:0b25] (DENYLISTED, but vfio_pci.disable_denylist=Y)
Especially if I glance at the output of the "bad" state:
# ./list_supported_devices.sh
0000:6a:01.0 - Intel DSA SPR [8086:0b25] (DENYLISTED)
0000:6f:01.0 - Intel DSA SPR [8086:0b25] (DENYLISTED)
0000:74:01.0 - Intel DSA SPR [8086:0b25] (DENYLISTED)
0000:79:01.0 - Intel DSA SPR [8086:0b25] (DENYLISTED)
0000:e7:01.0 - Intel DSA SPR [8086:0b25] (DENYLISTED)
0000:ec:01.0 - Intel DSA SPR [8086:0b25] (DENYLISTED)
0000:f1:01.0 - Intel DSA SPR [8086:0b25] (DENYLISTED)
0000:f6:01.0 - Intel DSA SPR [8086:0b25] (DENYLISTED)
vfio-pci does not bind DENYLISTED devices while
vfio_pci.disable_denylist=N. To use them, reload vfio-pci:
modprobe -r vfio-pci
modprobe vfio-pci disable_denylist=1
If vfio-pci is built into the kernel, boot with
vfio_pci.disable_denylist=1 instead.
IMO, the blurb at the end is also unnecessarily noisy. I don't think we need to
tell the user how to manage kernel modules. I realize I'm setting a double
standard with respect to assumed knowledge, but IMO knowing how to load kernel
modules is table stakes for anyone running this script.
The blurb (and strictly speaking, the scirpt as a whole) is also somewhat
misleading because it doesn't actually verify that vfio-pci is loaded.
Rather than squish everything into a the per-device output, what if we organize
the devices so that it's more obvious what is what, and so that the output isn't
as noisy/redundant. E.g. something like the below. And for the -q output, it
probably makes sense to also provide a flag to show/hide unusable devices. Probably
to show? i.e. have -q output show only fully supported devices by default? And
maybe fail -q outright if vfio-pci isn't loaded? Dunno about that last one, not
sure what would be the least confusing.
If vfio-pci is loaded with disable_denylist=1 and there are both allowed and
denied-by-default devices (ignore that they're all the same device):
# ./list_supported_devices.sh
Supported
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]
0000:79:01.0 - Intel DSA SPR [8086:0b25]
0000:e7:01.0 - Intel DSA SPR [8086:0b25]
0000:ec:01.0 - Intel DSA SPR [8086:0b25]
0000:f1:01.0 - Intel DSA SPR [8086:0b25]
0000:f6:01.0 - Intel DSA SPR [8086:0b25]
Supported (on denylist, but denylist disabled)
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]
0000:79:01.0 - Intel DSA SPR [8086:0b25]
0000:e7:01.0 - Intel DSA SPR [8086:0b25]
0000:ec:01.0 - Intel DSA SPR [8086:0b25]
0000:f1:01.0 - Intel DSA SPR [8086:0b25]
0000:f6:01.0 - Intel DSA SPR [8086:0b25]
Versus if vfio-pci is loaded with disable_denylist=0:
# ./list_supported_devices.sh
Supported
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]
0000:79:01.0 - Intel DSA SPR [8086:0b25]
0000:e7:01.0 - Intel DSA SPR [8086:0b25]
0000:ec:01.0 - Intel DSA SPR [8086:0b25]
0000:f1:01.0 - Intel DSA SPR [8086:0b25]
0000:f6:01.0 - Intel DSA SPR [8086:0b25]
Unusable (available, but denylisted by the kernel):
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]
0000:79:01.0 - Intel DSA SPR [8086:0b25]
0000:e7:01.0 - Intel DSA SPR [8086:0b25]
0000:ec:01.0 - Intel DSA SPR [8086:0b25]
0000:f1:01.0 - Intel DSA SPR [8086:0b25]
0000:f6: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).
Versus if vfio-pci isn't loaded at all:
# ./list_supported_devices.sh
Unusable (available, but vfio-pci not loaded)
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]
0000:79:01.0 - Intel DSA SPR [8086:0b25]
0000:e7:01.0 - Intel DSA SPR [8086:0b25]
0000:ec:01.0 - Intel DSA SPR [8086:0b25]
0000:f1:01.0 - Intel DSA SPR [8086:0b25]
0000:f6:01.0 - Intel DSA SPR [8086:0b25]
Unusable (available, but vfio-pci not loaded, and denylisted by the kernel):
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]
0000:79:01.0 - Intel DSA SPR [8086:0b25]
0000:e7:01.0 - Intel DSA SPR [8086:0b25]
0000:ec:01.0 - Intel DSA SPR [8086:0b25]
0000:f1:01.0 - Intel DSA SPR [8086:0b25]
0000:f6: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).
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-11 16:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-06 5:17 [PATCH v7] vfio: selftests: Find devices that have VFIO selftest drivers Josh Hilke
2026-11-11 16:51 ` Sean Christopherson
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®