From nobody Mon Jun 8 11:01:52 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 E9ED63F39DF for ; Fri, 29 May 2026 18:04:38 +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=1780077881; cv=none; b=FqpI0r5JeeNL/rPi/+wARAHm7IM7uHgh1tfjI3wN9xRyHS9fVKuqGhhZvsM3J4Xt4gdJs7wXTRQ5Q1QbSyAldLD386rpBr7CoR3iE2+niX5FDjtX/6Z2o+NIreyY2E/AA+rhJqbKygSCBYdIVMa4rfZyrVkQTRk6KPS1wC3N3cM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780077881; c=relaxed/simple; bh=baefiB1t0iOsg8R0RFIXO6GnbNQRrkVh+LFUlTroyys=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=uhUCcyUcr1e67ST52/mX2ENDwwQCgnGv4MSVgYGMLOiMQWUhAD04Em4LvPIcx6uY7JfwUO6llUz+wx3wvjSDt1ViusE9OPkf1cwDEW+jlpqtjAJRCCmuTb3wqlOyHAGV/fLyXaomjwSNd2NXiK0/y5Cqx8Hswrn2XV/ZuPPOAKs= 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=rj3bWXuH; 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="rj3bWXuH" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2bfdd99f6b7so23405ad.0 for ; Fri, 29 May 2026 11:04:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780077878; x=1780682678; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=gfMwsg0HM1yRvKSxiICFP8LN82ljVUFn8UMojuCSS3s=; b=rj3bWXuHpWGGT0kmRHGMLMcoCOjt8A8UrtzZYugiObR8kXgfRd7gtmqh06Z20IFhT2 oj7xOdA1HF2/P4rIwXBPMOM6ULWfZvjp9B8F5QzhxmnZ7McIkVFP2xUTOORM7689ntXt /Z2wFRFBA76YUdenPHsHSCTUCmXkGOgczeESWT80VDyWTodgL01IUUlBGvVqiJhxmVvL vMorxaWLfLyjLbSN4PLtaUcJYByjw148/9aYp0Y9Tm6dNcQZThpOdWf8WRtdezDjbigm IOhjAvdU8IB5mEk9VZxNHtkUfrOw0ZTRJLOFzGvAGOt3jS9vHnSu1GCgtoO+O1DShFmg rOfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780077878; x=1780682678; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=gfMwsg0HM1yRvKSxiICFP8LN82ljVUFn8UMojuCSS3s=; b=PhjWZNs6uy/7ygLqPp9hr9Iv2cGuAFkLS41Vqk/EDyVXRMddBW1jjmDdfyz/hvuCfO X5e/PjFJgqLG48W0TWuozBg87czbqAZSCAXQ3ovKBc7BfntI0nmm2W94PHK7uyd/drFP 7xbhMXlf0LEubtzVUefrQXaoPuuHwusTXFlUOXYtC2V/m3Qru3+LqzU9R88pXJomZiiW bWWLuEF3dxDJ1rYWjk0EbaN4NdLZD4ZgOe2olUTF2bBjKK8Ey4Hi0EniJDpx+8WHpaIf zJ9D5paUnRR6m0JSlm0wEj43UyV0qXI97TmWwHVzh1IvO5HKgvXDQ5v6H4RSmueBpbh9 95fA== X-Forwarded-Encrypted: i=1; AFNElJ/NKZXiouAC7dAuUdZe1jT1yN3FXItF8kWHWemFCTtZOdBu9jRxLKnGFUnBWanGp1HPXJx6M6d0p8dAeaM=@vger.kernel.org X-Gm-Message-State: AOJu0Yx7LnPVXT39LAXbJI0q7kygavSEnuRHTbQjDXgXIG55/fmpRC2G /q9Yl13d8JSyUkma35ofWAoGQqr3eqtmy5qFWmZqiouXw8AewqUhn96uz6McJVCoH48MANdgE6I cGXpDEh2u X-Received: from pgbdr23.prod.google.com ([2002:a05:6a02:fd7:b0:c79:8315:4734]) (user=jrhilke job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:1b4d:b0:2bf:2015:5b93 with SMTP id d9443c01a7336-2bf367d9879mr12357865ad.11.1780077877896; Fri, 29 May 2026 11:04:37 -0700 (PDT) Date: Fri, 29 May 2026 18:04:25 +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.929.g9b7fa37559-goog Message-ID: <20260529180425.4162392-1-jrhilke@google.com> Subject: [PATCH v4] vfio: selftests: Find devices that have VFIO selftest drivers From: Josh Hilke To: Alex Williamson , David Matlack 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 v3 -> v4: - Move argument parsing into main() (David) - Use empty string for false in quiet flag (David) - Simplify logic to print device names and IDs (David) tools/testing/selftests/vfio/Makefile | 1 + .../selftests/vfio/scripts/list_devices.sh | 43 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100755 tools/testing/selftests/vfio/scripts/list_devices.sh diff --git a/tools/testing/selftests/vfio/Makefile b/tools/testing/selftest= s/vfio/Makefile index 0684932d91bf..777f91f09057 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_devices.sh TEST_FILES +=3D scripts/run.sh TEST_FILES +=3D scripts/setup.sh =20 diff --git a/tools/testing/selftests/vfio/scripts/list_devices.sh b/tools/t= esting/selftests/vfio/scripts/list_devices.sh new file mode 100755 index 000000000000..249532f15570 --- /dev/null +++ b/tools/testing/selftests/vfio/scripts/list_devices.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later + +# List of devices which have a VFIO selftest driver +readonly DEVICES=3D( + "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 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.929.g9b7fa37559-goog