* [PATCH v2 0/1] vfio: selftests: Find devices that have VFIO selftest drivers
@ 2026-04-14 23:09 Josh Hilke
2026-04-14 23:09 ` [PATCH v2 1/1] " Josh Hilke
0 siblings, 1 reply; 8+ messages in thread
From: Josh Hilke @ 2026-04-14 23:09 UTC (permalink / raw)
To: Alex Williamson
Cc: Sean Christopherson, David Matlack, Vipin Sharma,
Raghavendra Rao Ananta, kvm, linux-kernel, Josh Hilke
v2 of this series is only a single patch which adds a new script to print the
segment:bus:device.function numbers of PCI devices on the user's system which
have a VFIO selftest driver.
Example:
$ ./tools/testing/selftests/vfio/scripts/list_devices.sh
0000:6a:01.0
0000:6f:01.0
0000:74:01.0
The devices are compatible with all VFIO selftests. Other devices may be
compatible with VFIO selftests that don't use the driver functionality, but no
gaurantees.
User's can automate binding devices to VFIO (which is required in order to run
the selftests) by directing the output of list_devices.sh into
tools/testing/selftests/vfio/scripts/setup.sh.
Example:
$ ./tools/testing/selftests/vfio/scripts/setup.sh $(./tools/testing/selftests/vfio/scripts/list_devices.sh)
+ echo "0000:6a:01.0" > /sys/bus/pci/drivers/vfio-pci/unbind
+ echo "" > /sys/bus/pci/devices/0000:6a:01.0/driver_override
+ echo "0000:6a:01.0" > /sys/bus/pci/drivers/idxd/bind
+ echo "0000:6f:01.0" > /sys/bus/pci/drivers/vfio-pci/unbind
+ echo "" > /sys/bus/pci/devices/0000:6f:01.0/driver_override
+ echo "0000:6f:01.0" > /sys/bus/pci/drivers/idxd/bind
+ echo "0000:74:01.0" > /sys/bus/pci/drivers/vfio-pci/unbind
+ echo "" > /sys/bus/pci/devices/0000:74:01.0/driver_override
+ echo "0000:74:01.0" > /sys/bus/pci/drivers/idxd/bind
This series is based on top of the kvm/queue branch.
Changes from v1:
---
- Move the functionality to discover devices from setup.sh into its own script (Sean)
- Omit the patch which automates binding devices to VFIO (Sean, David)
- Change title of cover letter (Me)
v1: https://lore.kernel.org/kvm/20260409015139.2800185-1-jrhilke@google.com/
Josh Hilke (1):
vfio: selftests: Find devices that have VFIO selftest drivers
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
--
2.54.0.rc0.605.g598a273b03-goog
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/1] vfio: selftests: Find devices that have VFIO selftest drivers
2026-04-14 23:09 [PATCH v2 0/1] vfio: selftests: Find devices that have VFIO selftest drivers Josh Hilke
@ 2026-04-14 23:09 ` Josh Hilke
2026-04-16 23:35 ` David Matlack
2026-05-08 18:17 ` Sean Christopherson
0 siblings, 2 replies; 8+ messages in thread
From: Josh Hilke @ 2026-04-14 23:09 UTC (permalink / raw)
To: Alex Williamson
Cc: Sean Christopherson, David Matlack, Vipin Sharma,
Raghavendra Rao Ananta, kvm, linux-kernel, Josh Hilke
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@google.com>
Suggested-by: Sean Christopherson <seanjc@google.com>
---
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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/1] vfio: selftests: Find devices that have VFIO selftest drivers
2026-04-14 23:09 ` [PATCH v2 1/1] " Josh Hilke
@ 2026-04-16 23:35 ` David Matlack
2026-05-08 18:17 ` Sean Christopherson
1 sibling, 0 replies; 8+ messages in thread
From: David Matlack @ 2026-04-16 23:35 UTC (permalink / raw)
To: Josh Hilke
Cc: Alex Williamson, Sean Christopherson, Vipin Sharma,
Raghavendra Rao Ananta, kvm, linux-kernel
On 2026-04-14 11:09 PM, Josh Hilke wrote:
> 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@google.com>
> Suggested-by: Sean Christopherson <seanjc@google.com>
Aside the nit below, looks good to me. But would like to get Sean's
feedback too since he requested it.
Reviewed-by: David Matlack <dmatlack@google.com>
> ---
> 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=(
nit: Use readonly here.
> + "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
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/1] vfio: selftests: Find devices that have VFIO selftest drivers
2026-04-14 23:09 ` [PATCH v2 1/1] " Josh Hilke
2026-04-16 23:35 ` David Matlack
@ 2026-05-08 18:17 ` Sean Christopherson
2026-05-08 22:03 ` Josh Hilke
1 sibling, 1 reply; 8+ messages in thread
From: Sean Christopherson @ 2026-05-08 18:17 UTC (permalink / raw)
To: Josh Hilke
Cc: Alex Williamson, David Matlack, Vipin Sharma,
Raghavendra Rao Ananta, kvm, linux-kernel
On Tue, Apr 14, 2026, Josh Hilke wrote:
> +# 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}'
For ignorant people like me, it would be helpful to capture what device was actually
found. I mean, I don't necessarily know exactly what these devices do, but as the
list grows, at least having a general sense of what device I'm going to be feeding
into VFIO would be helpful.
E.g. something like this (ignore my terrible script skills)?
#!/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 found
local i
OLDIFS=$IFS
IFS=','
for i in "${DEVICES[@]}"; do
set -- $i
found=$(lspci -D -d "$1" | cut -f 1 -d ' ')
if [[ -n $found ]]; then
echo "$2 ($1) Device IDs:"
echo $found
fi
done
IFS=$OLDIFS
}
main
# ./devices.sh
Intel SPR DSA (8086:0b25) Device IDs:
0000:6a:01.0
0000:6f:01.0
0000:74:01.0
0000:79:01.0
0000:e7:01.0
0000:ec:01.0
0000:f1:01.0
0000:f6:01.0
> + done
> +}
> +
> +main "$@"
Why pass along args? The script doesn't actually recognize any arguments.
> --
> 2.54.0.rc0.605.g598a273b03-goog
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/1] vfio: selftests: Find devices that have VFIO selftest drivers
2026-05-08 18:17 ` Sean Christopherson
@ 2026-05-08 22:03 ` Josh Hilke
2026-05-08 22:20 ` Sean Christopherson
0 siblings, 1 reply; 8+ messages in thread
From: Josh Hilke @ 2026-05-08 22:03 UTC (permalink / raw)
To: Sean Christopherson
Cc: Alex Williamson, David Matlack, Vipin Sharma,
Raghavendra Rao Ananta, kvm, linux-kernel
On Fri, May 8, 2026 at 11:17 AM Sean Christopherson <seanjc@google.com> wrote:
>
> On Tue, Apr 14, 2026, Josh Hilke wrote:
> > +# 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}'
>
> For ignorant people like me, it would be helpful to capture what device was actually
> found. I mean, I don't necessarily know exactly what these devices do, but as the
> list grows, at least having a general sense of what device I'm going to be feeding
> into VFIO would be helpful.
>
Sure I can do that.
> # ./devices.sh
> Intel SPR DSA (8086:0b25) Device IDs:
> 0000:6a:01.0
> 0000:6f:01.0
> 0000:74:01.0
> 0000:79:01.0
> 0000:e7:01.0
> 0000:ec:01.0
> 0000:f1:01.0
> 0000:f6:01.0
How about a "-v" (verbose) option which prints the device name
alongside the BDF?
$ ./list_devices.sh -v
0000:6a:01.0 Intel SPR DSA (8086:0b25)
0000:6f:01.0 Intel SPR DSA (8086:0b25)
This approach preserves the ability to pipe the script output into
/tools/testing/selftests/vfio/scripts/setup.sh to automate binding the
devices to VFIO by excluding the -v arg since the setup script expects
a list of BDFs.
> > +main "$@"
>
> Why pass along args? The script doesn't actually recognize any arguments.
It's a remnant from copying another script when creating this one.
I'll remove it if we don't add the -v argument.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/1] vfio: selftests: Find devices that have VFIO selftest drivers
2026-05-08 22:03 ` Josh Hilke
@ 2026-05-08 22:20 ` Sean Christopherson
2026-05-08 22:49 ` David Matlack
0 siblings, 1 reply; 8+ messages in thread
From: Sean Christopherson @ 2026-05-08 22:20 UTC (permalink / raw)
To: Josh Hilke
Cc: Alex Williamson, David Matlack, Vipin Sharma,
Raghavendra Rao Ananta, kvm, linux-kernel
On Fri, May 08, 2026, Josh Hilke wrote:
> On Fri, May 8, 2026 at 11:17 AM Sean Christopherson <seanjc@google.com> wrote:
> >
> > On Tue, Apr 14, 2026, Josh Hilke wrote:
> > > +# 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}'
> >
> > For ignorant people like me, it would be helpful to capture what device was actually
> > found. I mean, I don't necessarily know exactly what these devices do, but as the
> > list grows, at least having a general sense of what device I'm going to be feeding
> > into VFIO would be helpful.
> >
>
> Sure I can do that.
>
> > # ./devices.sh
> > Intel SPR DSA (8086:0b25) Device IDs:
> > 0000:6a:01.0
> > 0000:6f:01.0
> > 0000:74:01.0
> > 0000:79:01.0
> > 0000:e7:01.0
> > 0000:ec:01.0
> > 0000:f1:01.0
> > 0000:f6:01.0
>
> How about a "-v" (verbose) option which prints the device name
> alongside the BDF?
> Works for me.
> $ ./list_devices.sh -v
> 0000:6a:01.0 Intel SPR DSA (8086:0b25)
> 0000:6f:01.0 Intel SPR DSA (8086:0b25)
Maybe add a dash to visually separate things? E.g.
0000:6a:01.0 - Intel SPR DSA (8086:0b25)
> This approach preserves the ability to pipe the script output into
> /tools/testing/selftests/vfio/scripts/setup.sh to automate binding the
> devices to VFIO by excluding the -v arg since the setup script expects
> a list of BDFs.
Alternatively, -q for quiet? Or:
./devices.sh | cut -f 1 -d ' ' | setup.sh
Or have setup.h do the cutting? I'm a-ok with a -v, but if the script is mostly
going to be run by humans (no idea if this is true), it seems like it should use
the more verbose version by default.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/1] vfio: selftests: Find devices that have VFIO selftest drivers
2026-05-08 22:20 ` Sean Christopherson
@ 2026-05-08 22:49 ` David Matlack
2026-05-11 16:12 ` Josh Hilke
0 siblings, 1 reply; 8+ messages in thread
From: David Matlack @ 2026-05-08 22:49 UTC (permalink / raw)
To: Sean Christopherson
Cc: Josh Hilke, Alex Williamson, Vipin Sharma, Raghavendra Rao Ananta,
kvm, linux-kernel
On Fri, May 8, 2026 at 3:20 PM Sean Christopherson <seanjc@google.com> wrote:
>
> On Fri, May 08, 2026, Josh Hilke wrote:
> > On Fri, May 8, 2026 at 11:17 AM Sean Christopherson <seanjc@google.com> wrote:
> > >
> > > On Tue, Apr 14, 2026, Josh Hilke wrote:
> > > > +# 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}'
> > >
> > > For ignorant people like me, it would be helpful to capture what device was actually
> > > found. I mean, I don't necessarily know exactly what these devices do, but as the
> > > list grows, at least having a general sense of what device I'm going to be feeding
> > > into VFIO would be helpful.
> > >
> >
> > Sure I can do that.
> >
> > > # ./devices.sh
> > > Intel SPR DSA (8086:0b25) Device IDs:
> > > 0000:6a:01.0
> > > 0000:6f:01.0
> > > 0000:74:01.0
> > > 0000:79:01.0
> > > 0000:e7:01.0
> > > 0000:ec:01.0
> > > 0000:f1:01.0
> > > 0000:f6:01.0
> >
> > How about a "-v" (verbose) option which prints the device name
> > alongside the BDF?
> > Works for me.
>
> > $ ./list_devices.sh -v
> > 0000:6a:01.0 Intel SPR DSA (8086:0b25)
> > 0000:6f:01.0 Intel SPR DSA (8086:0b25)
>
> Maybe add a dash to visually separate things? E.g.
>
> 0000:6a:01.0 - Intel SPR DSA (8086:0b25)
>
> > This approach preserves the ability to pipe the script output into
> > /tools/testing/selftests/vfio/scripts/setup.sh to automate binding the
> > devices to VFIO by excluding the -v arg since the setup script expects
> > a list of BDFs.
>
> Alternatively, -q for quiet? Or:
>
> ./devices.sh | cut -f 1 -d ' ' | setup.sh
>
> Or have setup.h do the cutting? I'm a-ok with a -v, but if the script is mostly
> going to be run by humans (no idea if this is true), it seems like it should use
> the more verbose version by default.
Let's do -q. That makes the default (no arguments) usable by humans.
For scripting, it's easy enough to pass in -q.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/1] vfio: selftests: Find devices that have VFIO selftest drivers
2026-05-08 22:49 ` David Matlack
@ 2026-05-11 16:12 ` Josh Hilke
0 siblings, 0 replies; 8+ messages in thread
From: Josh Hilke @ 2026-05-11 16:12 UTC (permalink / raw)
To: David Matlack
Cc: Sean Christopherson, Alex Williamson, Vipin Sharma,
Raghavendra Rao Ananta, kvm, linux-kernel
On Fri, May 8, 2026 at 3:50 PM David Matlack <dmatlack@google.com> wrote:
>
> On Fri, May 8, 2026 at 3:20 PM Sean Christopherson <seanjc@google.com> wrote:
> >
> > On Fri, May 08, 2026, Josh Hilke wrote:
> > > On Fri, May 8, 2026 at 11:17 AM Sean Christopherson <seanjc@google.com> wrote:
> > > >
> > > > On Tue, Apr 14, 2026, Josh Hilke wrote:
> > > > > +# 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}'
> > > >
> > > > For ignorant people like me, it would be helpful to capture what device was actually
> > > > found. I mean, I don't necessarily know exactly what these devices do, but as the
> > > > list grows, at least having a general sense of what device I'm going to be feeding
> > > > into VFIO would be helpful.
> > > >
> > >
> > > Sure I can do that.
> > >
> > > > # ./devices.sh
> > > > Intel SPR DSA (8086:0b25) Device IDs:
> > > > 0000:6a:01.0
> > > > 0000:6f:01.0
> > > > 0000:74:01.0
> > > > 0000:79:01.0
> > > > 0000:e7:01.0
> > > > 0000:ec:01.0
> > > > 0000:f1:01.0
> > > > 0000:f6:01.0
> > >
> > > How about a "-v" (verbose) option which prints the device name
> > > alongside the BDF?
> > > Works for me.
> >
> > > $ ./list_devices.sh -v
> > > 0000:6a:01.0 Intel SPR DSA (8086:0b25)
> > > 0000:6f:01.0 Intel SPR DSA (8086:0b25)
> >
> > Maybe add a dash to visually separate things? E.g.
> >
> > 0000:6a:01.0 - Intel SPR DSA (8086:0b25)
> >
> > > This approach preserves the ability to pipe the script output into
> > > /tools/testing/selftests/vfio/scripts/setup.sh to automate binding the
> > > devices to VFIO by excluding the -v arg since the setup script expects
> > > a list of BDFs.
> >
> > Alternatively, -q for quiet? Or:
> >
> > ./devices.sh | cut -f 1 -d ' ' | setup.sh
> >
> > Or have setup.h do the cutting? I'm a-ok with a -v, but if the script is mostly
> > going to be run by humans (no idea if this is true), it seems like it should use
> > the more verbose version by default.
>
> Let's do -q. That makes the default (no arguments) usable by humans.
> For scripting, it's easy enough to pass in -q.
-q sounds good to me. Will do in v3.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-05-11 16:12 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-14 23:09 [PATCH v2 0/1] vfio: selftests: Find devices that have VFIO selftest drivers Josh Hilke
2026-04-14 23:09 ` [PATCH v2 1/1] " Josh Hilke
2026-04-16 23:35 ` David Matlack
2026-05-08 18:17 ` Sean Christopherson
2026-05-08 22:03 ` Josh Hilke
2026-05-08 22:20 ` Sean Christopherson
2026-05-08 22:49 ` David Matlack
2026-05-11 16:12 ` Josh Hilke
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox