Re: [PATCH v2 00/30] vfio: Introduce selftests for VFIO

2025-08-27 Thread David Matlack
On Wed, Aug 27, 2025 at 11:55 AM Alex Williamson wrote: > > On Fri, 22 Aug 2025 21:24:47 +0000 > David Matlack wrote: > > > This series introduces VFIO selftests, located in > > tools/testing/selftests/vfio/. > > > > VFIO selftests aim to enable kernel develo

[PATCH v2 28/30] vfio: selftests: Add iommufd mode

2025-08-22 Thread David Matlack
Add a new IOMMU mode for using iommufd directly. In this mode userspace opens /dev/iommu and binds it to a device FD acquired through /dev/vfio/devices/vfioX. Acked-by: Shuah Khan Signed-off-by: David Matlack --- .../selftests/vfio/lib/include/vfio_util.h| 6 +- .../selftests/vfio/lib

[PATCH v2 25/30] vfio: selftests: Replicate tests across all iommu_modes

2025-08-22 Thread David Matlack
: David Matlack --- .../selftests/vfio/lib/include/vfio_util.h| 8 +++ .../selftests/vfio/lib/vfio_pci_device.c | 1 + .../selftests/vfio/vfio_dma_mapping_test.c| 24 +-- .../selftests/vfio/vfio_pci_driver_test.c | 13 +- 4 files changed, 32 insertions

[PATCH v2 22/30] vfio: selftests: Add driver for Intel DSA

2025-08-22 Thread David Matlack
plenty to stress test VFIO and the IOMMU. The driver does not yet support requesting interrupt handles, as this commit was not tested against hardware that requires it. Cc: Vinicius Costa Gomes Cc: Dave Jiang Acked-by: Vinicius Costa Gomes Acked-by: Shuah Khan Signed-off-by: David Matlack

[PATCH v2 26/30] vfio: selftests: Add vfio_type1v2_mode

2025-08-22 Thread David Matlack
Add a new IOMMU mode for using VFIO_TYPE1v2_IOMMU. Acked-by: Shuah Khan Signed-off-by: David Matlack --- tools/testing/selftests/vfio/lib/include/vfio_util.h | 3 ++- tools/testing/selftests/vfio/lib/vfio_pci_device.c | 5 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a

[PATCH v2 20/30] tools headers: Import iosubmit_cmds512()

2025-08-22 Thread David Matlack
made when importing: None Acked-by: Vinicius Costa Gomes Acked-by: Shuah Khan Signed-off-by: David Matlack --- tools/arch/x86/include/asm/io.h| 26 + tools/arch/x86/include/asm/special_insns.h | 27 ++ 2 files changed, 53 insertions(+) create

[PATCH v2 15/30] tools headers: Import asm-generic MMIO helpers

2025-08-22 Thread David Matlack
: David Matlack --- tools/include/asm-generic/io.h | 482 + tools/include/asm/io.h | 7 + tools/include/linux/io.h | 4 +- 3 files changed, 492 insertions(+), 1 deletion(-) create mode 100644 tools/include/asm-generic/io.h create mode 100644 tools

[PATCH v2 30/30] vfio: selftests: Add a script to help with running VFIO selftests

2025-08-22 Thread David Matlack
then cleanup all the devices. Acked-by: Shuah Khan Signed-off-by: David Matlack --- tools/testing/selftests/vfio/Makefile | 1 + tools/testing/selftests/vfio/run.sh | 109 ++ 2 files changed, 110 insertions(+) create mode 100755 tools/testing/selftests/vfio/run.sh

[PATCH v2 29/30] vfio: selftests: Make iommufd the default iommu_mode

2025-08-22 Thread David Matlack
Now that VFIO selftests support iommufd, make it the default mode. IOMMUFD is the successor to VFIO_TYPE1{,v2}_IOMMU and all new features are being added there, so it's a slightly better fit as the default mode. Acked-by: Shuah Khan Signed-off-by: David Matlack --- tools/testing/selftests

[PATCH v2 24/30] vfio: selftests: Encapsulate IOMMU mode

2025-08-22 Thread David Matlack
Encapsulate the "IOMMU mode" a test should use behind a new struct. In the future this will be used to support other types of IOMMUs besides VFIO_TYPE1_IOMMU, and allow users to select the mode on the command line. No functional change intended. Acked-by: Shuah Khan Signed-off-by: Dav

[PATCH v2 11/30] vfio: selftests: Add a helper for matching vendor+device IDs

2025-08-22 Thread David Matlack
Add a helper function for matching a device against a given vendor and device ID. This will be used in a subsequent commit to match devices against drivers. Acked-by: Shuah Khan Signed-off-by: David Matlack --- tools/testing/selftests/vfio/lib/include/vfio_util.h | 7 +++ tools/testing

[PATCH v2 27/30] vfio: selftests: Add iommufd_compat_type1{,v2} modes

2025-08-22 Thread David Matlack
transparently. Acked-by: Shuah Khan Signed-off-by: David Matlack --- tools/testing/selftests/vfio/lib/include/vfio_util.h | 4 +++- tools/testing/selftests/vfio/lib/vfio_pci_device.c | 10 ++ tools/testing/selftests/vfio/vfio_dma_mapping_test.c | 12 ++-- 3 files changed, 23

[PATCH v2 19/30] vfio: selftests: Add driver for Intel CBDMA

