[PATCH v5 7/8] iommufd/selftest: Add coverage for vdevice tombstone

Xu Yilun posted 8 patches 2 months, 3 weeks ago
There is a newer version of this series
[PATCH v5 7/8] iommufd/selftest: Add coverage for vdevice tombstone
Posted by Xu Yilun 2 months, 3 weeks ago
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.

Signed-off-by: Xu Yilun <yilun.xu@linux.intel.com>
---
 tools/testing/selftests/iommu/iommufd.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/tools/testing/selftests/iommu/iommufd.c b/tools/testing/selftests/iommu/iommufd.c
index 16ea10ea1dbf..6084396f7111 100644
--- a/tools/testing/selftests/iommu/iommufd.c
+++ b/tools/testing/selftests/iommu/iommufd.c
@@ -3117,6 +3117,20 @@ TEST_F(iommufd_viommu, hw_queue)
 	test_ioctl_ioas_unmap(iova, PAGE_SIZE);
 }
 
+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)
+		SKIP(return, "Skipping test for variant no_viommu");
+
+	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
Re: [PATCH v5 7/8] iommufd/selftest: Add coverage for vdevice tombstone
Posted by Nicolin Chen 2 months, 3 weeks ago
On Tue, Jul 15, 2025 at 02:32:44PM +0800, Xu Yilun wrote:
> 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.
> 
> Signed-off-by: Xu Yilun <yilun.xu@linux.intel.com>

Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>