[PATCH v7 06/14] iommu/arm-smmu-v3: Do not use master->sva_enable to restrict attaches

Nicolin Chen nicolinc at nvidia.com
Mon May 13 13:58:04 PDT 2024


On Sun, May 12, 2024 at 11:01:32PM -0700, Nicolin Chen wrote:
> On Wed, May 08, 2024 at 03:57:14PM -0300, Jason Gunthorpe wrote:
> > We no longer need a master->sva_enable to control what attaches are
> > allowed. Instead we can tell if the attach is legal based on the current
> > configuration of the master.
> > 
> > Keep track of the number of valid CD entries for SSID's in the cd_table
> > and if the cd_table has been installed in the STE directly so we know what
> > the configuration is.
> > 
> > The attach logic is then made into:
> >  - SVA bind, check if the CD is installed
> >  - RID attach of S2, block if SSIDs are used
> >  - RID attach of IDENTITY/BLOCKING, block if SSIDs are used
> > 
> > Signed-off-by: Jason Gunthorpe <jgg at nvidia.com>
> > ---
> >  .../iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c   |  2 +-
> >  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c   | 24 +++++++++----------
> >  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h   |  7 ++++++
> >  3 files changed, 20 insertions(+), 13 deletions(-)
> > 
> > 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 d31caceb584984..7627cb53da55b9 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
> > @@ -628,7 +628,7 @@ static int arm_smmu_sva_set_dev_pasid(struct iommu_domain *domain,
> >  	struct arm_smmu_cd target;
> >  	int ret;
> >  
> > -	if (mm_get_enqcmd_pasid(mm) != id)
> > +	if (mm_get_enqcmd_pasid(mm) != id || !master->cd_table.in_ste)
> >  		return -EINVAL;
> 
> The in_ste is added in PATCH-2 and the new arm_smmu_set_pasid()
> in the same patch is also guarded by the in_ste. So, it feels a
> little more related by moving this check here into PATCH-2 too?

Actually, I found this in_ste sanity gets removed in PATCH-10.
I assume we rely on the same sanity in the arm_smmu_set_pasid()
instead?

If so, this sanity exists already in the arm_smmu_set_pasid()
in the code that this patch applies to. So, could we just start
to rely on that here, instead of adding this additional in_ste
sanity in this patch?

Thanks
Nicolin



More information about the linux-arm-kernel mailing list