Skip to contentSkip to conversation

efi_laoder: Call Exit() on return from payload in StartImage()

PATCH Superseded Alexander Graf 2 participants 2 messages Jan 25, 2018 – Jan 26, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efi_laoder: Call Exit() on return from payload in StartImage()

When a UEFI payload just returns instead of calling the Exit() callback, we handle that in efi_do_enter() and call Exit on its behalf, so that the loaded_image->exit_status value is correct.

We were missing that logic in StartImage(). Call it there too.

---
 lib/efi_loader/efi_boottime.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
lib/efi_loader/efi_boottime.c +7 -2
index f5dae40f06..4a36b62828 100644
@@ -1578,8 +1578,13 @@ static efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
 
 	ret = EFI_CALL(entry(image_handle, &systab));
 
-	/* Should usually never get here */
-	return EFI_EXIT(ret);
+	/*
+	 * Usually UEFI applications call Exit() instead of returning.
+	 * But because the world doesn not consist of ponies and unicorns,
+	 * we're happy to emulate that behavior on behalf of a payload
+	 * that forgot.
+	 */
+	return EFI_CALL(systab.boottime->exit(image_handle, ret, 0, NULL));
 }
 
 /*
Signature · 1 line
2.12.3
#1 lore raw

PATCH 1/1 efi_laoder: Call Exit() on return from payload in StartImage()

On 01/26/2018 12:53 AM, Alexander Graf wrote:

There is a typo in the subject "efi_laoder".

Quoted 33 lines

When a UEFI payload just returns instead of calling the Exit() callback, we handle that in efi_do_enter() and call Exit on its behalf, so that the loaded_image->exit_status value is correct.

We were missing that logic in StartImage(). Call it there too.

---
  lib/efi_loader/efi_boottime.c | 9 +++++++--
  1 file changed, 7 insertions(+), 2 deletions(-)
lib/efi_loader/efi_boottime.c +7 -2
index f5dae40f06..4a36b62828 100644
@@ -1578,8 +1578,13 @@ static efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
 
  	ret = EFI_CALL(entry(image_handle, &systab));
 
-	/* Should usually never get here */
-	return EFI_EXIT(ret);
+	/*
+	 * Usually UEFI applications call Exit() instead of returning.
+	 * But because the world doesn not consist of ponies and unicorns,
+	 * we're happy to emulate that behavior on behalf of a payload
+	 * that forgot.
+	 */
+	return EFI_CALL(systab.boottime->exit(image_handle, ret, 0, NULL));
  }
 
  /*