David Matlack
5df9bd6205
vfio: selftests: Encapsulate IOMMU mode
...
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 <skhan@linuxfoundation.org >
Signed-off-by: David Matlack <dmatlack@google.com >
Link: https://lore.kernel.org/r/20250822212518.4156428-25-dmatlack@google.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com >
2025-08-27 12:14:09 -06:00
David Matlack
50d8fe805f
vfio: selftests: Add a helper for matching vendor+device IDs
...
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 <skhan@linuxfoundation.org >
Signed-off-by: David Matlack <dmatlack@google.com >
Link: https://lore.kernel.org/r/20250822212518.4156428-12-dmatlack@google.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com >
2025-08-27 12:14:05 -06:00
David Matlack
924947804f
vfio: selftests: Enable asserting MSI eventfds not firing
...
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 <skhan@linuxfoundation.org >
Signed-off-by: David Matlack <dmatlack@google.com >
Link: https://lore.kernel.org/r/20250822212518.4156428-11-dmatlack@google.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com >
2025-08-27 12:14:04 -06:00
Josh Hilke
a0fd0af504
vfio: selftests: Add test to reset vfio device.
...
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 <jrhilke@google.com >
Acked-by: Shuah Khan <skhan@linuxfoundation.org >
Signed-off-by: David Matlack <dmatlack@google.com >
Link: https://lore.kernel.org/r/20250822212518.4156428-7-dmatlack@google.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com >
2025-08-27 12:14:03 -06:00
Josh Hilke
b477e7bcd2
vfio: selftests: Move vfio dma mapping test to their own file
...
Move the dma_map_unmap test from vfio_pci_device_test to a new test:
vfio_dma_mapping_test. We are going to add more complex dma mapping
tests, so it makes sense to separate this from the vfio pci device
test which is more of a sanity check for vfio pci functionality.
Signed-off-by: Josh Hilke <jrhilke@google.com >
Acked-by: Shuah Khan <skhan@linuxfoundation.org >
Signed-off-by: David Matlack <dmatlack@google.com >
Link: https://lore.kernel.org/r/20250822212518.4156428-6-dmatlack@google.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com >
2025-08-27 12:14:02 -06:00
David Matlack
16eadd7c12
vfio: selftests: Introduce vfio_pci_device_test
...
Introduce a basic VFIO selftest called vfio_pci_device_test to
demonstrate the functionality of the VFIO selftest library and provide
some test coverage of basic VFIO operations, including:
- Mapping and unmapping DMA
- Mapping and unmapping BARs
- Enabling, triggering, and disabling MSI and 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 <skhan@linuxfoundation.org >
Signed-off-by: David Matlack <dmatlack@google.com >
Link: https://lore.kernel.org/r/20250822212518.4156428-4-dmatlack@google.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com >
2025-08-27 12:14:02 -06:00