Skip to content

Commit 52c9f93

Browse files
nathanchancectmarinas
authored andcommitted
arm64: Do not include __READ_ONCE() block in assembly files
When building arm64 defconfig + CONFIG_LTO_CLANG_{FULL,THIN}=y after commit 558c303 ("arm64: Mitigate spectre style branch history side channels"), the following error occurs: <instantiation>:4:2: error: invalid fixup for movz/movk instruction mov w0, #ARM_SMCCC_ARCH_WORKAROUND_3 ^ Marc figured out that moving "#include <linux/init.h>" in include/linux/arm-smccc.h into a !__ASSEMBLY__ block resolves it. The full include chain with CONFIG_LTO=y from include/linux/arm-smccc.h: include/linux/init.h include/linux/compiler.h arch/arm64/include/asm/rwonce.h arch/arm64/include/asm/alternative-macros.h arch/arm64/include/asm/assembler.h The asm/alternative-macros.h include in asm/rwonce.h only happens when CONFIG_LTO is set, which ultimately casues asm/assembler.h to be included before the definition of ARM_SMCCC_ARCH_WORKAROUND_3. As a result, the preprocessor does not expand ARM_SMCCC_ARCH_WORKAROUND_3 in __mitigate_spectre_bhb_fw, which results in the error above. Avoid this problem by just avoiding the CONFIG_LTO=y __READ_ONCE() block in asm/rwonce.h with assembly files, as nothing in that block is useful to assembly files, which allows ARM_SMCCC_ARCH_WORKAROUND_3 to be properly expanded with CONFIG_LTO=y builds. Fixes: e35123d ("arm64: lto: Strengthen READ_ONCE() to acquire when CONFIG_LTO=y") Cc: <[email protected]> # 5.11.x Link: https://lore.kernel.org/r/[email protected]/ Reported-by: Marc Zyngier <[email protected]> Acked-by: James Morse <[email protected]> Signed-off-by: Nathan Chancellor <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 58c9a50 commit 52c9f93

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/arm64/include/asm/rwonce.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#ifndef __ASM_RWONCE_H
66
#define __ASM_RWONCE_H
77

8-
#ifdef CONFIG_LTO
8+
#if defined(CONFIG_LTO) && !defined(__ASSEMBLY__)
99

1010
#include <linux/compiler_types.h>
1111
#include <asm/alternative-macros.h>
@@ -66,7 +66,7 @@
6666
})
6767

6868
#endif /* !BUILD_VDSO */
69-
#endif /* CONFIG_LTO */
69+
#endif /* CONFIG_LTO && !__ASSEMBLY__ */
7070

7171
#include <asm-generic/rwonce.h>
7272

0 commit comments

Comments
 (0)