All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] arm: Add return value argument to longjmp
@ 2016-09-27  7:30 Alexander Graf
  2016-09-27 17:55 ` Simon Glass
  2016-10-08 17:07 ` [U-Boot] " Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Alexander Graf @ 2016-09-27  7:30 UTC (permalink / raw)
  To: u-boot

The normal longjmp command allows for a caller to pass the return value
of the setjmp() invocation. This patch adds that semantic to the arm
implementation of it and adjusts the efi_loader call respectively.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 arch/arm/include/asm/setjmp.h | 32 ++++++++++++++------------------
 lib/efi_loader/efi_boottime.c |  2 +-
 2 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/arch/arm/include/asm/setjmp.h b/arch/arm/include/asm/setjmp.h
index f7b97ef..df9934b 100644
--- a/arch/arm/include/asm/setjmp.h
+++ b/arch/arm/include/asm/setjmp.h
@@ -11,29 +11,26 @@
 struct jmp_buf_data {
 	ulong target;
 	ulong regs[5];
+	int ret;
 };
 
 typedef struct jmp_buf_data jmp_buf[1];
 
 static inline int setjmp(jmp_buf jmp)
 {
-	long r = 0;
+	jmp->ret = 0;
 
 #ifdef CONFIG_ARM64
 	asm volatile(
 		"adr x1, jmp_target\n"
-		"str x1, %1\n"
-		"stp x26, x27, %2\n"
-		"stp x28, x29, %3\n"
+		"str x1, %0\n"
+		"stp x26, x27, %1\n"
+		"stp x28, x29, %2\n"
 		"mov x1, sp\n"
-		"str x1, %4\n"
-		"b 2f\n"
+		"str x1, %3\n"
 		"jmp_target: "
-		"mov %0, #1\n"
-		"2:\n"
-		: "+r" (r), "=m" (jmp->target),
-		  "=m" (jmp->regs[0]), "=m" (jmp->regs[2]),
-		  "=m" (jmp->regs[4])
+		: "=m" (jmp->target), "=m" (jmp->regs[0]),
+		  "=m" (jmp->regs[2]), "=m" (jmp->regs[4])
 		:
 		: "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7",
 		  "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15",
@@ -49,26 +46,25 @@ static inline int setjmp(jmp_buf jmp)
 #else
 		"adr r0, jmp_target\n"
 #endif
-		"mov r1, %1\n"
+		"mov r1, %0\n"
 		"mov r2, sp\n"
 		"stm r1!, {r0, r2, r4, r5, r6, r7}\n"
-		"b 2f\n"
 		".align 2\n"
 		"jmp_target: \n"
-		"mov %0, #1\n"
-		"2:\n"
-		: "+l" (r)
+		:
 		: "l" (&jmp->target)
 		: "r0", "r1", "r2", "r3", /* "r4", "r5", "r6", "r7", */
 		  "r8", "r9", "r10", "r11", /* sp, */ "ip", "lr",
 		  "cc", "memory");
 #endif
 
-	return r;
+	return jmp->ret;
 }
 
-static inline __noreturn void longjmp(jmp_buf jmp)
+static inline __noreturn void longjmp(jmp_buf jmp, int ret)
 {
+	jmp->ret = ret;
+
 #ifdef CONFIG_ARM64
 	asm volatile(
 		"ldr x0, %0\n"
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index be6f5e8..792db39 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -475,7 +475,7 @@ static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
 		  exit_data_size, exit_data);
 
 	loaded_image_info->exit_status = exit_status;
-	longjmp(&loaded_image_info->exit_jmp);
+	longjmp(&loaded_image_info->exit_jmp, 1);
 
 	panic("EFI application exited");
 }
-- 
1.8.5.6

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] arm: Add return value argument to longjmp
  2016-09-27  7:30 [U-Boot] [PATCH] arm: Add return value argument to longjmp Alexander Graf
@ 2016-09-27 17:55 ` Simon Glass
  2016-10-08 17:07 ` [U-Boot] " Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2016-09-27 17:55 UTC (permalink / raw)
  To: u-boot

On 27 September 2016 at 01:30, Alexander Graf <agraf@suse.de> wrote:
> The normal longjmp command allows for a caller to pass the return value
> of the setjmp() invocation. This patch adds that semantic to the arm
> implementation of it and adjusts the efi_loader call respectively.
>
> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>  arch/arm/include/asm/setjmp.h | 32 ++++++++++++++------------------
>  lib/efi_loader/efi_boottime.c |  2 +-
>  2 files changed, 15 insertions(+), 19 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] arm: Add return value argument to longjmp
  2016-09-27  7:30 [U-Boot] [PATCH] arm: Add return value argument to longjmp Alexander Graf
  2016-09-27 17:55 ` Simon Glass
@ 2016-10-08 17:07 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2016-10-08 17:07 UTC (permalink / raw)
  To: u-boot

On Tue, Sep 27, 2016 at 09:30:32AM +0200, Alexander Graf wrote:

> The normal longjmp command allows for a caller to pass the return value
> of the setjmp() invocation. This patch adds that semantic to the arm
> implementation of it and adjusts the efi_loader call respectively.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161008/14a1cd06/attachment.sig>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-10-08 17:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-27  7:30 [U-Boot] [PATCH] arm: Add return value argument to longjmp Alexander Graf
2016-09-27 17:55 ` Simon Glass
2016-10-08 17:07 ` [U-Boot] " Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.