Skip to contentSkip to conversation

armv8: Skip PIE in SPL due to load alignment fault.

PATCH In review Kevin Chen 2 participants 2 messages Aug 3, 2023 – Aug 18, 2023 Arm (32-bit)

lore
Share & tools
lore

Kevin Chen

author
#0 lore raw

PATCH 1/1 armv8: Skip PIE in SPL due to load alignment fault.

When PIE is enabled in start.S, u-boot/-spl use __rel_dyn_start and _rel_dyn_end symbol to be loaded to and executed at a different address than it was linked at.

u-boot-spl.lds is used in SPL build, but relocation information section(.rela*) were discarded.
In line number 80 in arch/arm/cpu/armv8/u-boot-spl.lds
/DISCARD/ : { *(.rela*) }

If PIE enabled in SPL, __rel_dyn_start which is defined as .rel_dyn_start in sections.c will be apended to the end of .bss section.

In our ASPEED case, size of .bss section would let .rel_dyn_start without 8-byte alignment, leading to alignment fault when executing ldp instuction in pie_fix_loop.

---
 arch/arm/cpu/armv8/start.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/cpu/armv8/start.S +1 -1
index f3ea858577..6cc1d26e5e 100644
@@ -58,7 +58,7 @@ reset:
 .globl	save_boot_params_ret
 save_boot_params_ret:
 
-#if CONFIG_POSITION_INDEPENDENT
+#if CONFIG_POSITION_INDEPENDENT && !defined(CONFIG_SPL_BUILD)
 	/* Verify that we're 4K aligned.  */
 	adr	x0, _start
 	ands	x0, x0, #0xfff
Signature · 1 line
2.41.0
#1 lore raw
Quoted 13 lines · Kevin Chen

When PIE is enabled in start.S, u-boot/-spl use __rel_dyn_start and _rel_dyn_end symbol to be loaded to and executed at a different address than it was linked at.

u-boot-spl.lds is used in SPL build, but relocation information section(.rela*) were discarded.
In line number 80 in arch/arm/cpu/armv8/u-boot-spl.lds
/DISCARD/ : { *(.rela*) }

If PIE enabled in SPL, __rel_dyn_start which is defined as .rel_dyn_start in sections.c will be apended to the end of .bss section.

Quoted 5 lines

In our ASPEED case, size of .bss section would let .rel_dyn_start without 8-byte alignment, leading to alignment fault when executing ldp instuction in pie_fix_loop.

Applied to u-boot/next, thanks!

Signature · 1 line
Tom