[PATCH] arm64: Paper over ARM_SMCCC_ARCH_WORKAROUND_3 Clang issue
James Morse
james.morse at arm.com
Wed Mar 9 08:09:57 PST 2022
Hi Marc,
On 09/03/2022 15:57, Marc Zyngier wrote:
> Compiling the arm64 kernel with the BHB workarounds and Clang+LTO
> results in a bunch of:
>
> <instantiation>:4:2: error: invalid fixup for movz/movk instruction
> mov w0, #ARM_SMCCC_ARCH_WORKAROUND_3
>
> when compiling arch/arm64/kernel/entry.S, and makes no sense at all.
>
> As it turns out, moving a single include line around makes the
> problem disappear. Why, you'd ask? Well, I don't have the faintest
> idea, and I'm running out of patience. So make of that what you want.
Thanks for this - I've been banging my head against the keyboard too.
My attempt is below, maybe that helps the toolchain people pin it down.
Catalin doesn't like it as he sensibly wants to keep the sequences
together.
Acked-by: James Morse <james.morse at arm.com>
Tested-by: James Morse <james.morse at arm.com>
Thanks,
James
Build incantation: make LLVM=1 -s -j 56 LD=ld.lld-11
clang --version:
Debian clang version 12.0.0-++20200929085817+962a247aebb-1~exp1
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
The 'exp' in debian's clang version spooked me, but I can also reproduce this with
debian's clang-11:
make LLVM=1 -s -j 56 LD=ld.lld-11 CC=clang-11
clang-11 --version
Debian clang version 11.0.1-2
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Works, but equally inexplicable.
-----%<------
diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h
index 6ebdc0f834a7..fd83baf1c552 100644
--- a/arch/arm64/include/asm/assembler.h
+++ b/arch/arm64/include/asm/assembler.h
@@ -880,20 +880,6 @@ alternative_cb_end
#endif /* CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY */
.endm
- /* Save/restores x0-x3 to the stack */
- .macro __mitigate_spectre_bhb_fw
-#ifdef CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY
- stp x0, x1, [sp, #-16]!
- stp x2, x3, [sp, #-16]!
- mov w0, #ARM_SMCCC_ARCH_WORKAROUND_3
-alternative_cb smccc_patch_fw_mitigation_conduit
- nop // Patched to SMC/HVC #0
-alternative_cb_end
- ldp x2, x3, [sp], #16
- ldp x0, x1, [sp], #16
-#endif /* CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY */
- .endm
-
.macro mitigate_spectre_bhb_clear_insn
#ifdef CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY
alternative_cb spectre_bhb_patch_clearbhb
diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
index 4a3a653df07e..03fbb561dcb3 100644
--- a/arch/arm64/kernel/entry.S
+++ b/arch/arm64/kernel/entry.S
@@ -659,6 +659,20 @@ alternative_else_nop_endif
#define BHB_MITIGATION_FW 2
#define BHB_MITIGATION_INSN 3
+ /* Save/restores x0-x3 to the stack */
+ .macro __mitigate_spectre_bhb_fw
+#ifdef CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY
+ stp x0, x1, [sp, #-16]!
+ stp x2, x3, [sp, #-16]!
+ mov w0, #ARM_SMCCC_ARCH_WORKAROUND_3
+alternative_cb smccc_patch_fw_mitigation_conduit
+ nop // Patched to SMC/HVC #0
+alternative_cb_end
+ ldp x2, x3, [sp], #16
+ ldp x0, x1, [sp], #16
+#endif /* CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY */
+ .endm
+
.macro tramp_ventry, vector_start, regsize, kpti, bhb
.align 7
1:
-----%<------
More information about the linux-arm-kernel
mailing list