[v2 PATCH] iommu/arm-smmu-v3: Fix L1 stream table index calculation for 32-bit sid size

Jason Gunthorpe jgg at ziepe.ca
Thu Oct 3 04:16:03 PDT 2024


On Wed, Oct 02, 2024 at 01:05:08PM -0700, Yang Shi wrote:
> > It would make some sense to have something like:
> > 
> >   u64 size = arm_smmu_strtab_max_sid()
> > 
> >   /* Would require too much memory */
> >   if (size > SZ_512M)
> >      return -EINVAL;
> 
> Why not just check smmu->sid_bits?
> 
> For example,
> 
> if (smmu->sid_bits > 28)
>     return -EINVAL;
> 
> The check can happen before the shift.

Sure, but IMHO it reads a bit better to check the size computed from
the helper

MAX_PAGE_ORDER is often 10, so kmalloc will always fail before we
reach 28 bits of sid space.

Jason



More information about the linux-arm-kernel mailing list