From: "David Matlack" <dmatlack@google.com>
To: "Josh Hilke" <jrhilke@google.com>, "Alex Williamson" <alex@shazbot.org>
Cc: "David Matlack" <dmatlack@google.com>, <kvm@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
"Sean Christopherson" <seanjc@google.com>,
"Vipin Sharma" <vipinsh@google.com>
Subject: Re: [PATCH v9] vfio: selftests: Find devices that have VFIO selftest drivers
Date: Wed, 25 Nov 2026 11:12:53 -0800 [thread overview]
Message-ID: <DN4J4BQK3N90.2WVQBRV6SRNXF@google.com> (raw)
In-Reply-To: <20261120012553.3745742-1-jrhilke@google.com>
On Thu Nov 19, 2026 at 5:25 PM PST, Josh Hilke wrote:
> 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.
Feeding the output straight into setup.sh worries me a bit. -q prints
every matching device, including ones the host is actively using, e.g.
the ConnectX NIC carrying the host's network connection or the GPU
driving the display. And once the NVMe driver lands, that could include
the boot disk. setup.sh will happily unbind all of them.
I don't think list_supported_devices.sh should try to filter these out,
but it should at least show the user what each device is currently bound
to (see below). The real protection belongs in setup.sh, since that's
the script that actually unbinds devices, regardless of how the user
picked the BDF. Please add a patch before this one that makes setup.sh
refuse to set up a device that is bound to a driver (other than
vfio-pci) unless -f is passed, e.g.
$ ./setup.sh 0000:00:04.0
0000:00:04.0 is bound to ioatdma, pass -f to unbind it.
Devices that are unbound or already bound to vfio-pci should not
require -f.
[...]
> +# Devices that have a driver in selftests/vfio/lib/drivers. NVIDIA GPUs are
> +# matched separately in is_nv_gpu() because nv_falcon_probe() matches on
> +# vendor, PCI class, and PMC_BOOT_0 rather than PCI device ID.
> +readonly DEVICES=(
Please add a comment that this list must be kept in sync with the probe()
routines in lib/drivers/, similar to what you did for
print_nv_falcon_note(). Otherwise the next device ID added to e.g.
mlx5.c is going to get missed here.
> +# 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.
Same here, s/The denylist is in/Keep in sync with/.
[...]
> +function print_denylist_note() {
> + echo
> + echo " To use denylisted devices, load vfio-pci with disable_denylist=1"
> + echo " (or boot the kernel with vfio_pci.disable_denylist=1)."
> +}
The script checks for "Y" when reading disable_denylist, so please use
disable_denylist=Y here too, to keep things consistent.
[...]
> + while getopts "qa" opt; do
> + case "${opt}" in
> + q) quiet="true" ;;
> + a) all="true" ;;
> + \?) usage ;;
> + esac
> + done
Please add a -h option to print the usage. Right now -h works by
accident, but getopts prints a confusing "illegal option -- h" first.
-h should also exit 0, since asking for help isn't an error.
[...]
> + IFS=',' read -r name driver <<< "${entry}"
> + line="${bdf} - ${name} [${id}] - lib/drivers/${driver}/${driver}.c"
Please also print the kernel driver the device is currently bound to (if
any), so users can see at a glance which devices are in use by the host
before handing them to setup.sh. e.g.
Supported:
0000:00:04.0 - Intel IOAT SKX [8086:2021] - lib/drivers/ioat/ioat.c (bound to ioatdma)
0000:00:04.1 - Intel IOAT SKX [8086:2021] - lib/drivers/ioat/ioat.c (bound to vfio-pci)
0000:00:04.2 - Intel IOAT SKX [8086:2021] - lib/drivers/ioat/ioat.c (unbound)
Please source lib.sh and use get_driver() for this rather than
open-coding it, like the other scripts do.
Note that "driver" is already used in this script to refer to the
selftest driver, so you'll want a different name for the kernel driver
variable.
[...]
> + if [ -z "${printed}" ]; then
> + echo "No devices with a VFIO selftest driver found." >&2
> + fi
> +}
Please print this with -q as well, since the message goes to stderr
anyway and won't get mixed in with the BDFs. Right now -q silently
prints nothing, e.g. when vfio-pci isn't loaded, which leaves the user
guessing.
And in both cases the script should exit with a non-zero status when it
doesn't find any devices, so callers can tell the difference. This
should include the case where devices are found but none of them are
usable (e.g. -q without -a when vfio-pci isn't loaded or the devices
are all denylisted), since -q prints nothing in that case either.
Lastly, please update Documentation/driver-api/vfio-selftests.rst. The
"Picking a Device" section says it "will be expanded in the future to
guide developers on how to find a device with a supported driver", which
is exactly what this script does. Please describe the script there, and
update the "Setting up Devices" section to cover the new -f option for
setup.sh.
prev parent reply other threads:[~2026-11-25 19:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 1:25 Josh Hilke
2026-11-20 18:14 ` Sean Christopherson
2026-11-25 19:12 ` David Matlack [this message]
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=DN4J4BQK3N90.2WVQBRV6SRNXF@google.com \
--to=dmatlack@google.com \
--cc=alex@shazbot.org \
--cc=jrhilke@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
all inboxes | Powered by JetHome®