[PATCH v4 01/27] iommu/arm-smmu-v3: Check that the RID domain is S1 in SVA
Shameerali Kolothum Thodi
shameerali.kolothum.thodi at huawei.com
Tue Jan 30 00:46:10 PST 2024
> -----Original Message-----
> From: Jason Gunthorpe <jgg at nvidia.com>
> Sent: Friday, January 26, 2024 6:15 PM
> To: iommu at lists.linux.dev; Joerg Roedel <joro at 8bytes.org>; linux-arm-
> kernel at lists.infradead.org; Robin Murphy <robin.murphy at arm.com>; Will
> Deacon <will at kernel.org>
> Cc: Eric Auger <eric.auger at redhat.com>; Jean-Philippe Brucker <jean-
> philippe at linaro.org>; Moritz Fischer <mdf at kernel.org>; Michael Shavit
> <mshavit at google.com>; Nicolin Chen <nicolinc at nvidia.com>;
> patches at lists.linux.dev; Shameerali Kolothum Thodi
> <shameerali.kolothum.thodi at huawei.com>
> 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 <nicolinc at nvidia.com>
> Signed-off-by: Jason Gunthorpe <jgg at 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
More information about the linux-arm-kernel
mailing list