Thread (37 messages) read the whole thread 37 messages, 3 authors, 2024-02-20

RE: [PATCH v4 01/27] iommu/arm-smmu-v3: Check that the RID domain is S1 in SVA

From: Shameerali Kolothum Thodi <hidden>
Date: 2024-01-30 08:46:33
Also in: linux-iommu, linux-patches

quoted hunk ↗ jump to hunk
-----Original Message-----
From: Jason Gunthorpe <jgg@nvidia.com>
Sent: Friday, January 26, 2024 6:15 PM
To: iommu@lists.linux.dev; Joerg Roedel <joro@8bytes.org>; linux-arm-
kernel@lists.infradead.org; Robin Murphy [off-list ref]; Will
Deacon [off-list ref]
Cc: Eric Auger <eric.auger@redhat.com>; Jean-Philippe Brucker <jean-
philippe@linaro.org>; Moritz Fischer [off-list ref]; Michael Shavit
[off-list ref]; Nicolin Chen [off-list ref];
patches@lists.linux.dev; Shameerali Kolothum Thodi
[off-list ref]
Subject: [PATCH v4 01/27] iommu/arm-smmu-v3: Check that the RID domain is
S1 in SVA

This code only works if the RID domain is a S1 domain and has already
installed the cdtable.

Reviewed-by: Nicolin Chen <redacted>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c
b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c
index 05722121f00e70..b4549d698f3569 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c
@@ -387,7 +387,13 @@ static int __arm_smmu_sva_bind(struct device *dev,
struct mm_struct *mm)
 	struct arm_smmu_bond *bond;
 	struct arm_smmu_master *master = dev_iommu_priv_get(dev);
 	struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
-	struct arm_smmu_domain *smmu_domain =
to_smmu_domain(domain);
+	struct arm_smmu_domain *smmu_domain;
+
+	if (!(domain->type & __IOMMU_DOMAIN_PAGING))
+		return -ENODEV;
+	smmu_domain = to_smmu_domain(iommu_get_domain_for_dev(dev));
We already have the iommu_domain from above.
+	if (smmu_domain->stage != ARM_SMMU_DOMAIN_S1)
+		return -ENODEV;
I think we need to do the above checks in arm_smmu_sva_remove_dev_pasid()
as well.

Thanks,
Shameer

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help