2025-08-22 Thread David Matlack
acros (e.g. IOAT_CHANCMD_RESET) and struct ioat_dma_descriptor. Cc: Dave Jiang Cc: Dan Williams Acked-by: Dave Jiang Acked-by: Shuah Khan Signed-off-by: David Matlack --- .../selftests/vfio/lib/drivers/ioat/hw.h | 1 + .../selftests/vfio/lib/drivers/ioat/ioat.c| 235 ++

[PATCH v2 18/30] dmaengine: ioat: Move system_has_dca_enabled() to dma.h

2025-08-22 Thread David Matlack
: Dave Jiang Acked-by: Shuah Khan Signed-off-by: David Matlack --- drivers/dma/ioat/dma.h | 2 ++ drivers/dma/ioat/hw.h | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/dma/ioat/dma.h b/drivers/dma/ioat/dma.h index a180171087a8..12a4a4860a74 100644 --- a/drivers/dma

[PATCH v2 17/30] tools headers: Add symlink to linux/pci_ids.h

2025-08-22 Thread David Matlack
Add a symlink to include/linux/pci_ids.h to tools/include/. This will be used by VFIO selftests in subsequent commits to match device and vendor IDs. Acked-by: Shuah Khan Signed-off-by: David Matlack --- tools/include/linux/pci_ids.h | 1 + 1 file changed, 1 insertion(+) create mode 12

[PATCH v2 16/30] tools headers: Import x86 MMIO helper overrides

2025-08-22 Thread David Matlack
Import the x86-specific overrides for from the kernel headers into tools/include/. Changes made when importing: - Replace CONFIG_X86_64 with __x86_64__. Acked-by: Shuah Khan Signed-off-by: David Matlack --- tools/arch/x86/include/asm/io.h | 75 + tools

[PATCH v2 23/30] vfio: selftests: Move helper to get cdev path to libvfio

2025-08-22 Thread David Matlack
Move the helper function to get the VFIO cdev path to libvfio so that it can be used in libvfio in a subsequent commit. No functional change intended. Acked-by: Shuah Khan Signed-off-by: David Matlack --- .../selftests/vfio/lib/include/vfio_util.h| 1 + .../selftests/vfio/lib

[PATCH v2 14/30] tools headers: Add stub definition for __iomem

2025-08-22 Thread David Matlack
Add an empty definition for __iomem so that kernel headers that use __iomem can be imported into tools/include/ with less modifications. Acked-by: Shuah Khan Signed-off-by: David Matlack --- tools/include/linux/compiler.h | 4 1 file changed, 4 insertions(+) diff --git a/tools/include

[PATCH v2 21/30] dmaengine: idxd: Allow registers.h to be included from tools/

2025-08-22 Thread David Matlack
: Vinicius Costa Gomes Acked-by: Shuah Khan Signed-off-by: David Matlack --- drivers/dma/idxd/registers.h | 4 1 file changed, 4 insertions(+) diff --git a/drivers/dma/idxd/registers.h b/drivers/dma/idxd/registers.h index 9c1c546fe443..02bab136385e 100644 --- a/drivers/dma/idxd/registers.h

[PATCH v2 13/30] vfio: sefltests: Add vfio_pci_driver_test

2025-08-22 Thread David Matlack
Add a new selftest that tests all driver operations. This test serves both as a demonstration of the driver framework, and also as a correctness test for future drivers. Acked-by: Shuah Khan Signed-off-by: David Matlack --- tools/testing/selftests/vfio/Makefile | 1 + .../selftests

[PATCH v2 09/30] vfio: selftests: Keep track of DMA regions mapped into the device

2025-08-22 Thread David Matlack
are then used by drivers. Acked-by: Shuah Khan Signed-off-by: David Matlack --- .../selftests/vfio/lib/include/vfio_util.h| 23 +++-- .../selftests/vfio/lib/vfio_pci_device.c | 49 --- .../selftests/vfio/vfio_dma_mapping_test.c| 31 ++-- 3 files changed

[PATCH v2 12/30] vfio: selftests: Add driver framework

2025-08-22 Thread David Matlack
commits will introduce drivers for specific devices. Acked-by: Shuah Khan Signed-off-by: David Matlack --- .../selftests/vfio/lib/include/vfio_util.h| 92 ++ tools/testing/selftests/vfio/lib/libvfio.mk | 1 + .../selftests/vfio/lib/vfio_pci_device.c | 5

[PATCH v2 10/30] vfio: selftests: Enable asserting MSI eventfds not firing

2025-08-22 Thread David Matlack
Make it possible to assert that a given MSI eventfd did _not_ fire by adding a helper to mark an eventfd non-blocking. Demonstrate this in vfio_pci_device_test by asserting the MSI eventfd did not fire before vfio_pci_irq_trigger(). Acked-by: Shuah Khan Signed-off-by: David Matlack --- tools

[PATCH v2 08/30] vfio: selftests: Validate 2M/1G HugeTLB are mapped as 2M/1G in IOMMU

2025-08-22 Thread David Matlack
skipped if that directory is not available (i.e. non-Intel IOMMUs). Signed-off-by: Josh Hilke [reword commit message, refactor code] Acked-by: Shuah Khan Signed-off-by: David Matlack --- .../selftests/vfio/vfio_dma_mapping_test.c| 111 ++ 1 file changed, 111 insertions(+) diff

[PATCH v2 07/30] vfio: selftests: Add DMA mapping tests for 2M and 1G HugeTLB

2025-08-22 Thread David Matlack
Khan Signed-off-by: David Matlack --- .../selftests/vfio/vfio_dma_mapping_test.c| 38 --- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/vfio/vfio_dma_mapping_test.c b/tools/testing/selftests/vfio/vfio_dma_mapping_test.c index b56cebb

