[U-Boot] efi_loader: arch/arm/include/asm/setjmp.h

Alexander Graf agraf at suse.de
Mon Oct 9 05:09:54 UTC 2017



On 07.10.17 22:23, Heinrich Schuchardt wrote:
> Hello Alex,
> 
> our current logic for removing the handler of the loaded image is wrong:
> 
> If a driver image calls Exit() with EFI_SUCCESS the image has to remain.
> 
> I tried to rework the logic and needed a second setjmp in cmd/bootefi.c
> to handle 'bootefi selftest'.
> 
> On arm this resulted in:
> 
> Building current source for 1 boards (1 thread, 4 jobs per thread)
>        arm:  +   vexpress_ca15_tc2
> +{standard input}: Assembler messages:
> +{standard input}:638: Error: symbol `jmp_target' is already defined
> +{standard input}:633: Error: symbol .text.do_bootefi_exec is in a
> different section
> +make[2]: *** [cmd/bootefi.o] Error 1
> +make[1]: *** [cmd] Error 2
> +make: *** [sub-make] Error 2
> 
> All registers that have to be restored should be stored in jmp_buf and
> not at any static address (jmp_target).

jmp_target is not an address to store things at, it's an address to jump
to :). We just happen to define the same label twice because of inlining.

Does the patch below fix it for you?

Either way, Philipp rewrote all of the setjmp/longjmp code anyway in his
rockchip patch set.

Philipp, what path do you expect that to take? Should we fix the in-tree
setjmp or just apply yours?


Alex


diff --git a/arch/arm/include/asm/setjmp.h b/arch/arm/include/asm/setjmp.h
index c3399a7e15..2c58e2819e 100644
--- a/arch/arm/include/asm/setjmp.h
+++ b/arch/arm/include/asm/setjmp.h
@@ -22,13 +22,13 @@ static inline int setjmp(jmp_buf jmp)

 #ifdef CONFIG_ARM64
 	asm volatile(
-		"adr x1, jmp_target\n"
+		"adr x1, 1f\n"
 		"str x1, %0\n"
 		"stp x26, x27, %1\n"
 		"stp x28, x29, %2\n"
 		"mov x1, sp\n"
 		"str x1, %3\n"
-		"jmp_target: "
+		"1: "
 		: "=m" (jmp->target), "=m" (jmp->regs[0]),
 		  "=m" (jmp->regs[2]), "=m" (jmp->regs[4])
 		:
@@ -41,16 +41,16 @@ static inline int setjmp(jmp_buf jmp)
 	asm volatile(
 #if CONFIG_IS_ENABLED(SYS_THUMB_BUILD)
 		".align 2\n"
-		"adr r0, jmp_target\n"
+		"adr r0, 1f\n"
 		"add r0, r0, $1\n"
 #else
-		"adr r0, jmp_target\n"
+		"adr r0, 1f\n"
 #endif
 		"mov r1, %0\n"
 		"mov r2, sp\n"
 		"stm r1!, {r0, r2, r4, r5, r6, r7}\n"
 		".align 2\n"
-		"jmp_target: \n"
+		"1: \n"
 		:
 		: "l" (&jmp->target)
 		: "r0", "r1", "r2", "r3", /* "r4", "r5", "r6", "r7", */


More information about the U-Boot mailing list