[PATCH 04/19] iommu/arm-smmu-v3: Make STE programming independent of the callers

Michael Shavit mshavit at google.com
Wed Jan 3 08:47:07 PST 2024


On Wed, Jan 3, 2024 at 11:49 PM Jason Gunthorpe <jgg at nvidia.com> wrote:
>
> On Wed, Jan 03, 2024 at 11:42:50PM +0800, Michael Shavit wrote:
> > On Wed, Dec 27, 2023 at 11:46 PM Jason Gunthorpe <jgg at nvidia.com> wrote:
> > >
> > >        } else { // hweight8 == 0
> > >              set(qword_start=0,qword_end=N);
> > >        }
> > About this branch: wouldn't it be more clear to explicitly do nothing
> > or warn if any of the bits differ? We shouldn't ever expect to see the
> > STE differ in unused-bits position.
>
> Right, it should be impossible considering the used consistency check,
> but if we do hit this case for some future bug the right thing to do
> is fix it up and keep going. A WARN_ONCE would be good
>
> If we get here and set does actually make a change it will be to
> change an unused bit which is 1 to a 0, and we've already taken the
> position in this logic that is something we want to correct.
>
> As before since set should skip the sync if no bits change this is
> effectively a NOP.

Yeah I realize it's a NOP, it's just a question of clarity. Having a
call to set() without a warn or a comment could mislead readers into
thinking that this is a valid branch rather than a bug-catching
branch.



More information about the linux-arm-kernel mailing list