| 785562e3 | 11-Jun-2026 |
David Matlack <dmatlack@google.com> |
vfio: selftests: Ensure libvfio output dirs are always created
Add an explicit dependency between the output object files and the output directories that need to be created to hold those files. This
vfio: selftests: Ensure libvfio output dirs are always created
Add an explicit dependency between the output object files and the output directories that need to be created to hold those files. This ensures that the output directories are always created.
Creating the output directories at parse time (current behavior) doesn't support the scenario where someone does "make clean all". The directories will be created during parsing, deleted during "clean" and then not available for the "all" target.
Use an order-only prerequisite for the output directories, rather than a normal prerequisite, to avoid unnecessary recompilations.
Fixes: 19faf6fd969c ("vfio: selftests: Add a helper library for VFIO selftests") Reported-by: Sashiko <sashiko-bot@kernel.org> Closes: https://lore.kernel.org/kvm/20260610010314.DB8861F00893@smtp.kernel.org/ Signed-off-by: David Matlack <dmatlack@google.com> Link: https://lore.kernel.org/r/20260611213945.3714421-1-dmatlack@google.com Signed-off-by: Alex Williamson <alex@shazbot.org>
show more ...
|
| 3152e7f4 | 05-May-2026 |
Raghavendra Rao Ananta <rananta@google.com> |
vfio: selftests: Add helpers to alloc/free vfio_pci_device
Add a helper, vfio_pci_device_alloc(), to allocate 'struct vfio_pci_device'. The subsequent test patch will utilize this to get the struct
vfio: selftests: Add helpers to alloc/free vfio_pci_device
Add a helper, vfio_pci_device_alloc(), to allocate 'struct vfio_pci_device'. The subsequent test patch will utilize this to get the struct with very minimal initialization done. Internally, let vfio_pci_device_init() also make use of this function and later do the full initialization.
Symmetrically, add a free variant, vfio_pci_device_free(), to be used in a similar fashion.
No functional change intended.
Signed-off-by: Raghavendra Rao Ananta <rananta@google.com> Reviewed-by: David Matlack <dmatlack@google.com> Reviewed-by: Vipin Sharma <vipinsh@google.com> Tested-by: David Matlack <dmatlack@google.com> Link: https://lore.kernel.org/r/20260505212838.1698034-8-rananta@google.com Signed-off-by: Alex Williamson <alex@shazbot.org>
show more ...
|
| 20face8c | 05-May-2026 |
Raghavendra Rao Ananta <rananta@google.com> |
vfio: selftests: Add helper to set/override a vf_token
Add a helper function, vfio_device_set_vf_token(), to set or override a vf_token. Not only at init, but a vf_token can also be set via the VFIO
vfio: selftests: Add helper to set/override a vf_token
Add a helper function, vfio_device_set_vf_token(), to set or override a vf_token. Not only at init, but a vf_token can also be set via the VFIO_DEVICE_FEATURE ioctl, by setting the VFIO_DEVICE_FEATURE_PCI_VF_TOKEN flag. Hence, add an API to utilize this functionality from the test code. The subsequent commit will use this to test the functionality of this method to set the vf_token.
Signed-off-by: Raghavendra Rao Ananta <rananta@google.com> Reviewed-by: David Matlack <dmatlack@google.com> Reviewed-by: Vipin Sharma <vipinsh@google.com> Tested-by: David Matlack <dmatlack@google.com> Link: https://lore.kernel.org/r/20260505212838.1698034-7-rananta@google.com Signed-off-by: Alex Williamson <alex@shazbot.org>
show more ...
|
| 60ab36e5 | 05-May-2026 |
Raghavendra Rao Ananta <rananta@google.com> |
vfio: selftests: Expose more vfio_pci_device functions
Refactor and make the functions called under device initialization public. A later patch adds a test that calls these functions to validate the
vfio: selftests: Expose more vfio_pci_device functions
Refactor and make the functions called under device initialization public. A later patch adds a test that calls these functions to validate the UAPI of SR-IOV devices. Opportunistically, to test the success and failure cases of the UAPI, split the functions dealing with VFIO_GROUP_GET_DEVICE_FD and VFIO_DEVICE_BIND_IOMMUFD into a core function and another one that asserts the ioctl. The former will be used for testing the SR-IOV UAPI, hence only export these.
Signed-off-by: Raghavendra Rao Ananta <rananta@google.com> Reviewed-by: David Matlack <dmatlack@google.com> Reviewed-by: Vipin Sharma <vipinsh@google.com> Tested-by: David Matlack <dmatlack@google.com> Link: https://lore.kernel.org/r/20260505212838.1698034-6-rananta@google.com Signed-off-by: Alex Williamson <alex@shazbot.org>
show more ...
|
| e65f1bf8 | 05-May-2026 |
Raghavendra Rao Ananta <rananta@google.com> |
vfio: selftests: Extend container/iommufd setup for passing vf_token
A UUID is normally set as a vf_token to correspond the VFs with the PFs, if they are both bound by the vfio-pci driver. This is t
vfio: selftests: Extend container/iommufd setup for passing vf_token
A UUID is normally set as a vf_token to correspond the VFs with the PFs, if they are both bound by the vfio-pci driver. This is true for iommufd-based approach and container-based approach. The token can be set either during device creation (VFIO_GROUP_GET_DEVICE_FD) in container-based approach or during iommu bind (VFIO_DEVICE_BIND_IOMMUFD) in the iommu-fd case. Hence extend the functions, vfio_pci_iommufd_setup() and vfio_pci_container_setup(), to accept vf_token as an (optional) argument and handle the necessary setup.
No functional changes are expected.
Signed-off-by: Raghavendra Rao Ananta <rananta@google.com> Reviewed-by: David Matlack <dmatlack@google.com> Reviewed-by: Vipin Sharma <vipinsh@google.com> Tested-by: David Matlack <dmatlack@google.com> Link: https://lore.kernel.org/r/20260505212838.1698034-5-rananta@google.com Signed-off-by: Alex Williamson <alex@shazbot.org>
show more ...
|
| c5db77a0 | 05-May-2026 |
Raghavendra Rao Ananta <rananta@google.com> |
vfio: selftests: Introduce a sysfs lib
Introduce a sysfs library to handle the common reads/writes to the PCI sysfs files, for example, getting the total number of VFs supported by the device via /s
vfio: selftests: Introduce a sysfs lib
Introduce a sysfs library to handle the common reads/writes to the PCI sysfs files, for example, getting the total number of VFs supported by the device via /sys/bus/pci/devices/$BDF/sriov_totalvfs. The library will be used in the upcoming test patch to configure the VFs for a given PF device.
Since readlink() is quite commonly used in the lib, introduce and use readlink_safe() to take care of potential buffer overrun errors and to safely terminate the buffer with '\0'.
Opportunistically, move vfio_pci_get_group_from_dev() to this library as it falls under the same bucket. Rename it to sysfs_iommu_group_get() to align with other function names.
Signed-off-by: Raghavendra Rao Ananta <rananta@google.com> Reviewed-by: Vipin Sharma <vipinsh@google.com> Reviewed-by: David Matlack <dmatlack@google.com> Tested-by: David Matlack <dmatlack@google.com> Link: https://lore.kernel.org/r/20260505212838.1698034-4-rananta@google.com Signed-off-by: Alex Williamson <alex@shazbot.org>
show more ...
|
| c82cfe15 | 20-Mar-2026 |
Yi Lai <yi1.lai@intel.com> |
vfio: selftests: Support DMR and GNR-D DSA devices
Currently, the VFIO DSA driver test only supports the SPR DSA device ID. Attempting to run the test on newer platforms like DMR or GNR-D results in
vfio: selftests: Support DMR and GNR-D DSA devices
Currently, the VFIO DSA driver test only supports the SPR DSA device ID. Attempting to run the test on newer platforms like DMR or GNR-D results in a "No driver found" error, causing the test to be skipped.
Refactor dsa_probe() to use a switch statement for checking device IDs. This improves maintainability and makes it easier to add new device IDs in the future.
Add the following DSA device IDs to the supported list: PCI_DEVICE_ID_INTEL_DSA_DMR (0x1212) PCI_DEVICE_ID_INTEL_DSA_GNRD (0x11fb)
Signed-off-by: Yi Lai <yi1.lai@intel.com> Reviewed-by: David Matlack <dmatlack@google.com> Link: https://lore.kernel.org/r/20260320010930.481380-1-yi1.lai@intel.com Signed-off-by: Alex Williamson <alex@shazbot.org>
show more ...
|
| 557dbdf6 | 14-Jan-2026 |
Alex Mastro <amastro@fb.com> |
vfio: selftests: Align BAR mmaps for efficient IOMMU mapping
Update vfio_pci_bar_map() to align BAR mmaps for efficient huge page mappings. The manual mmap alignment can be removed once mmap(!MAP_FI
vfio: selftests: Align BAR mmaps for efficient IOMMU mapping
Update vfio_pci_bar_map() to align BAR mmaps for efficient huge page mappings. The manual mmap alignment can be removed once mmap(!MAP_FIXED) on vfio device fds improves to automatically return well-aligned addresses.
Also add MADV_HUGEPAGE, which encourages the kernel to use huge pages (e.g. when /sys/kernel/mm/transparent_hugepage/enabled is set to "madvise").
Drop MAP_FILE from mmap(). It is an ignored compatibility flag.
Signed-off-by: Alex Mastro <amastro@fb.com> Reviewed-by: David Matlack <dmatlack@google.com> Tested-by: David Matlack <dmatlack@google.com> Link: https://lore.kernel.org/r/20260114-map-mmio-test-v3-2-44e036d95e64@fb.com Signed-off-by: Alex Williamson <alex@shazbot.org>
show more ...
|
| 5fabc49a | 27-Nov-2025 |
David Matlack <dmatlack@google.com> |
vfio: selftests: Split libvfio.h into separate header files
Split out the contents of libvfio.h into separate header files, but keep libvfio.h as the top-level include that all tests can use.
Put a
vfio: selftests: Split libvfio.h into separate header files
Split out the contents of libvfio.h into separate header files, but keep libvfio.h as the top-level include that all tests can use.
Put all new header files into a libvfio/ subdirectory to avoid future name conflicts in include paths when libvfio is used by other selftests like KVM.
No functional change intended.
Reviewed-by: Alex Mastro <amastro@fb.com> Tested-by: Alex Mastro <amastro@fb.com> Reviewed-by: Raghavendra Rao Ananta <rananta@google.com> Signed-off-by: David Matlack <dmatlack@google.com> Link: https://lore.kernel.org/r/20251126231733.3302983-17-dmatlack@google.com Signed-off-by: Alex Williamson <alex@shazbot.org>
show more ...
|
| 19cf492c | 27-Nov-2025 |
David Matlack <dmatlack@google.com> |
vfio: selftests: Move vfio_selftests_*() helpers into libvfio.c
Move the vfio_selftests_*() helpers into their own file libvfio.c. These helpers have nothing to do with struct vfio_pci_device, so th
vfio: selftests: Move vfio_selftests_*() helpers into libvfio.c
Move the vfio_selftests_*() helpers into their own file libvfio.c. These helpers have nothing to do with struct vfio_pci_device, so they don't make sense in vfio_pci_device.c.
No functional change intended.
Reviewed-by: Alex Mastro <amastro@fb.com> Tested-by: Alex Mastro <amastro@fb.com> Reviewed-by: Raghavendra Rao Ananta <rananta@google.com> Signed-off-by: David Matlack <dmatlack@google.com> Link: https://lore.kernel.org/r/20251126231733.3302983-16-dmatlack@google.com Signed-off-by: Alex Williamson <alex@shazbot.org>
show more ...
|
| 831c37a5 | 27-Nov-2025 |
David Matlack <dmatlack@google.com> |
vfio: selftests: Stop passing device for IOMMU operations
Drop the struct vfio_pci_device wrappers for IOMMU map/unmap functions and require tests to directly call iommu_map(), iommu_unmap(), etc. T
vfio: selftests: Stop passing device for IOMMU operations
Drop the struct vfio_pci_device wrappers for IOMMU map/unmap functions and require tests to directly call iommu_map(), iommu_unmap(), etc. This results in more concise code, and also makes it clear the map operations are happening on a struct iommu, not necessarily on a specific device, especially when multi-device tests are introduced.
Do the same for iova_allocator_init() as that function only needs the struct iommu, not struct vfio_pci_device.
Reviewed-by: Alex Mastro <amastro@fb.com> Tested-by: Alex Mastro <amastro@fb.com> Reviewed-by: Raghavendra Rao Ananta <rananta@google.com> Signed-off-by: David Matlack <dmatlack@google.com> Link: https://lore.kernel.org/r/20251126231733.3302983-14-dmatlack@google.com Signed-off-by: Alex Williamson <alex@shazbot.org>
show more ...
|
| 2607a436 | 27-Nov-2025 |
David Matlack <dmatlack@google.com> |
vfio: selftests: Move IOVA allocator into iova_allocator.c
Move the IOVA allocator into its own file, to provide better separation between the allocator and the struct vfio_pci_device helper code.
vfio: selftests: Move IOVA allocator into iova_allocator.c
Move the IOVA allocator into its own file, to provide better separation between the allocator and the struct vfio_pci_device helper code.
The allocator could go into iommu.c, but it is standalone enough that a separate file seems cleaner. This also continues the trend of having a .c for every major object in VFIO selftests (vfio_pci_device.c, vfio_pci_driver.c, iommu.c, and now iova_allocator.c).
No functional change intended.
Reviewed-by: Alex Mastro <amastro@fb.com> Tested-by: Alex Mastro <amastro@fb.com> Reviewed-by: Raghavendra Rao Ananta <rananta@google.com> Signed-off-by: David Matlack <dmatlack@google.com> Link: https://lore.kernel.org/r/20251126231733.3302983-13-dmatlack@google.com Signed-off-by: Alex Williamson <alex@shazbot.org>
show more ...
|
| 2aca5710 | 27-Nov-2025 |
David Matlack <dmatlack@google.com> |
vfio: selftests: Move IOMMU library code into iommu.c
Move all the IOMMU related library code into their own file iommu.c. This provides a better separation between the vfio_pci_device helper code a
vfio: selftests: Move IOMMU library code into iommu.c
Move all the IOMMU related library code into their own file iommu.c. This provides a better separation between the vfio_pci_device helper code and the iommu code.
No function change intended.
Reviewed-by: Alex Mastro <amastro@fb.com> Tested-by: Alex Mastro <amastro@fb.com> Reviewed-by: Raghavendra Rao Ananta <rananta@google.com> Signed-off-by: David Matlack <dmatlack@google.com> Link: https://lore.kernel.org/r/20251126231733.3302983-12-dmatlack@google.com Signed-off-by: Alex Williamson <alex@shazbot.org>
show more ...
|
| 9a659d74 | 27-Nov-2025 |
David Matlack <dmatlack@google.com> |
vfio: selftests: Rename struct vfio_dma_region to dma_region
Rename struct vfio_dma_region to dma_region. This is in preparation for separating the VFIO PCI device library code from the IOMMU librar
vfio: selftests: Rename struct vfio_dma_region to dma_region
Rename struct vfio_dma_region to dma_region. This is in preparation for separating the VFIO PCI device library code from the IOMMU library code. This name change also better reflects the fact that DMA mappings can be managed by either VFIO or IOMMUFD. i.e. the "vfio_" prefix is misleading.
Reviewed-by: Alex Mastro <amastro@fb.com> Tested-by: Alex Mastro <amastro@fb.com> Reviewed-by: Raghavendra Rao Ananta <rananta@google.com> Signed-off-by: David Matlack <dmatlack@google.com> Link: https://lore.kernel.org/r/20251126231733.3302983-11-dmatlack@google.com Signed-off-by: Alex Williamson <alex@shazbot.org>
show more ...
|
| 28a84da7 | 27-Nov-2025 |
David Matlack <dmatlack@google.com> |
vfio: selftests: Upgrade driver logging to dev_err()
Upgrade various logging in the VFIO selftests drivers from dev_info() to dev_err(). All of these logs indicate scenarios that may be unexpected.
vfio: selftests: Upgrade driver logging to dev_err()
Upgrade various logging in the VFIO selftests drivers from dev_info() to dev_err(). All of these logs indicate scenarios that may be unexpected. For example, the logging during probing indicates matching devices but that aren't supported by the driver. And the memcpy errors can indicate a problem if the caller was not trying to do something like exercise I/O fault handling. Exercising I/O fault handling is certainly a valid thing to do, but the driver can't infer the caller's expectations, so better to just log with dev_err().
Suggested-by: Raghavendra Rao Ananta <rananta@google.com> Reviewed-by: Alex Mastro <amastro@fb.com> Tested-by: Alex Mastro <amastro@fb.com> Reviewed-by: Raghavendra Rao Ananta <rananta@google.com> Signed-off-by: David Matlack <dmatlack@google.com> Link: https://lore.kernel.org/r/20251126231733.3302983-10-dmatlack@google.com Signed-off-by: Alex Williamson <alex@shazbot.org>
show more ...
|
| c4854544 | 27-Nov-2025 |
David Matlack <dmatlack@google.com> |
vfio: selftests: Prefix logs with device BDF where relevant
Prefix log messages with the device's BDF where relevant. This will help understanding VFIO selftests logs when tests are run with multipl
vfio: selftests: Prefix logs with device BDF where relevant
Prefix log messages with the device's BDF where relevant. This will help understanding VFIO selftests logs when tests are run with multiple devices.
Reviewed-by: Alex Mastro <amastro@fb.com> Tested-by: Alex Mastro <amastro@fb.com> Reviewed-by: Raghavendra Rao Ananta <rananta@google.com> Signed-off-by: David Matlack <dmatlack@google.com> Link: https://lore.kernel.org/r/20251126231733.3302983-9-dmatlack@google.com Signed-off-by: Alex Williamson <alex@shazbot.org>
show more ...
|
| 6c74d983 | 27-Nov-2025 |
David Matlack <dmatlack@google.com> |
vfio: selftests: Eliminate overly chatty logging
Eliminate overly chatty logs that are printed during almost every test. These logs are adding more noise than value. If a test cares about this infor
vfio: selftests: Eliminate overly chatty logging
Eliminate overly chatty logs that are printed during almost every test. These logs are adding more noise than value. If a test cares about this information it can log it itself. This is especially true as the VFIO selftests gains support for multiple devices in a single test (which multiplies all these logs).
Reviewed-by: Alex Mastro <amastro@fb.com> Tested-by: Alex Mastro <amastro@fb.com> Reviewed-by: Raghavendra Rao Ananta <rananta@google.com> Signed-off-by: David Matlack <dmatlack@google.com> Link: https://lore.kernel.org/r/20251126231733.3302983-8-dmatlack@google.com Signed-off-by: Alex Williamson <alex@shazbot.org>
show more ...
|
| d8470a77 | 27-Nov-2025 |
David Matlack <dmatlack@google.com> |
vfio: selftests: Support multiple devices in the same container/iommufd
Support tests that want to add multiple devices to the same container/iommufd by decoupling struct vfio_pci_device from struct
vfio: selftests: Support multiple devices in the same container/iommufd
Support tests that want to add multiple devices to the same container/iommufd by decoupling struct vfio_pci_device from struct iommu.
Multi-devices tests can now put multiple devices in the same container/iommufd like so:
iommu = iommu_init(iommu_mode);
device1 = vfio_pci_device_init(bdf1, iommu); device2 = vfio_pci_device_init(bdf2, iommu); device3 = vfio_pci_device_init(bdf3, iommu);
...
vfio_pci_device_cleanup(device3); vfio_pci_device_cleanup(device2); vfio_pci_device_cleanup(device1);
iommu_cleanup(iommu);
To account for the new separation of vfio_pci_device and iommu, update existing tests to initialize and cleanup a struct iommu.
Reviewed-by: Alex Mastro <amastro@fb.com> Tested-by: Alex Mastro <amastro@fb.com> Reviewed-by: Raghavendra Rao Ananta <rananta@google.com> Signed-off-by: David Matlack <dmatlack@google.com> Link: https://lore.kernel.org/r/20251126231733.3302983-7-dmatlack@google.com Signed-off-by: Alex Williamson <alex@shazbot.org>
show more ...
|