Skip to content

Commit c958721

Browse files
duanzhenzhongjoergroedel
authored andcommitted
iommufd/selftest: Test dirty tracking on PASID
Add test case for dirty tracking on a domain attached to PASID, also confirm attachment to PASID fail if device doesn't support dirty tracking. Suggested-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Reviewed-by: Yi Liu <yi.l.liu@intel.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Link: https://lore.kernel.org/r/20260330101108.12594-5-zhenzhong.duan@intel.com Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
1 parent ae2fafc commit c958721

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

tools/testing/selftests/iommu/iommufd.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2275,6 +2275,33 @@ TEST_F(iommufd_dirty_tracking, set_dirty_tracking)
22752275
test_ioctl_destroy(hwpt_id);
22762276
}
22772277

2278+
TEST_F(iommufd_dirty_tracking, pasid_set_dirty_tracking)
2279+
{
2280+
uint32_t stddev_id, ioas_id, hwpt_id, pasid = 100;
2281+
uint32_t dev_flags = MOCK_FLAGS_DEVICE_PASID;
2282+
2283+
/* Regular case */
2284+
test_cmd_hwpt_alloc(self->idev_id, self->ioas_id,
2285+
IOMMU_HWPT_ALLOC_PASID | IOMMU_HWPT_ALLOC_DIRTY_TRACKING,
2286+
&hwpt_id);
2287+
test_cmd_mock_domain_flags(hwpt_id, dev_flags, &stddev_id, NULL, NULL);
2288+
ASSERT_EQ(0, _test_cmd_pasid_attach(self->fd, stddev_id, pasid, hwpt_id));
2289+
test_cmd_set_dirty_tracking(hwpt_id, true);
2290+
test_cmd_set_dirty_tracking(hwpt_id, false);
2291+
ASSERT_EQ(0, _test_cmd_pasid_detach(self->fd, stddev_id, pasid));
2292+
2293+
test_ioctl_destroy(stddev_id);
2294+
2295+
/* IOMMU device does not support dirty tracking */
2296+
dev_flags |= MOCK_FLAGS_DEVICE_NO_DIRTY;
2297+
test_ioctl_ioas_alloc(&ioas_id);
2298+
test_cmd_mock_domain_flags(ioas_id, dev_flags, &stddev_id, NULL, NULL);
2299+
EXPECT_ERRNO(EINVAL, _test_cmd_pasid_attach(self->fd, stddev_id, pasid, hwpt_id));
2300+
2301+
test_ioctl_destroy(stddev_id);
2302+
test_ioctl_destroy(hwpt_id);
2303+
}
2304+
22782305
TEST_F(iommufd_dirty_tracking, device_dirty_capability)
22792306
{
22802307
uint32_t caps = 0;

0 commit comments

Comments
 (0)