aboutsummaryrefslogtreecommitdiff
path: root/tools/testing/selftests/iommu/iommufd_utils.h
diff options
context:
space:
mode:
authorGravatar Joao Martins <joao.m.martins@oracle.com> 2023-10-24 14:51:04 +0100
committerGravatar Jason Gunthorpe <jgg@nvidia.com> 2023-10-24 11:58:44 -0300
commite04b23c8d4ed977dbab4a4159f9e4d9a878b5c65 (patch)
treea65f83d7ffc22e319fdb155d14217a781b778552 /tools/testing/selftests/iommu/iommufd_utils.h
parentiommu/vt-d: Access/Dirty bit support for SS domains (diff)
downloadlinux-e04b23c8d4ed977dbab4a4159f9e4d9a878b5c65.tar.gz
linux-e04b23c8d4ed977dbab4a4159f9e4d9a878b5c65.tar.bz2
linux-e04b23c8d4ed977dbab4a4159f9e4d9a878b5c65.zip
iommufd/selftest: Expand mock_domain with dev_flags
Expand mock_domain test to be able to manipulate the device capabilities. This allows testing with mockdev without dirty tracking support advertised and thus make sure enforce_dirty test does the expected. To avoid breaking IOMMUFD_TEST UABI replicate the mock_domain struct and thus add an input dev_flags at the end. Link: https://lore.kernel.org/r/20231024135109.73787-14-joao.m.martins@oracle.com Signed-off-by: Joao Martins <joao.m.martins@oracle.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Diffstat (limited to 'tools/testing/selftests/iommu/iommufd_utils.h')
-rw-r--r--tools/testing/selftests/iommu/iommufd_utils.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/testing/selftests/iommu/iommufd_utils.h b/tools/testing/selftests/iommu/iommufd_utils.h
index be4970a84977..1e0736adc991 100644
--- a/tools/testing/selftests/iommu/iommufd_utils.h
+++ b/tools/testing/selftests/iommu/iommufd_utils.h
@@ -74,6 +74,35 @@ static int _test_cmd_mock_domain(int fd, unsigned int ioas_id, __u32 *stdev_id,
EXPECT_ERRNO(_errno, _test_cmd_mock_domain(self->fd, ioas_id, \
stdev_id, hwpt_id, NULL))
+static int _test_cmd_mock_domain_flags(int fd, unsigned int ioas_id,
+ __u32 stdev_flags, __u32 *stdev_id,
+ __u32 *hwpt_id, __u32 *idev_id)
+{
+ struct iommu_test_cmd cmd = {
+ .size = sizeof(cmd),
+ .op = IOMMU_TEST_OP_MOCK_DOMAIN_FLAGS,
+ .id = ioas_id,
+ .mock_domain_flags = { .dev_flags = stdev_flags },
+ };
+ int ret;
+
+ ret = ioctl(fd, IOMMU_TEST_CMD, &cmd);
+ if (ret)
+ return ret;
+ if (stdev_id)
+ *stdev_id = cmd.mock_domain_flags.out_stdev_id;
+ assert(cmd.id != 0);
+ if (hwpt_id)
+ *hwpt_id = cmd.mock_domain_flags.out_hwpt_id;
+ if (idev_id)
+ *idev_id = cmd.mock_domain_flags.out_idev_id;
+ return 0;
+}
+#define test_err_mock_domain_flags(_errno, ioas_id, flags, stdev_id, hwpt_id) \
+ EXPECT_ERRNO(_errno, \
+ _test_cmd_mock_domain_flags(self->fd, ioas_id, flags, \
+ stdev_id, hwpt_id, NULL))
+
static int _test_cmd_mock_domain_replace(int fd, __u32 stdev_id, __u32 pt_id,
__u32 *hwpt_id)
{