vfio: selftests: Find devices that have VFIO selftest drivers
Subsystems (4)
PATCH v7 1/1 vfio: selftests: Find devices that have VFIO selftest drivers
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 ...
---
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/[email protected]/
v5: https://lore.kernel.org/kvm/[email protected]/
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
tools/testing/selftests/vfio/Makefile +1 -0
@@ -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
tools/testing/selftests/vfio/scripts/list_supported_devices.sh new file +146 -0
146 lines not on this page · raw message
Signature · 1 line
2.56.0.455.g6c5a503b38-goog
Sean Christopherson
reviewerQuoted 31 lines · Josh Hilke
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.
Quoted 3 lines
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).