Skip to contentSkip to conversation

hexagon: constant-extend head.S calls to out-of-file symbols

PATCH New Tzu-Ching Yang 1 participant 1 message Nov 21 Qualcomm hexagon architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hexagon: constant-extend head.S calls to out-of-file symbols

From: Brian Cain <[email protected]>

Every call in head.S before this point targets a symbol defined
elsewhere: __vmnewmap and __vmsetvec in vm_ops.S, memset in lib/, and start_kernel in init/main.c. The distance to each is whatever the linker happens to lay out, not something the assembler can bound at compile time.

The ld.lld versions used during this port have had bugs in exactly this area -- miscalculating a compact PC-relative call's relocation range, and not always synthesizing a trampoline when a call genuinely didn't reach -- so a call that link-checks fine today is not a guarantee it still will after the next relayout or the next linker. Constant-extend all five so the encoding carries the full address and neither of those failure modes is reachable, independent of link layout or which lld is in use.

Without this, allmodconfig does not link with LLVM 17 and 18, as ld.lld before 19.1.5 checks R_HEX_B22_PCREL against 2 MiB instead of 8 MiB [1] and the first four calls span 2.14 to 2.15 MiB in v7.4-rc1 with LLVM 17.0.1:

ld.lld: error: vmlinux.a(arch/hexagon/kernel/head.o):
(.init.text+0xd4): relocation R_HEX_B22_PCREL out of range: 2242552 is not in [-2097152, 2097151]; references '__vmnewmap'

---
Brian, as you agreed in your reply to my report, this is 09df35bd9d9f from your hexagon-qemu-virt branch rebased onto hexagon-fixes (0304683b4c43). The five changed lines are the same as yours; only the context differs. I added the allmodconfig paragraph with the error message and the two Link tags; please edit or drop them as you see fit.

I did not add a stable tag; you may want to add one, as v7.3.4 fails in the same way and v6.18.63 with LLVM 17.0.1 only. The patch applies to both, and to v7.4-rc1 and next-20261113.

On each of these trees and on hexagon-fixes, the patch gives the head.S I tested for the report linked in the changelog.

 arch/hexagon/kernel/head.S | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
arch/hexagon/kernel/head.S +5 -5
index 908ffece9132..cdd14403491b 100644
@@ -119,7 +119,7 @@ ENTRY(stext)
 	 * vm_ops.S
 	 */
 	r1 = #VM_TRANS_TYPE_TABLE
-	call	__vmnewmap;
+	call	##__vmnewmap;
 
 	/*  Jump into virtual address range.  */
 
@@ -155,12 +155,12 @@ __head_s_vaddr_target:
 
 	r0 = r24
 	r1 = #VM_TRANS_TYPE_TABLE
-	call __vmnewmap
+	call ##__vmnewmap
 
 	/*  Go ahead and install the trap0 return so angel calls work  */
 	r0.h = #hi(_K_provisional_vec)
 	r0.l = #lo(_K_provisional_vec)
-	call __vmsetvec
+	call ##__vmsetvec
 
 	/*
 	 * OK, at this point we should start to be much more careful,
@@ -195,7 +195,7 @@ __head_s_vaddr_target:
 	{ r0.H = #HI(__bss_start);           r2.h = #HI(__bss_stop); }
 
 	r2 = sub(r2,r0);
-	call memset;
+	call ##memset;
 
 	/*  Set PHYS_OFFSET; should be in R25 */
 #ifdef CONFIG_HEXAGON_PHYS_OFFSET
@@ -205,7 +205,7 @@ __head_s_vaddr_target:
 #endif
 
 	/* Time to make the doughnuts.   */
-	call start_kernel
+	call ##start_kernel
 
 	/*
 	 * Should not reach here.

base-commit: 0304683b4c43048082483e9445fdd0691d088431

Signature · 1 line
2.34.1