From nobody Mon Jun 8 05:25:26 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 C18763BC69D for ; Tue, 2 Jun 2026 22:29:47 +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=1780439389; cv=none; b=n5jZ0/7kuk53JKOwA/g6xo8J/REYxNH6ZdEunuWea3+vO28RwNc10BxUwvJo8HShtebCyM/uAsK+OMgi8vyKDoO/aJ5MCmzvBIZM84wkN07lAvUqyi0cpTf06Hvn49AjSCpZ61OAu3esmBxgKi5JEn4Gz+0gQaE0vZFSViyNOIw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780439389; c=relaxed/simple; bh=dnRUvzknQfJJE+Bp2OxCb37758Fx4+OIKGtYTN6MmLo=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=sqNJo2spmavXWVb0lESHx+eHKAdt+wqyOi7pHZZBrxejRYfUrz4x6tZEmFgZxDOccE2IOnGfys06Dw6/X0af9DGTk0oYtS9ok/yBrcUaglcKeIr15haZXkFx/BxE3MZURXzV62wgoqYwgX6HDUbNHuwVrdOQQxKQwe6tRMLyKvc= 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=szeLAsgb; 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="szeLAsgb" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2bf243973c2so34164615ad.1 for ; Tue, 02 Jun 2026 15:29:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780439387; x=1781044187; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=ckZAnXtzekfjja3TFHldWcVuWo0dT7v37hNoLYsawes=; b=szeLAsgbao/t0ZAGzZu52+1fpVzzTi1qyGEXjO8xSl2Y+g8ZpaTpXxKqheCKyLu7Uj du3ZAk2QWfoOz9Di48Z75ZNacHNyUAEvShU4UywEOGLn+aswKlEXxF7YE6vihhatj4Wz BPxIhZGq1msc2u7nXOp7OnqcUEuKOQ5Nlh+B/N5tvsHn79z1LP9b2p2Lxaq5gFeDO/cm 0nPbNiJPyDWtAwWVGLgLBeARbyx5xd5KebjklSlp0Rb7Y0oZ1qOqWHP1ZHJSZ27IRHp+ kqYH8ZtPfDclbwSb111043iggh+ORZgjGj6wGRXGNkOakrJR5zXDYy7GStEl6+8t+hGB kU0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780439387; x=1781044187; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ckZAnXtzekfjja3TFHldWcVuWo0dT7v37hNoLYsawes=; b=YRqFokjtxHpA/+Pvhc6UxaiaVlwc/ny8bB0B7ij8qVp8QNvF2Qi8Wi+8EWbwCFSUtv j+rXQE/4GshJaSQ5Gdzjo/LRKf3/v8Hu8yNAhWf3CdXgf3J6eo9RBDt0ONZReISNjlcV 7fZ4lDfXtwam5qWQapLIZs+m5LIEvNJjhxNG4VxZjH/uLFwEtvVq6F+mKuqrk0xhrRVk vF4rd8P5jeQWR+tlJXsEGygfokvWzmhXSJUKPXyeFMMzFZ2M546XIoRMFr4n8IaFnf0u x9hzfiewlE2pd9xAuKNTc41Jvnlx8J/XeifzvSSWkx5gTrY3oRZD4D2EQz6KlGOf9+fL Ming== X-Forwarded-Encrypted: i=1; AFNElJ8qRvW3hcfEO0QvWVrgrQm3D6aa3tr3WtmEaiPx/qr7I8btghip6Qen9VS8as6f+EM2KyqVAtcRiwd5RnQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwCOghZu1528gGs/bssHjonfNMj5U0IByDvDMNROd33Z8H1RFx/ XmGmXKeJS8zoV2+J5C38yRixRrrLPPIHMBa3LCsJnXFIDul+pn0OyAObrVFemWugyIkvCaKjIgw NQL2Zf6EF X-Received: from plgy12.prod.google.com ([2002:a17:903:22cc:b0:2ba:316c:2d88]) (user=jrhilke job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:17cd:b0:2c0:ce23:d525 with SMTP id d9443c01a7336-2c163d6dd3fmr5663195ad.14.1780439386816; Tue, 02 Jun 2026 15:29:46 -0700 (PDT) Date: Tue, 2 Jun 2026 22:29:41 +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: <20260602222941.3133236-1-jrhilke@google.com> Subject: [PATCH v6] 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_supported_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 passed to tools/testing/selftests/vfio/scripts/setup.sh (e.g. via xargs) to bind the devices to VFIO to use in VFIO selftests. Examples: $ ./list_supported_devices.sh 0000:6a:01.0 - Intel DSA SPR [8086:0b25] 0000:6f:01.0 - Intel DSA SPR [8086:0b25] 0000:74:01.0 - Intel DSA SPR [8086:0b25] $ ./list_supported_devices.sh -q 0000:6a:01.0 0000:6f:01.0 0000:74:01.0 Suggested-by: Sean Christopherson Signed-off-by: Josh Hilke --- Changelog v5 -> v6 - Fix typos in commit message (Sashiko) - Remove unused variable (Sashiko) v5: https://lore.kernel.org/kvm/20260602185615.3025904-1-jrhilke@google.com/ tools/testing/selftests/vfio/Makefile | 1 + .../vfio/scripts/list_supported_devices.sh | 43 +++++++++++++++++++ 2 files changed, 44 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..4a4a2bc41901 --- /dev/null +++ b/tools/testing/selftests/vfio/scripts/list_supported_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. 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 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