All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] efi_loader: Fix efi_exit gd clobbering
@ 2017-09-03 12:17 Alexander Graf
  0 siblings, 0 replies; only message in thread
From: Alexander Graf @ 2017-09-03 12:17 UTC (permalink / raw)
  To: u-boot

Commit f494950b (efi_loader: call __efi_exit_check in efi_exit) added a call
to __efi_exit_check inside efi_exit to account for the fact that we're exiting
the efi_exit function via a longjmp call.

However, __efi_exit_check also swizzles gd to the application gd while the
longjmp will put us back into EFI context, so we need the efi (u-boot) gd.

This patch fixes that up by explicitly setting gd back to efi_gd before
doing the longjmp. It also adds a few comments on why it does that.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 lib/efi_loader/efi_boottime.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 99c5a6ee0c..90e9ead7b2 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -798,8 +798,15 @@ static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
 	EFI_ENTRY("%p, %ld, %ld, %p", image_handle, exit_status,
 		  exit_data_size, exit_data);
 
+	/* Make sure entry/exit counts for EFI world cross-overs match */
 	__efi_exit_check();
 
+	/*
+	 * But longjmp out with the U-Boot gd, not the application's, as
+	 * the other end is a setjmp call inside EFI context.
+	 */
+	efi_restore_gd();
+
 	loaded_image_info->exit_status = exit_status;
 	longjmp(&loaded_image_info->exit_jmp, 1);
 
-- 
2.12.3

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-09-03 12:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-03 12:17 [U-Boot] [PATCH] efi_loader: Fix efi_exit gd clobbering Alexander Graf

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.