From nobody Mon Jun 15 07:33:56 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 AC242358D37 for ; Thu, 9 Apr 2026 01:52:08 +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=1775699529; cv=none; b=cll6yyNdhyatvsAnGdLSaqK9TTNE1UUw97+L3PFv/mgxzGhd2//C2e9ixGKoWTCrt/gC2j1Lkedp+Cm6qvacjJBgN4iQX9HkGk/2I377qK3G9FuxMKKKjx8m7KnaG0fX4NbK2tct79t9sWK5bQmCoVHe0tNVpYKzWg1OATLpKiw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775699529; c=relaxed/simple; bh=jtKPPZnvt3Gt+0Iei3e54HFNPZCPbroXBkkpSBoRqcI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=nLV7SZKQbMD3Yy1/lUx2dz8yUTnIxHn9myggeryWsV7B6D+HGQGtk2U43Kq/V5x8+bcsWdGGrgE3cgNTgUVLK6zhWtHNBcyYa098Dg4BhsfNFnovjGA5eraF2Z/hCHdBmhmcEnoWtopY6+p5a5hJkfOul10dPjia5gWjsMu59sQ= 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=hYePWu9K; 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="hYePWu9K" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2b24af7ca99so7972625ad.1 for ; Wed, 08 Apr 2026 18:52:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775699528; x=1776304328; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Nss7oM9CWAnzGJLKS/17H4jU9Svs2+2Krfue4UO6n9A=; b=hYePWu9KsdRhB6k0XJQxi2gVbJsCJB699XNSxSNmV7Z4MNZRlVDlYglbHdefBWJyhc uwhf8xGM4VjdNDSIVbefGjpIAnYP4YxUiBhSppxz0KBB/hyzYb14wDDlWLouHhm30KWs wzmL5vkiCiJ1lUHF3tWWEiTPmYRNVsAsG9gljupicpJf/eR37Q8L0s/xd1zeHpEUMgJW LuXyMYovlSOh6md0CtxSyj2eReuybGQkkPHCT1eDZ3pbM+EwLYJGTfXfLOY9gGZh89H4 /TYC9wCgUeqA4YOG9dQ+NbkVoSz5qKFfoknGPYSiSmhFltlD//F0X/3gfxx1js7ENmgS 3t8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775699528; x=1776304328; h=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; bh=Nss7oM9CWAnzGJLKS/17H4jU9Svs2+2Krfue4UO6n9A=; b=IFiUZRTbJJNuYdwIr2rThKJymBgYse8s7IHROrzVqy9jYjwTo53YePaS7FLvZYQVqW xTY6tRQ+quUrreIsnn5950sEuhsCvttDraa+tkEZvqXqjO1qnjnx9rdfjEBHJTrcRpMU PxQ5V8qZbPmYrIOjdf2EfV/Wri9Uq+Iy8vkd6K3eZdu5ywQK5WjKxIAuyw6T0n5IN8qr pgrZwC6oA1Ovy9hPSCdfbGe5pUa2B8F+6MTXWhvmBEtv8IyThrcEtjHsEIzmemKtDZLM FkbB2oFSNrFla4IQY0jMr84lqK175dK0HVouHc4wuytzonNtYcOkFN0sAoFbjIC9QGgD YjEg== X-Forwarded-Encrypted: i=1; AJvYcCWNJRkKPNc0g2mQbsiCPPLWmTVaoO8bBdqJtDGxoVltFo0loULFqJfq9NwNVlpfDRMVbhWXXnbQmBBHGTo=@vger.kernel.org X-Gm-Message-State: AOJu0YxBu0Ed/n1vwseSQXzw1QIAl5O7Bv1/0E7OmfyuuUwNlieoGpz1 qaXEGkjFQuZM6AfsWVQ93gww340OBmterF0STmR3DpQkLkMyr7iKMoenA+M40SWfLGfpaXXJmD4 ND6Qm/3k2 X-Received: from plop3.prod.google.com ([2002:a17:902:8a83:b0:2b0:af2d:2502]) (user=jrhilke job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:38c5:b0:2b0:49e6:9622 with SMTP id d9443c01a7336-2b2817ac962mr241069935ad.37.1775699527890; Wed, 08 Apr 2026 18:52:07 -0700 (PDT) Date: Thu, 9 Apr 2026 01:51:38 +0000 In-Reply-To: <20260409015139.2800185-1-jrhilke@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260409015139.2800185-1-jrhilke@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260409015139.2800185-2-jrhilke@google.com> Subject: [PATCH 1/2] vfio: selftests: Find devices that are compatible with VFIO selftests From: Josh Hilke To: Alex Williamson Cc: David Matlack , Vipin Sharma , Raghavendra Rao Ananta , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Josh Hilke Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Update the VFIO selftest setup script to print the segment:bus:device.funct= ion numbers of devices on the user's system that have VFIO selftest drivers (i.= e. are compatible with the VFIO selftest infrastructure). This makes it easy f= or users to quickly find devices that are compatible with VFIO selftests. Example of how to list compatible devices on the system: $ ./tools/testing/selftests/vfio/scripts/setup.sh -l Supported devices: 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 Example of setting up a device: $ ./tools/testing/selftests/vfio/scripts/setup.sh -d 0000:6a:01.0 + echo "0000:6a:01.0" > /sys/bus/pci/drivers/idxd/unbind + echo "vfio-pci" > /sys/bus/pci/devices/0000:6a:01.0/driver_override + echo "0000:6a:01.0" > /sys/bus/pci/drivers/vfio-pci/bind Successfully set up 0000:6a:01.0 This makes the script much more user friendly so that no one has to dig around in the VFIO selftest libraries to figure out which devices can run the selftests. Signed-off-by: Josh Hilke --- tools/testing/selftests/vfio/scripts/setup.sh | 43 +++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/vfio/scripts/setup.sh b/tools/testing/= selftests/vfio/scripts/setup.sh index 49a499e51cbe..2cde07eb9c8b 100755 --- a/tools/testing/selftests/vfio/scripts/setup.sh +++ b/tools/testing/selftests/vfio/scripts/setup.sh @@ -3,18 +3,54 @@ set -e =20 source $(dirname -- "${BASH_SOURCE[0]}")/lib.sh =20 +# List of devices which have a VFIO selftest driver +DEVICES=3D( + "8086:0b25" # Intel Data Streaming Accelerator + "8086:0cf8" # Intel CBDMA +) + +function print_supported_devices() { + local vendor_device_id + local id + + for vendor_device_id in "${DEVICES[@]}"; do + read -r id <<< "${vendor_device_id}" + lspci -D -d "${id}" | awk '{ print $1 }' + done +} + +function usage() { + echo "usage: $0 [-l] [-d ]" >&2 + echo "" >&2 + echo " -l List segment:bus:device.function numbers of supported devices= ." >&2 + echo " -d segment:bus:device.function to set up." >&2 +} + function main() { local device_bdf local device_dir local numvfs local driver + local bdf_list=3D() + + while getopts "ld:" opt; do + case ${opt} in + l) + echo "Supported devices: " + print_supported_devices + exit 0 + ;; + d) bdf_list+=3D("${OPTARG}") ;; + *) usage; exit 1 ;; + esac + done =20 - if [ $# =3D 0 ]; then - echo "usage: $0 segment:bus:device.function ..." >&2 + if [ ${#bdf_list[@]} -eq 0 ]; then + usage exit 1 fi =20 - for device_bdf in "$@"; do + for device_bdf in "${bdf_list[@]}"; do test -d /sys/bus/pci/devices/${device_bdf} =20 device_dir=3D${DEVICES_DIR}/${device_bdf} @@ -42,6 +78,7 @@ function main() { =20 bind ${device_bdf} vfio-pci touch ${device_dir}/vfio-pci + echo "Successfully set up ${device_bdf}" done } =20 --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 07:33:56 2026 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 568E536212F for ; Thu, 9 Apr 2026 01:52:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775699533; cv=none; b=PW2nLscz5SnTzH7YptHHcvmKzTgjLAkidU7AqspCY/SqJw6sVcMyTlPe3nxe3kvGuX+L903WV0m0o5OGVycQdx5qw/RcBNp13tijcrbON+/mNEJxlG3gsFDOwCG0pGAftJ0ItybNg/WyyU3PZx4Kh0vUd+pd76L0oKeUF7Fao7Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775699533; c=relaxed/simple; bh=kYhQPDbaUkfA3PCtDBBPaUGp80LdI+jnzTzjI1ZaiQ4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=hPykMs7CfipDrjUhSjwFR+muUQNJ1xCq3M2J/sTAHOXZuZtEWpEdoDFFv8y1xUzBTAG/MZLg3O+TaFNVGtvWSgQnxMimInen90iG7UXEC6yafbLV+c4POmwPIn6ouc4nHF8D/OpK3KdCKJQJMQx0MRSrO1lweYEwbL5ljlOIZpg= 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=wcJB8rZR; arc=none smtp.client-ip=209.85.216.74 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="wcJB8rZR" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-35da8eb0553so395695a91.1 for ; Wed, 08 Apr 2026 18:52:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775699532; x=1776304332; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=sJJMEh70XMZMR8QUFX5nqErnEJA2I6kW94NqDFWP/AE=; b=wcJB8rZRpYmxySsY1KKbPSr53InPkNGY0Fj1HZJwnFgxoVf+UHWU7rkpJat04p9pBi LxzCywHhkx2o6DO/M+lzY649yyvm3IORR7B4J2W13qESHM4ASNvDiWkVeha3Lhl3JBwu bsI+cfl0vItbL3iSvAERoQgDyO9w8DN6mJtZk5vN4d1yUov2vFGerOcEyW76XU6cYAy6 wk58Ctx9uApofQucBh6nKbeXjLJJUqwplhFelVz+aOg0rsFFnpKzai3+HdmV4I6FaipZ MtSbUvR2l3TDd2hmNAuDb/gATktKVv920rjZCUpX6z5XwVX8fs4zsT7z/p9259YuW1on /HjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775699532; x=1776304332; h=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; bh=sJJMEh70XMZMR8QUFX5nqErnEJA2I6kW94NqDFWP/AE=; b=n0gWVtTwv8vg/m1tMz3dXmP2STakm+V8mkSZv+EfrTN+U4L6CD9+8py3u1ONrs1N9x E/yBROtFdjUMt9I5/gQHKYMxgCvbSE18qLEX2MwI/LoP/Ibtmcez04RJMOiUK0GqDn7T LjrTrefUp/w+fEJd06z7ipIozr6zovHpymKNu/8aWhJspOihFTrqmjuJGG3zeO0HT5H2 g1TGprblB+N1OY1NIzbXa1PFUfSLSluciK+Q4TgamIw8s9pD1GVtCoy3uKmWgHkiB5tT lPSd1PMQFDy5/inP2tyAJzP5ljFmQZdWvXJ/GRnvqx60/IiIYb4HA+Kk+JliYHnmheCL FUCA== X-Forwarded-Encrypted: i=1; AJvYcCWXiiJgfQabFPBZkzFTeLFFSNi+8jrC1hhsurwBQQyqTFJVUvkxQO7zqx21Ll5LInDm15Gtm4gHQFDt6p0=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1BX8hkcqLH27lC6bRkjSXh6OTovsa5b+RA/p36kUc7jQ2LkIH lxLj9cnTfVsPDvMQCY+V7T3Mwk6+nELD8kRnwm7T2H+M/ozng9TK0wcTLowbChxtXlwzM5uCP6m zWWGc5jme X-Received: from pjvc17.prod.google.com ([2002:a17:90a:d911:b0:35d:9ed4:368c]) (user=jrhilke job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:4b89:b0:35b:a44f:b80 with SMTP id 98e67ed59e1d1-35e3539c9abmr1358627a91.1.1775699531508; Wed, 08 Apr 2026 18:52:11 -0700 (PDT) Date: Thu, 9 Apr 2026 01:51:39 +0000 In-Reply-To: <20260409015139.2800185-1-jrhilke@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260409015139.2800185-1-jrhilke@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260409015139.2800185-3-jrhilke@google.com> Subject: [PATCH 2/2] vfio: selftests: Automate setting up devices for testing From: Josh Hilke To: Alex Williamson Cc: David Matlack , Vipin Sharma , Raghavendra Rao Ananta , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Josh Hilke Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Update the VFIO selftest setup script to find a device that has a VFIO self= test driver on the system, and set it up (i.e unbind that device from its driver= , and then bind that device to VFIO). This makes the process of setting up a device to VFIO selftests much easier= , as users don't have to manually figure out which device to use. Though, users= can still manually setup a device by passing the -d argument with a segment:bus:device.function number. Example of automated device setup: $ ./tools/testing/selftests/vfio/scripts/setup.sh./setup.sh + echo "0000:6a:01.0" > /sys/bus/pci/drivers/idxd/unbind + echo "vfio-pci" > /sys/bus/pci/devices/0000:6a:01.0/driver_override + echo "0000:6a:01.0" > /sys/bus/pci/drivers/vfio-pci/bind Successfully set up 0000:6a:01.0 Example of automated device setup where no compatible devices exist: $ . ./tools/testing/selftests/vfio/scripts/setup.sh/setup.sh No available supported devices found on the system. Example of manual device setup: $ ./tools/testing/selftests/vfio/scripts/setup.sh -d 0000:6a:01.0 + echo "0000:6a:01.0" > /sys/bus/pci/drivers/idxd/unbind + echo "vfio-pci" > /sys/bus/pci/devices/0000:6a:01.0/driver_override + echo "0000:6a:01.0" > /sys/bus/pci/drivers/vfio-pci/bind Successfully set up 0000:6a:01.0 Signed-off-by: Josh Hilke --- tools/testing/selftests/vfio/scripts/setup.sh | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/vfio/scripts/setup.sh b/tools/testing/= selftests/vfio/scripts/setup.sh index 2cde07eb9c8b..6d4492b211ea 100755 --- a/tools/testing/selftests/vfio/scripts/setup.sh +++ b/tools/testing/selftests/vfio/scripts/setup.sh @@ -19,11 +19,30 @@ function print_supported_devices() { done } =20 +function pick_device() { + local bdf + + while read -r bdf; do + if [ -n "${bdf}" ]; then + if [ -d "${DEVICES_DIR}/${bdf}" ]; then + echo "${bdf} has already been set up, exiting." >&2 + exit 0 + fi + echo "${bdf}" + return 0 + fi + done <<< "$(print_supported_devices)" + + echo "No available supported devices found on the system." >&2 + exit 1 +} + function usage() { echo "usage: $0 [-l] [-d ]" >&2 echo "" >&2 echo " -l List segment:bus:device.function numbers of supported devices= ." >&2 echo " -d segment:bus:device.function to set up." >&2 + echo " If -d is not specified, a device will be automatically picked= ." >&2 } =20 function main() { @@ -46,8 +65,7 @@ function main() { done =20 if [ ${#bdf_list[@]} -eq 0 ]; then - usage - exit 1 + bdf_list=3D($(pick_device)) fi =20 for device_bdf in "${bdf_list[@]}"; do --=20 2.53.0.1213.gd9a14994de-goog