From: Yi Liu <yi.l.liu@intel.com>
To: joro@8bytes.org, alex.williamson@redhat.com, jgg@nvidia.com,
kevin.tian@intel.com, robin.murphy@arm.com,
baolu.lu@linux.intel.com
Cc: cohuck@redhat.com, eric.auger@redhat.com, nicolinc@nvidia.com,
kvm@vger.kernel.org, mjrosato@linux.ibm.com,
chao.p.peng@linux.intel.com, yi.l.liu@intel.com,
yi.y.sun@linux.intel.com, peterx@redhat.com, jasowang@redhat.com,
shameerali.kolothum.thodi@huawei.com, lulu@redhat.com,
suravee.suthikulpanit@amd.com, iommu@lists.linux.dev,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
zhenzhong.duan@intel.com, joao.m.martins@oracle.com
Subject: [RFC 6/7] iommufd/selftest: Add test coverage for SIOV virtual device
Date: Mon, 9 Oct 2023 01:51:22 -0700 [thread overview]
Message-ID: <20231009085123.463179-7-yi.l.liu@intel.com> (raw)
In-Reply-To: <20231009085123.463179-1-yi.l.liu@intel.com>
This adds test coverage for SIOV virtual device by passsing a non-zero pasid
to IOMMU_TEST_OP_MOCK_DOMAIN op, and check if the SIOV virtual device (a.k.a
pasid of this device) is attached to the mock domain, then tries to replace
with a new hwpt and other types of hwpts, and check if the attached domain of
this virtual device is correct.
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
---
tools/testing/selftests/iommu/iommufd.c | 53 ++++++++++++++++++-
.../selftests/iommu/iommufd_fail_nth.c | 26 +++++++++
2 files changed, 77 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/iommu/iommufd.c b/tools/testing/selftests/iommu/iommufd.c
index 9a1fbba89e96..945ab07a8b84 100644
--- a/tools/testing/selftests/iommu/iommufd.c
+++ b/tools/testing/selftests/iommu/iommufd.c
@@ -2031,14 +2031,20 @@ FIXTURE(iommufd_device_pasid)
uint32_t device_id;
};
+FIXTURE_VARIANT(iommufd_device_pasid)
+{
+ uint32_t pasid;
+};
+
FIXTURE_SETUP(iommufd_device_pasid)
{
self->fd = open("/dev/iommu", O_RDWR);
ASSERT_NE(-1, self->fd);
test_ioctl_ioas_alloc(&self->ioas_id);
- test_cmd_mock_domain(self->ioas_id, 0, &self->stdev_id,
- &self->hwpt_id, &self->device_id);
+ test_cmd_mock_domain(self->ioas_id, variant->pasid,
+ &self->stdev_id, &self->hwpt_id,
+ &self->device_id);
}
FIXTURE_TEARDOWN(iommufd_device_pasid)
@@ -2046,6 +2052,12 @@ FIXTURE_TEARDOWN(iommufd_device_pasid)
teardown_iommufd(self->fd, _metadata);
}
+/* For SIOV test */
+FIXTURE_VARIANT_ADD(iommufd_device_pasid, siov_pasid_600)
+{
+ .pasid = 600, //this is the default pasid for the SIOV virtual device
+};
+
TEST_F(iommufd_device_pasid, pasid_attach)
{
if (self->device_id) {
@@ -2071,6 +2083,43 @@ TEST_F(iommufd_device_pasid, pasid_attach)
IOMMU_HWPT_ALLOC_DATA_SELFTEST,
&data, sizeof(data));
+ if (variant->pasid) {
+ uint32_t new_hwpt_id = 0;
+
+ ASSERT_EQ(0,
+ test_cmd_pasid_check_domain(self->fd,
+ self->stdev_id,
+ variant->pasid,
+ self->hwpt_id,
+ &result));
+ EXPECT_EQ(1, result);
+ test_cmd_hwpt_alloc(self->device_id, self->ioas_id,
+ 0, &new_hwpt_id);
+ test_cmd_mock_domain_replace(self->stdev_id,
+ new_hwpt_id);
+ ASSERT_EQ(0,
+ test_cmd_pasid_check_domain(self->fd,
+ self->stdev_id,
+ variant->pasid,
+ new_hwpt_id,
+ &result));
+ EXPECT_EQ(1, result);
+
+ /*
+ * Detach hwpt from variant->pasid, and check if the
+ * variant->pasid has null domain
+ */
+ test_cmd_pasid_detach(variant->pasid);
+ ASSERT_EQ(0,
+ test_cmd_pasid_check_domain(self->fd,
+ self->stdev_id,
+ variant->pasid,
+ 0, &result));
+ EXPECT_EQ(1, result);
+
+ test_ioctl_destroy(new_hwpt_id);
+ }
+
/*
* Attach ioas to pasid 100, should succeed, domain should
* be valid.
diff --git a/tools/testing/selftests/iommu/iommufd_fail_nth.c b/tools/testing/selftests/iommu/iommufd_fail_nth.c
index 691903c63de0..a5fb45d99869 100644
--- a/tools/testing/selftests/iommu/iommufd_fail_nth.c
+++ b/tools/testing/selftests/iommu/iommufd_fail_nth.c
@@ -644,6 +644,32 @@ TEST_FAIL_NTH(basic_fail_nth, device)
self->pasid = 0;
+ if (_test_ioctl_destroy(self->fd, self->stdev_id))
+ return -1;
+
+ self->pasid = 300;
+ self->stdev_id = 0;
+
+ /* Test for SIOV virtual devices attach */
+ if (_test_cmd_mock_domain(self->fd, ioas_id, self->pasid,
+ &self->stdev_id, NULL, &idev_id))
+ return -1;
+
+ /* Test for SIOV virtual device replace */
+ if (_test_cmd_mock_domain_replace(self->fd, self->stdev_id,
+ hwpt_id, NULL))
+ return -1;
+
+ if (_test_cmd_pasid_detach(self->fd, self->stdev_id, self->pasid))
+ return -1;
+
+ self->pasid = 0;
+
+ if (_test_ioctl_destroy(self->fd, self->stdev_id))
+ return -1;
+
+ self->stdev_id = 0;
+
return 0;
}
--
2.34.1
next prev parent reply other threads:[~2023-10-09 8:52 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-09 8:51 [RFC 0/7] Add SIOV virtual device support Yi Liu
2023-10-09 8:51 ` [RFC 1/7] iommufd: Handle unsafe interrupts in a separate function Yi Liu
2023-10-09 8:51 ` [RFC 2/7] iommufd: Introduce iommufd_alloc_device() Yi Liu
2023-10-09 8:51 ` [RFC 3/7] iommufd: Add iommufd_device_bind_pasid() Yi Liu
2023-10-10 8:19 ` Tian, Kevin
2023-11-08 7:45 ` Yi Liu
2023-11-08 8:46 ` Tian, Kevin
2023-11-08 9:03 ` Yi Liu
2023-10-09 8:51 ` [RFC 4/7] iommufd: Support attach/replace for SIOV virtual device {dev, pasid} Yi Liu
2023-10-10 8:24 ` Tian, Kevin
2023-11-09 8:21 ` Yi Liu
2023-10-09 8:51 ` [RFC 5/7] iommufd/selftest: Extend IOMMU_TEST_OP_MOCK_DOMAIN to pass in pasid Yi Liu
2023-10-10 8:25 ` Tian, Kevin
2023-10-09 8:51 ` Yi Liu [this message]
2023-10-10 8:30 ` [RFC 6/7] iommufd/selftest: Add test coverage for SIOV virtual device Tian, Kevin
2023-11-09 7:48 ` Yi Liu
2023-10-09 8:51 ` [RFC 7/7] vfio: Add vfio_register_pasid_iommu_dev() Yi Liu
2023-10-10 8:33 ` Tian, Kevin
2023-11-09 8:20 ` Yi Liu
2023-11-16 5:35 ` Cao, Yahui
2023-11-17 6:31 ` Yi Liu
[not found] ` <99115148-d0e3-4920-aed6-669ae45aa2fe@intel.com>
2023-11-17 6:30 ` Yi Liu
2023-10-09 13:21 ` [RFC 0/7] Add SIOV virtual device support Jason Gunthorpe
2023-10-09 23:33 ` Tian, Kevin
2023-11-22 3:59 ` Cao, Yahui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231009085123.463179-7-yi.l.liu@intel.com \
--to=yi.l.liu@intel.com \
--cc=alex.williamson@redhat.com \
--cc=baolu.lu@linux.intel.com \
--cc=chao.p.peng@linux.intel.com \
--cc=cohuck@redhat.com \
--cc=eric.auger@redhat.com \
--cc=iommu@lists.linux.dev \
--cc=jasowang@redhat.com \
--cc=jgg@nvidia.com \
--cc=joao.m.martins@oracle.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=lulu@redhat.com \
--cc=mjrosato@linux.ibm.com \
--cc=nicolinc@nvidia.com \
--cc=peterx@redhat.com \
--cc=robin.murphy@arm.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=yi.y.sun@linux.intel.com \
--cc=zhenzhong.duan@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®