[PATCH v2 06/30] vfio: selftests: Add test to reset vfio device.

2025-08-22 Thread David Matlack
From: Josh Hilke Add a test to vfio_pci_device_test which resets the device. If reset is not supported by the device, the test is skipped. Signed-off-by: Josh Hilke Acked-by: Shuah Khan Signed-off-by: David Matlack --- tools/testing/selftests/vfio/lib/include/vfio_util.h | 1 + tools

[PATCH v2 05/30] vfio: selftests: Move vfio dma mapping test to their own file

2025-08-22 Thread David Matlack
-off-by: Josh Hilke Acked-by: Shuah Khan Signed-off-by: David Matlack --- tools/testing/selftests/vfio/Makefile | 1 + .../selftests/vfio/vfio_dma_mapping_test.c| 51 +++ .../selftests/vfio/vfio_pci_device_test.c | 18 --- 3 files changed, 52 insertions(+), 18

[PATCH v2 04/30] vfio: selftests: Test basic VFIO and IOMMUFD integration

2025-08-22 Thread David Matlack
From: Josh Hilke Add a vfio test suite which verifies that userspace can bind and unbind devices, allocate I/O address space, and attach a device to an IOMMU domain using the cdev + IOMMUfd VFIO interface. Signed-off-by: Josh Hilke Acked-by: Shuah Khan Signed-off-by: David Matlack --- tools

[PATCH v2 03/30] vfio: selftests: Introduce vfio_pci_device_test

2025-08-22 Thread David Matlack
MSI-x - Reading and writing to PCI config space This test should work with most PCI devices, as long as they are bound to vfio-pci. Acked-by: Shuah Khan Signed-off-by: David Matlack --- tools/testing/selftests/vfio/Makefile | 1 + .../selftests/vfio/vfio_pci_device_test.c | 180

[PATCH v2 01/30] selftests: Create tools/testing/selftests/vfio

2025-08-22 Thread David Matlack
Create the directory tools/testing/selftests/vfio with a stub Makefile and hook it up to the top-level selftests Makefile. This directory will be used in subsequent commits to host selftests for the VFIO subsystem. Acked-by: Shuah Khan Signed-off-by: David Matlack --- MAINTAINERS

[PATCH v2 02/30] vfio: selftests: Add a helper library for VFIO selftests

2025-08-22 Thread David Matlack
subsequent commit. Acked-by: Shuah Khan Signed-off-by: David Matlack --- tools/testing/selftests/vfio/Makefile | 14 + .../selftests/vfio/lib/include/vfio_util.h| 140 +++ tools/testing/selftests/vfio/lib/libvfio.mk | 15 + .../selftests/vfio/lib/vfio_pci_device.c | 365

[PATCH v2 00/30] vfio: Introduce selftests for VFIO

2025-08-22 Thread David Matlack
50404193923.1413163-68-sea...@google.com/ [3] https://lore.kernel.org/kvm/20250620232031.2705638-32-dmatl...@google.com/ David Matlack (25): selftests: Create tools/testing/selftests/vfio vfio: selftests: Add a helper library for VFIO selftests vfio: selftests: Introduce vfio_pci_device_test

Re: [PATCH 00/33] vfio: Introduce selftests for VFIO

2025-08-21 Thread David Matlack
On Thu, Aug 21, 2025 at 1:10 PM Alex Williamson wrote: > > I think we have all the required acks now and reviews just suggest some > minor patch shuffling, right?. You were also going to switch from > reviewer to maintainer of the selftests in MAINTAINERS ;) > > Are you planning to collect those

Re: [PATCH 00/33] vfio: Introduce selftests for VFIO

2025-08-19 Thread David Matlack
On Tue, Aug 12, 2025 at 8:04 AM David Matlack wrote: > > On 2025-08-05 05:08 PM, Joel Granados wrote: > > On Fri, Jun 20, 2025 at 11:19:58PM +, David Matlack wrote: > > > This series introduces VFIO selftests, located in > > > tools/testing/selftests/vfio/. &g

Re: [PATCH 22/33] vfio: selftests: Add driver for Intel DSA

