[PATCH v2 4/4] iommufd/selftest: Add coverage for vdevice tombstone
From: Xu Yilun
Date: Mon Jun 23 2025 - 05:59:40 EST
This tests the flow to tombstone vdevice when idevice is to be unbound
before vdevice destroy. The expected result is:
- idevice unbound tombstones vdevice ID, the ID can't be repurposed
anymore.
- Even ioctl(IOMMU_DESTROY) can't free it the tombstoned ID.
- iommufd_fops_release() can still free everything.
Signed-off-by: Xu Yilun <yilun.xu@xxxxxxxxxxxxxxx>
---
tools/testing/selftests/iommu/iommufd.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/tools/testing/selftests/iommu/iommufd.c b/tools/testing/selftests/iommu/iommufd.c
index 1a8e85afe9aa..092e1344447e 100644
--- a/tools/testing/selftests/iommu/iommufd.c
+++ b/tools/testing/selftests/iommu/iommufd.c
@@ -3014,6 +3014,19 @@ TEST_F(iommufd_viommu, vdevice_cache)
}
}
+TEST_F(iommufd_viommu, vdevice_tombstone)
+{
+ uint32_t viommu_id = self->viommu_id;
+ uint32_t dev_id = self->device_id;
+ uint32_t vdev_id = 0;
+
+ if (dev_id) {
+ test_cmd_vdevice_alloc(viommu_id, dev_id, 0x99, &vdev_id);
+ test_ioctl_destroy(self->stdev_id);
+ EXPECT_ERRNO(ENOENT, _test_ioctl_destroy(self->fd, vdev_id));
+ }
+}
+
FIXTURE(iommufd_device_pasid)
{
int fd;
--
2.25.1