Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iommufd/selftest: Add coverage for vdevice tombstone

This tests the flow to tombstone vdevice when idevice is to be unbound
before vdevice destruction. The expected results of the tombstone are:

- The vdevice ID can't be reused anymore (not tested in this patch).
- Even ioctl(IOMMU_DESTROY) can't free the vdevice ID.
- iommufd_fops_release() can still free everything.

Link: https://patch.msgid.link/r/20250716070349.1807226-8-yilun.xu@linux.intel.com
Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>
Tested-by: Nicolin Chen <nicolinc@nvidia.com>
Signed-off-by: Xu Yilun <yilun.xu@linux.intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

authored by

Xu Yilun and committed by
Jason Gunthorpe
39a369c3 c4e496d4

+14
+14
tools/testing/selftests/iommu/iommufd.c
··· 3142 3142 test_ioctl_ioas_unmap(iova, PAGE_SIZE); 3143 3143 } 3144 3144 3145 + TEST_F(iommufd_viommu, vdevice_tombstone) 3146 + { 3147 + uint32_t viommu_id = self->viommu_id; 3148 + uint32_t dev_id = self->device_id; 3149 + uint32_t vdev_id = 0; 3150 + 3151 + if (!dev_id) 3152 + SKIP(return, "Skipping test for variant no_viommu"); 3153 + 3154 + test_cmd_vdevice_alloc(viommu_id, dev_id, 0x99, &vdev_id); 3155 + test_ioctl_destroy(self->stdev_id); 3156 + EXPECT_ERRNO(ENOENT, _test_ioctl_destroy(self->fd, vdev_id)); 3157 + } 3158 + 3145 3159 FIXTURE(iommufd_device_pasid) 3146 3160 { 3147 3161 int fd;