Message ID | 16-v2-de8b10590bf5+400-smmuv3_newapi_p1_jgg@nvidia.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Update SMMUv3 to the modern iommu API (part 1/3) | expand |
On Tue, Nov 14, 2023 at 1:53 AM Jason Gunthorpe <jgg@nvidia.com> wrote: > > Using the same design as the IDENTITY domain install an > STRTAB_STE_0_CFG_ABORT STE. > > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Michael Shavit <mshavit@google.com> Are there any subtle observable changes hidden here? IIUC the iommu framework would have previously installed an empty UNMANAGED domain but will now end up installing an abort STE instead. > --- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > index d6f68a6187d290..48981c2ff7a746 100644 > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > @@ -2647,6 +2647,24 @@ static struct iommu_domain arm_smmu_identity_domain = { > .ops = &arm_smmu_identity_ops, > }; > > +static int arm_smmu_attach_dev_blocked(struct iommu_domain *domain, > + struct device *dev) > +{ > + struct arm_smmu_ste ste; > + > + arm_smmu_make_abort_ste(&ste); > + return arm_smmu_attach_dev_ste(dev, &ste); > +} > + > +static const struct iommu_domain_ops arm_smmu_blocked_ops = { > + .attach_dev = arm_smmu_attach_dev_blocked, > +}; > + > +static struct iommu_domain arm_smmu_blocked_domain = { > + .type = IOMMU_DOMAIN_BLOCKED, > + .ops = &arm_smmu_blocked_ops, > +}; > + > static int arm_smmu_map_pages(struct iommu_domain *domain, unsigned long iova, > phys_addr_t paddr, size_t pgsize, size_t pgcount, > int prot, gfp_t gfp, size_t *mapped) > @@ -3040,6 +3058,7 @@ static void arm_smmu_remove_dev_pasid(struct device *dev, ioasid_t pasid) > > static struct iommu_ops arm_smmu_ops = { > .identity_domain = &arm_smmu_identity_domain, > + .blocked_domain = &arm_smmu_blocked_domain, > .capable = arm_smmu_capable, > .domain_alloc = arm_smmu_domain_alloc, > .probe_device = arm_smmu_probe_device, > -- > 2.42.0 >
On Wed, Nov 15, 2023 at 11:57:39PM +0800, Michael Shavit wrote: > On Tue, Nov 14, 2023 at 1:53 AM Jason Gunthorpe <jgg@nvidia.com> wrote: > > > > Using the same design as the IDENTITY domain install an > > STRTAB_STE_0_CFG_ABORT STE. > > > > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> > Reviewed-by: Michael Shavit <mshavit@google.com> > > Are there any subtle observable changes hidden here? IIUC the iommu > framework would have previously installed an empty UNMANAGED domain > but will now end up installing an abort STE instead. I don't think meaningfully. The empty UNMANAGED domain is a fallback for drivers that don't natively support BLOCKED. SMMUv3 already uses ABORT for this use case in the pre-boot and unattached devices flows, so if there is something wrong we have an existing issue already. I suspect there are slight differences about what gets logged if a DMA hits ABORT vs UNMANAGED, but not material. Thanks, Jason
On Mon, Nov 13, 2023 at 01:53:23PM -0400, Jason Gunthorpe wrote: > Using the same design as the IDENTITY domain install an > STRTAB_STE_0_CFG_ABORT STE. > > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>
diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index d6f68a6187d290..48981c2ff7a746 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2647,6 +2647,24 @@ static struct iommu_domain arm_smmu_identity_domain = { .ops = &arm_smmu_identity_ops, }; +static int arm_smmu_attach_dev_blocked(struct iommu_domain *domain, + struct device *dev) +{ + struct arm_smmu_ste ste; + + arm_smmu_make_abort_ste(&ste); + return arm_smmu_attach_dev_ste(dev, &ste); +} + +static const struct iommu_domain_ops arm_smmu_blocked_ops = { + .attach_dev = arm_smmu_attach_dev_blocked, +}; + +static struct iommu_domain arm_smmu_blocked_domain = { + .type = IOMMU_DOMAIN_BLOCKED, + .ops = &arm_smmu_blocked_ops, +}; + static int arm_smmu_map_pages(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, size_t pgsize, size_t pgcount, int prot, gfp_t gfp, size_t *mapped) @@ -3040,6 +3058,7 @@ static void arm_smmu_remove_dev_pasid(struct device *dev, ioasid_t pasid) static struct iommu_ops arm_smmu_ops = { .identity_domain = &arm_smmu_identity_domain, + .blocked_domain = &arm_smmu_blocked_domain, .capable = arm_smmu_capable, .domain_alloc = arm_smmu_domain_alloc, .probe_device = arm_smmu_probe_device,
Using the same design as the IDENTITY domain install an STRTAB_STE_0_CFG_ABORT STE. Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)