Re: [PATCH] arm64: cputype: Avoid overflow using MIDR_IMPLEMENTOR_MASK

From: Catalin Marinas
Date: Wed May 04 2022 - 06:52:15 EST


On Tue, Apr 26, 2022 at 09:06:03AM +0200, Michal Orzel wrote:
> Value of macro MIDR_IMPLEMENTOR_MASK exceeds the range of integer
> and can lead to overflow. Currently there is no issue as it is used
> in expressions implicitly casting it to u32. To avoid possible
> problems, fix the macro.
>
> Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
> ---
> Should we also add a U suffix to ARM_CPU_IMP_* macros that are also shifted
> by MIDR_IMPLEMENTOR_SHIFT? None of them has bit 7 set but we could take some
> precaution steps.

I'm ok with not adding it now. We haven't been consistent with this but
we did encounter a few issues in the past with other bits and only fixed
those that were touching bit 31.

--
Catalin