summaryrefslogtreecommitdiffstats
path: root/arch/arm/include/asm/current.h
diff options
context:
space:
mode:
authorArd Biesheuvel <ardb@kernel.org>2021-12-24 10:31:00 +0100
committerRussell King (Oracle) <rmk+kernel@armlinux.org.uk>2022-01-06 13:58:58 +0100
commit5fe41793bc78d9bb47fea37d1a16984ad6cf294b (patch)
tree697f185af991330149195a761e6721c081f5beef /arch/arm/include/asm/current.h
parentARM: 9177/1: disable vmap'ed stacks on suspend-capable SMP configs (diff)
downloadlinux-5fe41793bc78d9bb47fea37d1a16984ad6cf294b.tar.xz
linux-5fe41793bc78d9bb47fea37d1a16984ad6cf294b.zip
ARM: 9176/1: avoid literal references in inline assembly
Nathan reports that the new get_current() and per-CPU offset accessors may cause problems at build time due to the use of a literal to hold the address of the respective variables. This is due to the fact that LLD before v14 does not support the PC-relative group relocations that are normally used for this, and the fallback relies on literals but does not emit the literal pools explictly using the .ltorg directive. ./arch/arm/include/asm/current.h:53:6: error: out of range pc-relative fixup value asm(LOAD_SYM_ARMV6(%0, __current) : "=r"(cur)); ^ ./arch/arm/include/asm/insn.h:25:2: note: expanded from macro 'LOAD_SYM_ARMV6' " ldr " #reg ", =" #sym " nt" ^ <inline asm>:1:3: note: instantiated into assembly here ldr r0, =__current ^ Since emitting a literal pool in this particular case is not possible, let's avoid the LOAD_SYM_ARMV6() entirely, and use the ordinary C assigment instead. As it turns out, there are other such cases, and here, using .ltorg to emit the literal pool within range of the LDR instruction would be possible due to the presence of an unconditional branch right after it. Unfortunately, putting .ltorg directives in subsections appears to confuse the Clang inline assembler, resulting in similar errors even though the .ltorg is most definitely within range. So let's fix this by emitting the literal explicitly, and not rely on the assembler to figure this out. This means we have move the fallback out of the LOAD_SYM_ARMV6() macro and into the callers. Link: https://github.com/ClangBuiltLinux/linux/issues/1551 Fixes: 9c46929e7989 ("ARM: implement THREAD_INFO_IN_TASK for uniprocessor systems") Reported-by: Nathan Chancellor <natechancellor@gmail.com> Tested-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Diffstat (limited to 'arch/arm/include/asm/current.h')
-rw-r--r--arch/arm/include/asm/current.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/arch/arm/include/asm/current.h b/arch/arm/include/asm/current.h
index 69ecf4c6c725..2f9d79214b25 100644
--- a/arch/arm/include/asm/current.h
+++ b/arch/arm/include/asm/current.h
@@ -37,8 +37,16 @@ static inline __attribute_const__ struct task_struct *get_current(void)
#ifdef CONFIG_CPU_V6
"1: \n\t"
" .subsection 1 \n\t"
+#if !(defined(MODULE) && defined(CONFIG_ARM_MODULE_PLTS)) && \
+ !(defined(CONFIG_LD_IS_LLD) && CONFIG_LLD_VERSION < 140000)
"2: " LOAD_SYM_ARMV6(%0, __current) " \n\t"
" b 1b \n\t"
+#else
+ "2: ldr %0, 3f \n\t"
+ " ldr %0, [%0] \n\t"
+ " b 1b \n\t"
+ "3: .long __current \n\t"
+#endif
" .previous \n\t"
" .pushsection \".alt.smp.init\", \"a\" \n\t"
" .long 0b - . \n\t"
@@ -46,8 +54,9 @@ static inline __attribute_const__ struct task_struct *get_current(void)
" .popsection \n\t"
#endif
: "=r"(cur));
-#elif __LINUX_ARM_ARCH__>=7 || \
- (defined(MODULE) && defined(CONFIG_ARM_MODULE_PLTS))
+#elif __LINUX_ARM_ARCH__>= 7 || \
+ (defined(MODULE) && defined(CONFIG_ARM_MODULE_PLTS)) || \
+ (defined(CONFIG_LD_IS_LLD) && CONFIG_LLD_VERSION < 140000)
cur = __current;
#else
asm(LOAD_SYM_ARMV6(%0, __current) : "=r"(cur));