[PATCH v2] arm64: Fix bit-shifting UB in the MIDR_CPU_MODEL() macro

Catalin Marinas catalin.marinas at arm.com
Wed Nov 9 02:26:41 PST 2022


On Wed, 2 Nov 2022 09:01:06 -0700, D Scott Phillips wrote:
> CONFIG_UBSAN_SHIFT with gcc-5 complains that the shifting of
> ARM_CPU_IMP_AMPERE (0xC0) into bits [31:24] by MIDR_CPU_MODEL() is
> undefined behavior. Well, sort of, it actually spells the error as:
> 
>  arch/arm64/kernel/proton-pack.c: In function 'spectre_bhb_loop_affected':
>  arch/arm64/include/asm/cputype.h:44:2: error: initializer element is not constant
>    (((imp)   << MIDR_IMPLEMENTOR_SHIFT) | \
>    ^
> 
> [...]

Applied to arm64 (for-next/fixes), thanks!

[1/1] arm64: Fix bit-shifting UB in the MIDR_CPU_MODEL() macro
      https://git.kernel.org/arm64/c/8ec8490a1950

-- 
Catalin




More information about the linux-arm-kernel mailing list