From nobody Mon Jun 8 05:25:45 2026 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4CBC9313E0D for ; Tue, 2 Jun 2026 18:56:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780426589; cv=none; b=YN5+c1NeUebCgNB3Jbhuflr9bpi2Oxwm/28SoWRClgnxWsSnrViLjBDv3TfyeLfcv8RNyLG0uRdQq0Il5pkMnfZ7gYF6VPj1zm1TRkBnzWMQghym1rfwAwnelM2mSSXhJoF14/ZhARRlSCcTdaeY/ERsTyW4Ao3MOYrCv+wKYxM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780426589; c=relaxed/simple; bh=E8w6Hz0xZamuR+smlCJOyD76fZd8G+FCNZET93Yp94I=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=Lyco7WgSCLHe60ZrWgAdIurYi3SdJ6YanY8EPrMMRovAhqU2FiCnrPzORxNzvSdeTgmeztaMRd4wBGMQFGZvoCWD/aJ8snlUABGTZx3b/3D00geWG6tgI/kLz/IswnEJA3JDaxplVflzvci4pNSbFATLiFWnNOaDlPbiNb/WciM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jrhilke.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ojPMf/Nn; arc=none smtp.client-ip=209.85.214.201 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.b="ojPMf/Nn" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2bfdd99f6b7so61041075ad.0 for ; Tue, 02 Jun 2026 11:56:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780426586; x=1781031386; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=QzjpyP+aPhJKXse7RVA87aGxxV6wdLJmQoPrCJnMTkw=; b=ojPMf/NnB4du6Gu+FDDmM7J/OM2aSB4H9MBxLUcm+UDpBUd0yEP9VGNTieGkb5IlCn uScp3DGI7UbQstgFs8KGuHfeE6tHYd6lMiguf+4Lwguq8HF5THRRibwl5ek/atF7c0e+ kNPZDLdxrumwSFZL74T7BkYTI1mlORhJEGEqadEXOv/4WkkbUQS2wkvGayDupF5csaHv baKFLBJ1QFzHoJkjBg4GkLGT+/81UDJAxSyEyxTxfh+bmus95G3YDdulcq/FzL/SktmR lwmNGwkV+So+cSwWYbwF8euK4mOvJkuLC7F8XCAJ1ogMSukzzH5M/ESTXwhZeH7N+hwQ e94A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780426586; x=1781031386; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=QzjpyP+aPhJKXse7RVA87aGxxV6wdLJmQoPrCJnMTkw=; b=QwJ0jnbW1SQgVHXMENMUD9W6HJTxfaLyVuVa/ZgJY5ldFIdI5tdI7xTIIjvClDkNz/ 6qTMhrCBSNgBvyzf0l1cgCFv/Z2MleACNovUoaCxPb2ol6fZcvC8yZh2wXvwK7WyNwmX TrMpyWHr6A/wxcb0bn+nhBVlWwTZ0/E3Q9jTFe2dGU/DUwkbJArQ0Gre//SANBToAU8G ONfD+7DYD6CjZfqvihzhnUMSYtF6evjAgiDvVwzEXW7lR5xHlEqyvVMHSzSHXF+WtvHw 3eo5ZZKHqDo7X1RnzKguOykhx/tg1wR5Fa8XM3ZeFaVh2A2qyxRV/Y/mjGMUJNrO5sbf CViw== X-Forwarded-Encrypted: i=1; AFNElJ99GNWNNrPBzrRw3HjsLLa71uSCdotZu/3msx9W36Ru0iQ5G36WN5cGY6XmgJqMO9NOX6g7HIGIBHMnAjQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzM0/4eV6IYzWtqtRE63Zl/HSQTagmONgxReH+pOftYybeVzlnc Grhkmqy7POimpwyIxNpzgZsFyHflDTHpk2UUUyTAXyUPLe3SQgmCXG6j6lWzkJXI1dF81pVljuu 7Nb54aQiA X-Received: from plqs2.prod.google.com ([2002:a17:902:a502:b0:2bf:17b5:30c9]) (user=jrhilke job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:38c3:b0:2bf:2188:a90f with SMTP id d9443c01a7336-2c1644a02a1mr259875ad.32.1780426586321; Tue, 02 Jun 2026 11:56:26 -0700 (PDT) Date: Tue, 2 Jun 2026 18:56:15 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.54.0.1013.g208068f2d8-goog Message-ID: <20260602185615.3025904-1-jrhilke@google.com> Subject: [PATCH v5] vfio: selftests: Find devices that have VFIO selftest drivers From: Josh Hilke To: David Matlack , Alex Williamson Cc: Sean Christopherson , Vipin Sharma , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Josh Hilke Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a new script, list_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. Includes a -q (quiet) argument which prints just the SBDFs so that the output can be piped into tools/testing/selftests/vfio/script/setup.sh to bind the devices to VFIO to use in VFIO selftests. Examples: $ ./list_devices.sh 0000:6a:01.0 - Intel SPR DSA (8086:0b25) 0000:6f:01.0 - Intel SPR DSA (8086:0b25) 0000:74:01.0 - Intel SPR DSA (8086:0b25) 0000:79:01.0 - Intel SPR DSA (8086:0b25) 0000:e7:01.0 - Intel SPR DSA (8086:0b25) 0000:ec:01.0 - Intel SPR DSA (8086:0b25) 0000:f1:01.0 - Intel SPR DSA (8086:0b25) 0000:f6:01.0 - Intel SPR DSA (8086:0b25) $ ./list_devices.sh -q 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 Suggested-by: Sean Christopherson Signed-off-by: Josh Hilke --- Changelog v4 -> v5 - Rename list_devices.sh to list_supported_devices.sh (Vipin) - Document the source of supported device names/IDs (Vipin) - Align the output format with `lspci` (Vipin)=20 - Fix errors in device names and IDs (Vipin) v4: https://lore.kernel.org/kvm/20260529180425.4162392-1-jrhilke@google.com/ tools/testing/selftests/vfio/Makefile | 1 + .../vfio/scripts/list_supported_devices.sh | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100755 tools/testing/selftests/vfio/scripts/list_supported_dev= ices.sh diff --git a/tools/testing/selftests/vfio/Makefile b/tools/testing/selftest= s/vfio/Makefile index 0684932d91bf..127e70b996a9 100644 --- a/tools/testing/selftests/vfio/Makefile +++ b/tools/testing/selftests/vfio/Makefile @@ -15,6 +15,7 @@ TEST_GEN_PROGS +=3D vfio_pci_driver_test =20 TEST_FILES +=3D scripts/cleanup.sh TEST_FILES +=3D scripts/lib.sh +TEST_FILES +=3D scripts/list_supported_devices.sh TEST_FILES +=3D scripts/run.sh TEST_FILES +=3D scripts/setup.sh =20 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..a123a965d358 --- /dev/null +++ b/tools/testing/selftests/vfio/scripts/list_supported_devices.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later + +# List of devices which have a VFIO selftest driver. Device IDs are found = in the +# drivers in selftests/vfio/lib/drivers. +readonly DEVICES=3D( + "8086:0b25,Intel DSA SPR" + "8086:11fb,Intel DSA GNR-D" + "8086:1212,Intel DSA DMR" + "8086:2021,Intel IOAT SKX" +) + +# Print the segment:bus:device.function numbers of PCI devices that can be= used +# to run VFIO selftests. +function main() { + local id_name + local quiet=3D"" + local name + local bdfs + local bdf + local id + + while getopts "q" opt; do + case $opt in + q) quiet=3D"true" ;; + \?) echo "Usage: $0 [-q]" >&2; exit 1 ;; + esac + done + + for id_name in "${DEVICES[@]}"; do + IFS=3D',' read -r id name <<< "$id_name" + bdfs=3D$(lspci -D -d "${id}" | awk '{print $1}') + + [[ -z $bdfs ]] && continue + + if [ "$quiet" ]; then + echo "${bdfs}" + else + echo "${bdfs}" | sed "s|$| - ${name} [${id}]|" + fi + done +} + +main "$@" --=20 2.54.0.1013.g208068f2d8-goog