From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.197 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796144934; b=5f0Rv6MFEawxMmzHS9EHon2ZP629EEHQOsQymjP9da7qk0rVAs4RTiQyIPbk820iymY4 LUk6R61rHptgi/oNdbFa2tr4MnrYrsYYrrJmn9G9KjecYaxRlgbZ+Ht6i1fcPPrZnCqna VdetAdYrfhxaMxkYLZxWb8JVsHW/wF8NMIjdtT+0jiv9CUuRq9B/kc+uwKYLY2tK1YE/j j4IJvFa8iFNOLfSprCDPK9WiAJ5Yo9NNeEdiEyW/dmmXFRbcF2UhsDN7Q1zHF/Rdk7ek5 JnTdgXOE78GARnbyabGXOCXp/qqhkd0uLOwk/SSVZBpH4835jIY+9AnW/1xHE6Hd+0A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796144934; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=ke8rdxIauHTjsJ/c/oIaIGb6OAPdRAwP38D+MFuf0tY=; b=AJjRwD20QKvHhJ5T3/uE5KmvlakhreJir/vDdTDYgGSkDqstRh3TReGG7xWcllskJo9K OijWTi93MWv7Z82VAJIAbZLLD9c3nKkUKOEb7+Tp87Z5dAng+M30Iv+mB1K69DVbNc58S 4CvwNPqzChikA/s/erbPnFoc/BChElOLX5xRlqO3iLBS5ZnPzmu4T9aPwMn/DgJKzLJo7 MNY65DI6TtbIeta+FtW5dX+MoVgY7QmjduGO7G9o+HypcDUCQoNKpkUbqSIHm0lUeLLte Nx99r5IdfbZ94TmsoxoV2b+bBhY0dOAla2TlgKjVXwT6iEqWSs5r8KsIpXSuQ0BVxIg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--jrhilke.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=WFlPy73m; arc=none smtp.remote-ip=209.85.215.197 Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E762606A6A0 for ; Tue, 1 Dec 2026 17:08:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7E762606A6A0 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jrhilke.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=WFlPy73m Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-cdb8c46e240so7168475a12.1 for ; Tue, 01 Dec 2026 09:08:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796144933; x=1796749733; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ke8rdxIauHTjsJ/c/oIaIGb6OAPdRAwP38D+MFuf0tY=; b=WFlPy73m5kWmHOnq30/g0jUh8Oy9vJr/VLclzDvjZzIK91cycw10Pn7/I4dZHCShtU rRfYRJUeKLT0PkYbysJ2uszSy45h4mMyDY8NYRC5BG9ONmPSdCz0p9b9epVDNGBIPcLO cMyg8zKHQOJvzbmExa/Dx+UwvGFPp/1fHdB5a+AquHQ6WVFSZtCYf+Cw+itZavoj+3qo JzvMBQY7/5xvgP9b5N6uiaeWMeosAsrljfMg0AghECu1BXpffwwVa6lZmR0dLAaTIUiU toRzlpkgBXX31ucD3IOjXAn/XZ5OQmmNHSmv3D1+VDd4angxlaYSs97ExRUizL6flwRW FXxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796144933; x=1796749733; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ke8rdxIauHTjsJ/c/oIaIGb6OAPdRAwP38D+MFuf0tY=; b=niqms5RbUCSzWMmxuo9dNaBuT1WLmfWuz9Fuk+2GYjzVMM3caJ/C15hTZdtX28gdJS Kgq2YR3MYUMohZdJ3MvsjXhgB4Par5tNCcuaMb5BIMBrt0FqGL5/cMTfv0P4kt1UcxTe NjGEZ8sTR/38r4Jv8/kWFJ8aublOMsUf3YESlfdnSsaqs59WstYFy5A9r8AIbArg+r7P nF7r5H5uM9e8xCgd6zm6nK6tXhQnQOwI58LlmtSLbuVmTZwwzyGAQ9RhN/O2tzOP2YiC Oc6F9kHKJfXxV6d8W9b1LJ2ZJbH/cnVVLNRUfOUa7VP2S5nW5YVI/o0YP85lhZKyeoTI IF7g== X-Forwarded-Encrypted: i=1; AL+hErGTZNuFiaJGhC1xEP7L/R/c/EVM69gVsCHEvlMkJHISt92PVL5OBAcWg8h3JieC+PcZZaYVIR8wf00J4gE=@vger.kernel.org X-Gm-Message-State: APuU4Z8qQnAyoaKjpQNZ+etu5QccUCc5rnyygYxPfMxhPNFy2s+amcAL jkNiWEc6oI1tmSB46df6VYFaXYYU4eJM8hrODmhzgNv3+na4GMcRiaXLM4WEsGnNh3aAaIBrodh 0oxWZg3Zj X-Received: from pgme8-n2.prod.google.com ([2002:a05:6a02:6c88:20b0:cdd:e359:6c4a]) (user=jrhilke job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:6e04:b0:3fa:f6c0:331a with SMTP id adf61e73a8af0-4014ec3efffmr42664186637.61.1796144932014; Tue, 01 Dec 2026 09:08:52 -0800 (PST) Date: Tue, 1 Dec 2026 17:08:49 +0000 In-Reply-To: <20261201170849.296378-1-jrhilke@google.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261201170849.296378-1-jrhilke@google.com> X-Mailer: git-send-email 2.56.1.839.g22a8290db9-goog Message-ID: <20261201170849.296378-3-jrhilke@google.com> Subject: [PATCH v10 2/2] vfio: selftests: Find devices that have VFIO selftest drivers From: Josh Hilke To: Alex Williamson Cc: Josh Hilke , David Matlack , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson , Vipin Sharma Content-Type: text/plain; charset="UTF-8" Add list_supported_devices.sh to print the PCI addresses, names, selftest driver paths, and current kernel driver bindings of devices on the host that have a VFIO selftest driver. Group the output into sections based on whether vfio-pci is loaded, whether the vfio-pci denylist blocks the device, and whether a GPU requires an architecture check at probe time. Match NVIDIA GPUs by vendor ID and PCI display class, since nv_falcon identifies compatible GPUs by reading BAR0 rather than by PCI device ID. Group them under "Possibly supported", list the valid GPU architectures, and warn that nv_falcon skips MSI tests. Add -q to print only the PCI addresses of usable devices so scripts can consume them or pass them to setup.sh, -a for use with -q to include unusable devices as well, and -h to print usage and exit 0. Print a message to stderr and exit non-zero when no devices are printed. 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. Document list_supported_devices.sh in Documentation/driver-api/vfio-selftests.rst. Example on a host with Intel IOAT, NVIDIA GPU, 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] - lib/drivers/ioat/ioat.c (bound to ioatdma) ... Possibly supported (depends on GPU architecture): 0000:3b:00.0 - NVIDIA GPU [10de:1eb8] - lib/drivers/nv_falcon/nv_falcon.c (unbound) nv_falcon supports Kepler, Maxwell, Pascal, Volta, Turing, Ampere, Ada, and Hopper GPUs. It does not support send_msi() and will skip tests that try to send MSIs. Unusable (available, but denylisted by the kernel): 0000:6a:01.0 - Intel DSA SPR [8086:0b25] - lib/drivers/dsa/dsa.c (bound to idxd) ... To use denylisted devices, load vfio-pci with disable_denylist=Y (or boot the kernel with vfio_pci.disable_denylist=Y). $ ./list_supported_devices.sh -q 0000:00:04.0 ... 0000:3b:00.0 $ ./list_supported_devices.sh -q -a 0000:00:04.0 ... 0000:3b:00.0 0000:6a:01.0 ... Suggested-by: Sean Christopherson Signed-off-by: Josh Hilke --- Documentation/driver-api/vfio-selftests.rst | 16 +- tools/testing/selftests/vfio/Makefile | 1 + .../vfio/scripts/list_supported_devices.sh | 306 ++++++++++++++++++ 3 files changed, 320 insertions(+), 3 deletions(-) create mode 100755 tools/testing/selftests/vfio/scripts/list_supported_devices.sh diff --git a/Documentation/driver-api/vfio-selftests.rst b/Documentation/driver-api/vfio-selftests.rst index cfe7a3a06602..06e1e70f4416 100644 --- a/Documentation/driver-api/vfio-selftests.rst +++ b/Documentation/driver-api/vfio-selftests.rst @@ -31,9 +31,19 @@ Some VFIO selftests require a device with a supported driver implementation in the selftests library (see `Driver Framework`_), while other tests (such as basic PCI configuration space or reset tests) can use any arbitrary PCI device. -This section will be expanded in the future to guide developers on how to find -a device with a supported driver. In the meantime, the selftests library -includes driver support for the following devices: +Run ``list_supported_devices.sh`` to find devices on the host that have a +supported selftest driver: + +.. code-block:: sh + + tools/testing/selftests/vfio/scripts/list_supported_devices.sh + +The script prints each matching device's PCI address, name, selftest driver +path, and current kernel driver binding, grouped by whether the device can be +used with ``vfio-pci``. Pass ``-q`` to print only the PCI addresses of usable +devices, or ``-q -a`` to include unusable devices. + +The selftests library includes driver support for the following devices: - Intel IGB Gigabit Ethernet controllers - Intel IOAT (I/O Acceleration Technology) DMA engines 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..cd4a262d9ec0 --- /dev/null +++ b/tools/testing/selftests/vfio/scripts/list_supported_devices.sh @@ -0,0 +1,306 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later + +source $(dirname -- "${BASH_SOURCE[0]}")/lib.sh + +# Devices that have a driver in tools/testing/selftests/vfio/lib/drivers/. +# Keep in sync with the probe() routines in that directory. 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=( + "8086:0b25,Intel DSA SPR,dsa" + "8086:11fb,Intel DSA GNR-D,dsa" + "8086:1212,Intel DSA DMR,dsa" + "8086:2021,Intel IOAT SKX,ioat" + "8086:10c9,Intel 82576 Gigabit Ethernet Controller,igb" + "15b3:1011,Mellanox Connect-IB,mlx5" + "15b3:1012,Mellanox Connect-IB VF,mlx5" + "15b3:1013,Mellanox ConnectX-4,mlx5" + "15b3:1014,Mellanox ConnectX-4 VF,mlx5" + "15b3:1015,Mellanox ConnectX-4LX,mlx5" + "15b3:1016,Mellanox ConnectX-4LX VF,mlx5" + "15b3:1017,Mellanox ConnectX-5,mlx5" + "15b3:1018,Mellanox ConnectX-5 VF,mlx5" + "15b3:1019,Mellanox ConnectX-5 Ex,mlx5" + "15b3:101a,Mellanox ConnectX-5 Ex VF,mlx5" + "15b3:101b,Mellanox ConnectX-6,mlx5" + "15b3:101c,Mellanox ConnectX-6 VF,mlx5" + "15b3:101d,Mellanox ConnectX-6 Dx,mlx5" + "15b3:101e,Mellanox ConnectX-6 Dx VF,mlx5" + "15b3:101f,Mellanox ConnectX-6 LX,mlx5" + "15b3:1021,Mellanox ConnectX-7,mlx5" + "15b3:1023,Mellanox ConnectX-8,mlx5" + "15b3:1025,Mellanox ConnectX-9,mlx5" + "15b3:1027,Mellanox ConnectX-10,mlx5" + "15b3:2101,Mellanox ConnectX-10 NVLink-C2C,mlx5" + "15b3:a2d2,Mellanox BlueField integrated ConnectX-5,mlx5" + "15b3:a2d3,Mellanox BlueField integrated ConnectX-5 VF,mlx5" + "15b3:a2d6,Mellanox BlueField-2 integrated ConnectX-6 Dx,mlx5" + "15b3:a2dc,Mellanox BlueField-3 integrated ConnectX-7,mlx5" + "15b3:a2df,Mellanox BlueField-4 integrated ConnectX-8,mlx5" +) + +# Devices in DEVICES that are also on the vfio-pci denylist. Keep in sync with +# 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 +readonly PCI_VENDOR_ID_NVIDIA=10de +readonly PCI_BASE_CLASS_DISPLAY=3 + +function is_vfio_pci_loaded() { + [ -d "${VFIO_PCI_DRIVER}" ] +} + +function is_denylisted() { + local id + + for id in "${DENYLIST[@]}"; do + [ "${id}" = "${1}" ] && return 0 + done + + return 1 +} + +function is_denylist_enforced() { + local value + + read -r value 2>/dev/null < "${DISABLE_DENYLIST}" + [ "${value}" != "Y" ] +} + +function is_blocked() { + if ! is_vfio_pci_loaded; then + return 0 + fi + + is_denylisted "${1}" && is_denylist_enforced +} + +function is_nv_gpu() { + local bdf="${1}" + local id="${2}" + local class + + if [[ "${id}" != "${PCI_VENDOR_ID_NVIDIA}:"* ]]; then + return 1 + fi + + read -r class < "/sys/bus/pci/devices/${bdf}/class" + [ $((class >> 16)) -eq ${PCI_BASE_CLASS_DISPLAY} ] +} + +function print_device_name_and_driver() { + local bdf="${1}" + local id="${2}" + local entry + + for entry in "${DEVICES[@]}"; do + if [ "${entry%%,*}" = "${id}" ]; then + echo "${entry#*,}" + return 0 + fi + done + + if is_nv_gpu "${bdf}" "${id}"; then + echo "NVIDIA GPU,nv_falcon" + return 0 + fi + + return 1 +} + +denylisted_devices=() +allowed_devices=() +quiet_devices=() +nv_gpus=() +section_printed="" + +# Print a section header and indented device lines. +# ${1}: Section header text. +# ${2}...: Formatted device lines to print under the header. +# Return 0 if at least one device line was printed. Return 1 otherwise. +function print_section() { + local header="${1}" + local device + + shift + if [ $# -eq 0 ]; then + return 1 + fi + + [ "${section_printed}" ] && echo + section_printed="true" + + echo "${header}" + for device in "$@"; do + echo " ${device}" + done +} + +# Keep in sync with nv_gpu_arch_lookup() in +# tools/testing/selftests/vfio/lib/drivers/nv_falcon/nv_falcon.c. +function print_nv_falcon_note() { + echo + echo " nv_falcon supports Kepler, Maxwell, Pascal, Volta, Turing, Ampere," + echo " Ada, and Hopper GPUs. It does not support send_msi() and will skip" + echo " tests that try to send MSIs." +} + +function print_denylist_note() { + echo + echo " To use denylisted devices, load vfio-pci with disable_denylist=Y" + echo " (or boot the kernel with vfio_pci.disable_denylist=Y)." +} + +function usage() { + cat >&2 <&2 + return 1 + fi +} + +main "$@" -- 2.56.1.839.g22a8290db9-goog