2025-08-19 Thread David Matlack
On Mon, Aug 18, 2025 at 4:41 PM Vinicius Costa Gomes wrote: > David Matlack writes: > > + > > +static int dsa_probe(struct vfio_pci_device *device) > > +{ > > + if (!vfio_pci_device_match(device, PCI_VENDOR_ID_INTEL, > > +

Re: [PATCH 12/33] tools headers: Import iosubmit_cmds512()

2025-08-18 Thread David Matlack
On Mon, Aug 18, 2025 at 4:25 PM Vinicius Costa Gomes wrote: > > David Matlack writes: > > > Import iosubmit_cmds512() from arch/x86/include/asm/io.h into tools/ so > > it can be used by VFIO selftests to interact with Intel DSA devices. > > > > minor: perhaps m

Re: [PATCH 00/33] vfio: Introduce selftests for VFIO

2025-08-18 Thread David Matlack
On Mon, Aug 18, 2025 at 12:37 PM Alex Williamson wrote: > > On Mon, 18 Aug 2025 11:59:39 -0700 > David Matlack wrote: > > > On Thu, Jul 31, 2025 at 1:55 PM David Matlack wrote: > > > > > > On Tue, Jul 29, 2025 at 3:26 PM Jason Gunthorpe wrote: > > >

Re: [PATCH 00/33] vfio: Introduce selftests for VFIO

2025-08-18 Thread David Matlack
On Thu, Jul 31, 2025 at 1:55 PM David Matlack wrote: > > On Tue, Jul 29, 2025 at 3:26 PM Jason Gunthorpe wrote: > > > > On Mon, Jul 28, 2025 at 10:27:37AM -0600, Alex Williamson wrote: > > > On Fri, 25 Jul 2025 09:47:48 -0700 > > > David Matlack wrote: &

Re: [PATCH 00/33] vfio: Introduce selftests for VFIO

2025-08-12 Thread David Matlack
On 2025-08-05 05:08 PM, Joel Granados wrote: > On Fri, Jun 20, 2025 at 11:19:58PM +0000, David Matlack wrote: > > This series introduces VFIO selftests, located in > > tools/testing/selftests/vfio/. > Sorry for coming late to the party. Only recently got some cycles to go &g

Re: [PATCH 00/33] vfio: Introduce selftests for VFIO

2025-07-31 Thread David Matlack
On Tue, Jul 29, 2025 at 3:26 PM Jason Gunthorpe wrote: > > On Mon, Jul 28, 2025 at 10:27:37AM -0600, Alex Williamson wrote: > > On Fri, 25 Jul 2025 09:47:48 -0700 > > David Matlack wrote: > > > I also was curious about your thoughts on maintenance of VFIO > > &g

Re: [PATCH 00/33] vfio: Introduce selftests for VFIO

2025-07-25 Thread David Matlack
On Fri, Jun 20, 2025 at 4:21 PM David Matlack wrote: > > This series introduces VFIO selftests, located in > tools/testing/selftests/vfio/. Hi Alex, I wanted to discuss how you would like to proceed with this series. The series is quite large, so one thing I was wondering is if you

Re: [PATCH RFC 17/33] vfio: selftests: Enable asserting MSI eventfds not firing

2025-07-07 Thread David Matlack
On Mon, Jun 30, 2025 at 5:24 AM Sairaj Kodilkar wrote: > > On 5/24/2025 5:00 AM, David Matlack wrote: > > Make it possible to assert that a given MSI eventfd did _not_ fire by > > adding a helper to mark an eventfd non-blocking. Demonstrate this in > > vfio_pci_device_t

Re: [PATCH 03/33] vfio: selftests: Introduce vfio_pci_device_test

2025-06-27 Thread David Matlack
On Thu, Jun 26, 2025 at 9:57 PM Sairaj Kodilkar wrote: > > > > On 6/26/2025 9:59 PM, David Matlack wrote: > > On Thu, Jun 26, 2025 at 4:44 AM Sairaj Kodilkar wrote: > >> On 6/26/2025 4:57 PM, Sairaj Kodilkar wrote: > >>> On 6/21/2025 4:50 AM, David Matlack

Re: [PATCH 03/33] vfio: selftests: Introduce vfio_pci_device_test

2025-06-26 Thread David Matlack
On Thu, Jun 26, 2025 at 4:44 AM Sairaj Kodilkar wrote: > On 6/26/2025 4:57 PM, Sairaj Kodilkar wrote: > > On 6/21/2025 4:50 AM, David Matlack wrote: > >> +/* > >> + * Limit the number of MSIs enabled/disabled by the test regardless > >> of the > >>

[PATCH 33/33] KVM: selftests: Add -d option to vfio_pci_device_irq_test for device-sent MSIs

2025-06-20 Thread David Matlack
device-posted interrupts in Intel). Signed-off-by: David Matlack --- .../selftests/kvm/vfio_pci_device_irq_test.c | 61 +-- 1 file changed, 55 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/kvm/vfio_pci_device_irq_test.c b/tools/testing/selftests/kvm

[PATCH 32/33] KVM: selftests: Test sending a vfio-pci device IRQ to a VM

2025-06-20 Thread David Matlack
the hardware path (e.g. VT-d on Intel). This test only supports x86_64 for now, but can be ported to other architectures in the future. Signed-off-by: David Matlack --- tools/testing/selftests/kvm/Makefile.kvm | 1 + .../testing/selftests/kvm/include/kvm_util.h | 4 + tools/testing

[PATCH 31/33] KVM: selftests: Build and link sefltests/vfio/lib into KVM selftests

2025-06-20 Thread David Matlack
different CFLAGS when building without conflicting with each other. Signed-off-by: David Matlack --- tools/testing/selftests/kvm/Makefile.kvm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/testing/selftests/kvm/Makefile.kvm b/tools/testing/selftests/kvm/Makefile.kvm index 57d7a8fee047

[PATCH 30/33] vfio: selftests: Add a script to help with running VFIO selftests

2025-06-20 Thread David Matlack
then cleanup all the devices. Signed-off-by: David Matlack --- tools/testing/selftests/vfio/Makefile | 1 + tools/testing/selftests/vfio/run.sh | 109 ++ 2 files changed, 110 insertions(+) create mode 100755 tools/testing/selftests/vfio/run.sh diff --git a/tools

[PATCH 29/33] vfio: selftests: Make iommufd the default iommu_mode

2025-06-20 Thread David Matlack
Now that VFIO selftests support iommufd, make it the default mode. IOMMUFD is the successor to VFIO_TYPE1{,v2}_IOMMU and all new features are being added there, so it's a slightly better fit as the default mode. Signed-off-by: David Matlack --- tools/testing/selftests/vfio/lib/vfio_pci_dev

[PATCH 28/33] vfio: selftests: Add iommufd mode

2025-06-20 Thread David Matlack
Add a new IOMMU mode for using iommufd directly. In this mode userspace opens /dev/iommu and binds it to a device FD acquired through /dev/vfio/devices/vfioX. Signed-off-by: David Matlack --- .../selftests/vfio/lib/include/vfio_util.h| 6 +- .../selftests/vfio/lib/vfio_pci_device.c

[PATCH 27/33] vfio: selftests: Add iommufd_compat_type1{,v2} modes

2025-06-20 Thread David Matlack
transparently. Signed-off-by: David Matlack --- tools/testing/selftests/vfio/lib/include/vfio_util.h | 4 +++- tools/testing/selftests/vfio/lib/vfio_pci_device.c | 10 ++ tools/testing/selftests/vfio/vfio_dma_mapping_test.c | 12 ++-- 3 files changed, 23 insertions(+), 3 deletions

[PATCH 26/33] vfio: selftests: Add vfio_type1v2_mode

2025-06-20 Thread David Matlack
Add a new IOMMU mode for using VFIO_TYPE1v2_IOMMU. Signed-off-by: David Matlack --- tools/testing/selftests/vfio/lib/include/vfio_util.h | 3 ++- tools/testing/selftests/vfio/lib/vfio_pci_device.c | 5 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests

[PATCH 25/33] vfio: selftests: Replicate tests across all iommu_modes

2025-06-20 Thread David Matlack
Automatically replicate vfio_dma_mapping_test and vfio_pci_driver_test across all supported IOMMU modes using fixture variants. Both of these tests exercise DMA mapping to some degree so having automatic coverage across all IOMMU modes will help catch bugs. Signed-off-by: David Matlack

[PATCH 22/33] vfio: selftests: Add driver for Intel DSA

2025-06-20 Thread David Matlack
plenty to stress test VFIO and the IOMMU. The driver does not yet support requesting interrupt handles, as this commit was not tested against hardware that requires it. Cc: Vinicius Costa Gomes Cc: Dave Jiang Signed-off-by: David Matlack --- .../selftests/vfio/lib/drivers/dsa/dsa.c | 416

[PATCH 23/33] vfio: selftests: Move helper to get cdev path to libvfio

2025-06-20 Thread David Matlack
Move the helper function to get the VFIO cdev path to libvfio so that it can be used in libvfio in a subsequent commit. No functional change intended. Signed-off-by: David Matlack --- .../selftests/vfio/lib/include/vfio_util.h| 1 + .../selftests/vfio/lib/vfio_pci_device.c | 31

[PATCH 24/33] vfio: selftests: Encapsulate IOMMU mode

2025-06-20 Thread David Matlack
Encapsulate the "IOMMU mode" a test should use behind a new struct. In the future this will be used to support other types of IOMMUs besides VFIO_TYPE1_IOMMU, and allow users to select the mode on the command line. No functional change intended. Signed-off-by: David Matlack --- ...

[PATCH 21/33] dmaengine: idxd: Allow registers.h to be included from tools/

2025-06-20 Thread David Matlack
-by: David Matlack --- drivers/dma/idxd/registers.h | 4 1 file changed, 4 insertions(+) diff --git a/drivers/dma/idxd/registers.h b/drivers/dma/idxd/registers.h index 006ba206ab1b..bf79bc39a5f3 100644 --- a/drivers/dma/idxd/registers.h +++ b/drivers/dma/idxd/registers.h @@ -3,7 +3,11

[PATCH 20/33] vfio: selftests: Add driver for Intel CBDMA

2025-06-20 Thread David Matlack
acros (e.g. IOAT_CHANCMD_RESET) and struct ioat_dma_descriptor. Cc: Dave Jiang Cc: Dan Williams Signed-off-by: David Matlack --- .../selftests/vfio/lib/drivers/ioat/hw.h | 1 + .../selftests/vfio/lib/drivers/ioat/ioat.c| 235 ++ .../vfio/lib/drivers/ioat/registers.h

[PATCH 19/33] dmaengine: ioat: Move system_has_dca_enabled() to dma.h

2025-06-20 Thread David Matlack
-by: David Matlack --- drivers/dma/ioat/dma.h | 2 ++ drivers/dma/ioat/hw.h | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/dma/ioat/dma.h b/drivers/dma/ioat/dma.h index a180171087a8..12a4a4860a74 100644 --- a/drivers/dma/ioat/dma.h +++ b/drivers/dma/ioat/dma.h

[PATCH 18/33] vfio: sefltests: Add vfio_pci_driver_test

2025-06-20 Thread David Matlack
Add a new selftest that tests all driver operations. This test serves both as a demonstration of the driver framework, and also as a correctness test for future drivers. Signed-off-by: David Matlack --- tools/testing/selftests/vfio/Makefile | 1 + .../selftests/vfio

[PATCH 17/33] vfio: selftests: Add driver framework

2025-06-20 Thread David Matlack
commits will introduce drivers for specific devices. Signed-off-by: David Matlack --- .../selftests/vfio/lib/include/vfio_util.h| 92 ++ tools/testing/selftests/vfio/lib/libvfio.mk | 1 + .../selftests/vfio/lib/vfio_pci_device.c | 5 + .../selftests/vfio/lib

[PATCH 16/33] vfio: selftests: Add a helper for matching vendor+device IDs

2025-06-20 Thread David Matlack
Add a helper function for matching a device against a given vendor and device ID. This will be used in a subsequent commit to match devices against drivers. Signed-off-by: David Matlack --- tools/testing/selftests/vfio/lib/include/vfio_util.h | 7 +++ tools/testing/selftests/vfio

[PATCH 15/33] vfio: selftests: Enable asserting MSI eventfds not firing

2025-06-20 Thread David Matlack
Make it possible to assert that a given MSI eventfd did _not_ fire by adding a helper to mark an eventfd non-blocking. Demonstrate this in vfio_pci_device_test by asserting the MSI eventfd did not fire before vfio_pci_irq_trigger(). Signed-off-by: David Matlack --- tools/testing/selftests/vfio

[PATCH 14/33] vfio: selftests: Keep track of DMA regions mapped into the device

2025-06-20 Thread David Matlack
are then used by drivers. Signed-off-by: David Matlack --- .../selftests/vfio/lib/include/vfio_util.h| 23 +++-- .../selftests/vfio/lib/vfio_pci_device.c | 49 --- .../selftests/vfio/vfio_dma_mapping_test.c| 21 +--- 3 files changed, 75 insertions(+), 18

[PATCH 11/33] tools headers: Import x86 MMIO helper overrides

2025-06-20 Thread David Matlack
Import the x86-specific overrides for from the kernel headers into tools/include/. Changes made when importing: - Replace CONFIG_X86_64 with __x86_64__. Signed-off-by: David Matlack --- tools/arch/x86/include/asm/io.h | 75 + tools/include/asm/io.h

[PATCH 13/33] tools headers: Add symlink to linux/pci_ids.h

2025-06-20 Thread David Matlack
Add a symlink to include/linux/pci_ids.h to tools/include/. This will be used by VFIO selftests in subsequent commits to match device and vendor IDs. Signed-off-by: David Matlack --- tools/include/linux/pci_ids.h | 1 + 1 file changed, 1 insertion(+) create mode 12 tools/include/linux

[PATCH 08/33] vfio: selftests: Validate 2M/1G HugeTLB are mapped as 2M/1G in IOMMU

2025-06-20 Thread David Matlack
skipped if that directory is not available (i.e. non-Intel IOMMUs). Signed-off-by: Josh Hilke [reword commit message, refactor code] Signed-off-by: David Matlack --- .../selftests/vfio/vfio_dma_mapping_test.c| 111 ++ 1 file changed, 111 insertions(+) diff --git a/tools/testing

[PATCH 12/33] tools headers: Import iosubmit_cmds512()

2025-06-20 Thread David Matlack
made when importing: None Signed-off-by: David Matlack --- tools/arch/x86/include/asm/io.h| 26 + tools/arch/x86/include/asm/special_insns.h | 27 ++ 2 files changed, 53 insertions(+) create mode 100644 tools/arch/x86/include/asm/special_insns.h

[PATCH 10/33] tools headers: Import asm-generic MMIO helpers

2025-06-20 Thread David Matlack
directly). Changes made when importing: - Add missing includes at the top. - Stub out mmiowb_set_pending(). - Stub out _THIS_IP_. - Stub out log_*_mmio() calls. - Drop the CONFIG_64BIT checks, since tools/include/linux/types.h always defines u64. Signed-off-by: David Matlack --- tools

[PATCH 09/33] tools headers: Add stub definition for __iomem

2025-06-20 Thread David Matlack
Add an empty definition for __iomem so that kernel headers that use __iomem can be imported into tools/include/ with less modifications. Signed-off-by: David Matlack --- tools/include/linux/compiler.h | 4 1 file changed, 4 insertions(+) diff --git a/tools/include/linux/compiler.h b/tools

[PATCH 05/33] vfio: selftests: Move vfio dma mapping test to their own file

2025-06-20 Thread David Matlack
-off-by: Josh Hilke Signed-off-by: David Matlack --- tools/testing/selftests/vfio/Makefile | 1 + .../selftests/vfio/vfio_dma_mapping_test.c| 49 +++ .../selftests/vfio/vfio_pci_device_test.c | 16 -- 3 files changed, 50 insertions(+), 16 deletions(-) create

[PATCH 07/33] vfio: selftests: Add DMA mapping tests for 2M and 1G HugeTLB

2025-06-20 Thread David Matlack
From: Josh Hilke Add test coverage of mapping 2M and 1G HugeTLB to vfio_dma_mapping_test using a fixture variant. If there isn't enough HugeTLB memory available for the test, just skip them. Signed-off-by: Josh Hilke [switch from command line option to fixture variant] Signed-off-by:

[PATCH 06/33] vfio: selftests: Add test to reset vfio device.

2025-06-20 Thread David Matlack
From: Josh Hilke Add a test to vfio_pci_device_test which resets the device. If reset is not supported by the device, the test is skipped. Signed-off-by: Josh Hilke Signed-off-by: David Matlack --- tools/testing/selftests/vfio/lib/include/vfio_util.h | 1 + tools/testing/selftests/vfio/lib

[PATCH 04/33] vfio: selftests: Test basic VFIO and IOMMUFD integration

2025-06-20 Thread David Matlack
From: Josh Hilke Add a vfio test suite which verifies that userspace can bind and unbind devices, allocate I/O address space, and attach a device to an IOMMU domain using the cdev + IOMMUfd VFIO interface. Signed-off-by: Josh Hilke Signed-off-by: David Matlack --- tools/testing/selftests

[PATCH 03/33] vfio: selftests: Introduce vfio_pci_device_test

2025-06-20 Thread David Matlack
MSI-x - Reading and writing to PCI config space This test should work with most PCI devices, as long as they are bound to vfio-pci. Signed-off-by: David Matlack --- tools/testing/selftests/vfio/Makefile | 1 + .../selftests/vfio/vfio_pci_device_test.c | 178 ++ 2

[PATCH 02/33] vfio: selftests: Add a helper library for VFIO selftests

2025-06-20 Thread David Matlack
subsequent commit. Signed-off-by: David Matlack --- tools/testing/selftests/vfio/Makefile | 14 + .../selftests/vfio/lib/include/vfio_util.h| 140 +++ tools/testing/selftests/vfio/lib/libvfio.mk | 15 + .../selftests/vfio/lib/vfio_pci_device.c | 365 ++ 4 files

[PATCH 01/33] selftests: Create tools/testing/selftests/vfio

2025-06-20 Thread David Matlack
Create the directory tools/testing/selftests/vfio with a stub Makefile and hook it up to the top-level selftests Makefile. This directory will be used in subsequent commits to host selftests for the VFIO subsystem. Signed-off-by: David Matlack --- MAINTAINERS | 7

[PATCH 00/33] vfio: Introduce selftests for VFIO

2025-06-20 Thread David Matlack
Mahameed Cc: Adithya Jayachandran Cc: Joel Granados [1] https://github.com/Joelgranados/qemu/blob/pcie-testdev/hw/misc/pcie-ats-testdev.c [2] https://lore.kernel.org/kvm/20250404193923.1413163-68-sea...@google.com/ David Matlack (28): selftests: Create tools/testing/selftests/vfio vfio: selftests

Re: [RFC PATCH 07/33] vfio: selftests: Use command line to set hugepage size for DMA mapping test

2025-06-06 Thread David Matlack
On 2025-05-30 02:25 PM, Jason Gunthorpe wrote: > On Fri, May 30, 2025 at 09:50:22AM -0700, David Matlack wrote: > > I'll explore doing this. For a single dimension this looks possible. > > But for multiple dimensions (e.g. cross product of iommu_mode and > > backing_src)

Re: [RFC PATCH 08/33] vfio: selftests: Validate 2M/1G HugeTLB are mapped as 2M/1G in IOMMU

2025-06-03 Thread David Matlack
On Sun, Jun 1, 2025 at 12:45 AM Greg Kroah-Hartman wrote: > > On Sat, May 31, 2025 at 10:09:34PM +0300, Andy Shevchenko wrote: > > On Fri, May 30, 2025 at 02:12:36PM -0700, David Matlack wrote: > > > On Fri, May 23, 2025 at 4:30 PM David Matlack wrote: > > > > .

Re: [RFC PATCH 29/33] vfio: selftests: Make iommufd the default iommu_mode

2025-06-03 Thread David Matlack
On Mon, May 26, 2025 at 10:20 AM Jason Gunthorpe wrote: > > On Fri, May 23, 2025 at 11:30:14PM +, David Matlack wrote: > > Now that VFIO selftests support iommufd, make it the default mode. > > IOMMUFD is the successor to VFIO_TYPE1{,v2}_IOMMU and all new features > &g

Re: [RFC PATCH 30/33] vfio: selftests: Add a script to help with running VFIO selftests

2025-06-03 Thread David Matlack
On Mon, Jun 2, 2025 at 4:08 PM Alex Williamson wrote: > On Fri, 23 May 2025 23:30:15 + > > +function add_id() { > > + if echo $(echo ${1} | tr : ' ') > ${2}/new_id 2> /dev/null; then > > + echo "Added ${1} to ${2}" > > + return 0 > > + fi > > + > > + return

Re: [RFC PATCH 04/33] vfio: selftests: Test basic VFIO and IOMMUFD integration

2025-06-03 Thread David Matlack
On Mon, Jun 2, 2025 at 4:08 PM Alex Williamson wrote: > > On Fri, 23 May 2025 23:29:49 +0000 > David Matlack wrote: > > +int main(int argc, char *argv[]) > > +{ > > + char *bdf; > > + > > + if (argc != 2) { > > + pri

Re: [RFC PATCH 08/33] vfio: selftests: Validate 2M/1G HugeTLB are mapped as 2M/1G in IOMMU

2025-05-30 Thread David Matlack
On Fri, May 23, 2025 at 4:30 PM David Matlack wrote: > +static int iommu_mapping_get(const char *bdf, u64 iova, > +struct iommu_mapping *mapping) > +{ > + if (access("/sys/kernel/debug/iommu/intel", F_OK)) > + return in

Re: [RFC PATCH 07/33] vfio: selftests: Use command line to set hugepage size for DMA mapping test

2025-05-30 Thread David Matlack
On Mon, May 26, 2025 at 10:15 AM Jason Gunthorpe wrote: > > On Fri, May 23, 2025 at 11:29:52PM +, David Matlack wrote: > > From: Josh Hilke > > > > Add a command line arg to vfio_dma_mapping_test to choose the size of > > page which is mapped in VFIO. > >

Re: [RFC PATCH 00/33] vfio: Introduce selftests for VFIO

2025-05-28 Thread David Matlack
On Tue, May 27, 2025 at 5:11 PM Jason Gunthorpe wrote: > > On Tue, May 27, 2025 at 04:01:52PM -0700, David Matlack wrote: > > > A reusable mini-driver framework that can trigger DMA is a huge leap > > > forward. > > > > How broad do you think the reusability

Re: [RFC PATCH 13/33] tools headers: Import drivers/dma/ioat/{hw.h,registers.h}

2025-05-27 Thread David Matlack
On Mon, May 26, 2025 at 10:18 AM Jason Gunthorpe wrote: > > On Fri, May 23, 2025 at 11:29:58PM +, David Matlack wrote: > > Import drivers/dma/ioat/{hw.h,registers.h} into tools/include/ so that > > they can be used in VFIO selftests to interact with Intel CBDMA devices. &g

Re: [RFC PATCH 08/33] vfio: selftests: Validate 2M/1G HugeTLB are mapped as 2M/1G in IOMMU

2025-05-27 Thread David Matlack
On Mon, May 26, 2025 at 10:16 AM Jason Gunthorpe wrote: > > On Fri, May 23, 2025 at 11:29:53PM +, David Matlack wrote: > > From: Josh Hilke > > > > Update vfio dma mapping test to verify that the IOMMU uses 2M and 1G > > mappings when 2M and 1G HugeTLB

Re: [RFC PATCH 00/33] vfio: Introduce selftests for VFIO

2025-05-27 Thread David Matlack
On Mon, May 26, 2025 at 10:09 AM Jason Gunthorpe wrote: > > On Fri, May 23, 2025 at 11:29:45PM +, David Matlack wrote: > > Drivers must implement the following methods: > > > > - probe():Check if the driver supports a given device. > > - init():

Re: [RFC PATCH 00/33] vfio: Introduce selftests for VFIO

2025-05-27 Thread David Matlack
On Mon, May 26, 2025 at 2:07 AM Yi Liu wrote: > > On 2025/5/24 07:29, David Matlack wrote: > > This series introduces VFIO selftests, located in > > tools/testing/selftests/vfio/. > > > > VFIO selftests aim to enable kernel developers to write and run tests >

[RFC PATCH 30/33] vfio: selftests: Add a script to help with running VFIO selftests

2025-05-23 Thread David Matlack
and parse them into an array, setup all the devices, pass the list of BDFs to the test, and then cleanup all the devices. Signed-off-by: David Matlack --- tools/testing/selftests/vfio/Makefile | 1 + tools/testing/selftests/vfio/run.sh | 110 ++ 2 files changed, 111

[RFC PATCH 03/33] vfio: selftests: Introduce vfio_pci_device_test

2025-05-23 Thread David Matlack
MSI-x - Reading and writing to PCI config space This test should work with most PCI devices, as long as they are bound to vfio-pci. Signed-off-by: David Matlack --- tools/testing/selftests/vfio/Makefile | 1 + .../selftests/vfio/vfio_pci_device_test.c | 180 ++ 2

[RFC PATCH 02/33] vfio: selftests: Add a helper library for VFIO selftests

2025-05-23 Thread David Matlack
subsequent commit. Signed-off-by: David Matlack --- tools/testing/selftests/vfio/Makefile | 13 + .../selftests/vfio/lib/include/vfio_util.h| 126 +++ tools/testing/selftests/vfio/lib/libvfio.mk | 17 + .../selftests/vfio/lib/vfio_pci_device.c | 330 ++ 4 files

[RFC PATCH 04/33] vfio: selftests: Test basic VFIO and IOMMUFD integration

2025-05-23 Thread David Matlack
From: Josh Hilke Add a vfio test suite which verifies that userspace can bind and unbind devices, allocate I/O address space, and attach a device to an IOMMU domain using the cdev + IOMMUfd VFIO interface. Signed-off-by: Josh Hilke Signed-off-by: David Matlack --- tools/testing/selftests

[RFC PATCH 24/33] vfio: selftests: Encapsulate IOMMU mode

2025-05-23 Thread David Matlack
Encapsulate the "IOMMU mode" a test should use behind a new struct. In the future this will be used to support other types of IOMMUs besides VFIO_TYPE1_IOMMU, and allow users to select the mode on the command line. No functional change intended. Signed-off-by: David Matlack --- ...

[RFC PATCH 32/33] KVM: selftests: Test sending a vfio-pci device IRQ to a VM

2025-05-23 Thread David Matlack
the hardware path (e.g. VT-d on Intel). This test only supports x86_64 for now, but can be ported to other architectures in the future. Signed-off-by: David Matlack --- tools/testing/selftests/kvm/Makefile.kvm | 1 + .../testing/selftests/kvm/include/kvm_util.h | 4 + tools/testing

[RFC PATCH 29/33] vfio: selftests: Make iommufd the default iommu_mode

2025-05-23 Thread David Matlack
Now that VFIO selftests support iommufd, make it the default mode. IOMMUFD is the successor to VFIO_TYPE1{,v2}_IOMMU and all new features are being added there, so it's a slightly better fit as the default mode. Signed-off-by: David Matlack --- tools/testing/selftests/vfio/lib/vfio_pci_dev

[RFC PATCH 33/33] KVM: selftests: Use real device MSIs in vfio_pci_device_irq_test

2025-05-23 Thread David Matlack
Bypass (e.g. VT-d device-posted interrupts in Intel). Signed-off-by: David Matlack --- .../selftests/kvm/vfio_pci_device_irq_test.c | 66 +++ 1 file changed, 55 insertions(+), 11 deletions(-) diff --git a/tools/testing/selftests/kvm/vfio_pci_device_irq_test.c b/tools/testing

[RFC PATCH 31/33] KVM: selftests: Build and link sefltests/vfio/lib into KVM selftests

2025-05-23 Thread David Matlack
different CFLAGS when building without conflicting with each other. Signed-off-by: David Matlack --- tools/testing/selftests/kvm/Makefile.kvm | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/Makefile.kvm b/tools/testing/selftests/kvm/Makefile.kvm index

[RFC PATCH 27/33] vfio: selftests: Add iommufd_compat_type1{,v2} modes

2025-05-23 Thread David Matlack
transparently. Signed-off-by: David Matlack --- tools/testing/selftests/vfio/lib/vfio_pci_device.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/tools/testing/selftests/vfio/lib/vfio_pci_device.c b/tools/testing/selftests/vfio/lib/vfio_pci_device.c index b349d901cfdc..205bbfb3d54e

  1   2   >