* [PATCH] iommufd/selftest: Check the bus type during probe
@ 2024-01-03 15:27 Jason Gunthorpe
2024-01-05 0:38 ` Tian, Kevin
0 siblings, 1 reply; 3+ messages in thread
From: Jason Gunthorpe @ 2024-01-03 15:27 UTC (permalink / raw)
To: iommu, Joerg Roedel, Kevin Tian, Will Deacon
Cc: Lu Baolu, Joerg Roedel, Jerry Snitselaar, patches, Robin Murphy
This relied on the probe function only being invoked by the bus type mock
was registered on. The removal of the bus ops broke this assumption and
the probe could be called on non-mock bus types like PCI.
Check the bus type directly in probe.
Fixes: 17de3f5fdd35 ("iommu: Retire bus ops")
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/iommu/iommufd/selftest.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
I'll pick this up for the merge window, it solves some of the issues. I'll
send a patch to iterate all the global binding drivers for rc1.
diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c
index 9528528cab2743..cf3e9fed039ee7 100644
--- a/drivers/iommu/iommufd/selftest.c
+++ b/drivers/iommu/iommufd/selftest.c
@@ -25,6 +25,19 @@ static struct iommu_domain_ops domain_nested_ops;
size_t iommufd_test_memory_limit = 65536;
+struct mock_bus_type {
+ struct bus_type bus;
+ struct notifier_block nb;
+};
+
+static struct mock_bus_type iommufd_mock_bus_type = {
+ .bus = {
+ .name = "iommufd_mock",
+ },
+};
+
+static atomic_t mock_dev_num;
+
enum {
MOCK_DIRTY_TRACK = 1,
MOCK_IO_PAGE_SIZE = PAGE_SIZE / 2,
@@ -437,6 +450,8 @@ static struct iommu_device mock_iommu_device = {
static struct iommu_device *mock_probe_device(struct device *dev)
{
+ if (dev->bus != &iommufd_mock_bus_type.bus)
+ return ERR_PTR(-ENODEV);
return &mock_iommu_device;
}
@@ -586,19 +601,6 @@ get_md_pagetable_nested(struct iommufd_ucmd *ucmd, u32 mockpt_id,
return hwpt;
}
-struct mock_bus_type {
- struct bus_type bus;
- struct notifier_block nb;
-};
-
-static struct mock_bus_type iommufd_mock_bus_type = {
- .bus = {
- .name = "iommufd_mock",
- },
-};
-
-static atomic_t mock_dev_num;
-
static void mock_dev_release(struct device *dev)
{
struct mock_dev *mdev = container_of(dev, struct mock_dev, dev);
base-commit: ca4a310350b8795802e392ce005fb17075345fac
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH] iommufd/selftest: Check the bus type during probe
2024-01-03 15:27 [PATCH] iommufd/selftest: Check the bus type during probe Jason Gunthorpe
@ 2024-01-05 0:38 ` Tian, Kevin
2024-01-05 19:49 ` Jason Gunthorpe
0 siblings, 1 reply; 3+ messages in thread
From: Tian, Kevin @ 2024-01-05 0:38 UTC (permalink / raw)
To: Jason Gunthorpe, iommu@lists.linux.dev, Joerg Roedel, Will Deacon
Cc: Lu Baolu, Rodel, Jorg, Jerry Snitselaar, patches@lists.linux.dev,
Robin Murphy
> From: Jason Gunthorpe <jgg@nvidia.com>
> Sent: Wednesday, January 3, 2024 11:27 PM
>
> This relied on the probe function only being invoked by the bus type mock
> was registered on. The removal of the bus ops broke this assumption and
> the probe could be called on non-mock bus types like PCI.
>
> Check the bus type directly in probe.
>
> Fixes: 17de3f5fdd35 ("iommu: Retire bus ops")
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iommufd/selftest: Check the bus type during probe
2024-01-05 0:38 ` Tian, Kevin
@ 2024-01-05 19:49 ` Jason Gunthorpe
0 siblings, 0 replies; 3+ messages in thread
From: Jason Gunthorpe @ 2024-01-05 19:49 UTC (permalink / raw)
To: Tian, Kevin
Cc: iommu@lists.linux.dev, Joerg Roedel, Will Deacon, Lu Baolu,
Rodel, Jorg, Jerry Snitselaar, patches@lists.linux.dev,
Robin Murphy
On Fri, Jan 05, 2024 at 12:38:49AM +0000, Tian, Kevin wrote:
> > From: Jason Gunthorpe <jgg@nvidia.com>
> > Sent: Wednesday, January 3, 2024 11:27 PM
> >
> > This relied on the probe function only being invoked by the bus type mock
> > was registered on. The removal of the bus ops broke this assumption and
> > the probe could be called on non-mock bus types like PCI.
> >
> > Check the bus type directly in probe.
> >
> > Fixes: 17de3f5fdd35 ("iommu: Retire bus ops")
> > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
>
> Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Applied to iommufd for-next
Thanks,
Jason
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-05 19:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-03 15:27 [PATCH] iommufd/selftest: Check the bus type during probe Jason Gunthorpe
2024-01-05 0:38 ` Tian, Kevin
2024-01-05 19:49 ` Jason Gunthorpe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.