[PATCH] arm64: Fix bit-shifting UB in MIDR_AMPERE1
D Scott Phillips
scott at os.amperecomputing.com
Mon Oct 17 14:01:19 PDT 2022
CONFIG_UBSAN_SHIFT with gcc-5 complains that shifting ARM_CPU_IMP_AMPERE
(0xC0) into bits [31:24] is undefined behavior. Well, sort of, it actually
spells the error as:
/kisskb/src/arch/arm64/kernel/proton-pack.c: In function 'spectre_bhb_loop_affected':
/kisskb/src/arch/arm64/include/asm/cputype.h:44:2: error: initializer element is not constant
(((imp) << MIDR_IMPLEMENTOR_SHIFT) | \
^
This isn't an issue for other Implementor codes, as all the other codes
have zero in the top bit.
Fixes: 0e5d5ae837c8ce04 ("arm64: Add AMPERE1 to the Spectre-BHB affected list")
Reported-by: Geert Uytterhoeven <geert at linux-m68k.org>
Signed-off-by: D Scott Phillips <scott at os.amperecomputing.com>
---
arch/arm64/include/asm/cputype.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/cputype.h b/arch/arm64/include/asm/cputype.h
index abc418650fec..b28db64799eb 100644
--- a/arch/arm64/include/asm/cputype.h
+++ b/arch/arm64/include/asm/cputype.h
@@ -60,7 +60,7 @@
#define ARM_CPU_IMP_FUJITSU 0x46
#define ARM_CPU_IMP_HISI 0x48
#define ARM_CPU_IMP_APPLE 0x61
-#define ARM_CPU_IMP_AMPERE 0xC0
+#define ARM_CPU_IMP_AMPERE 0xC0u
#define ARM_CPU_PART_AEM_V8 0xD0F
#define ARM_CPU_PART_FOUNDATION 0xD00
--
2.37.3
More information about the linux-arm-kernel
mailing list