linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] efi/libstub/x86: deal with exit() boot service returning
@ 2020-03-03  8:06 Ard Biesheuvel
  2020-03-03  8:22 ` Nathan Chancellor
  0 siblings, 1 reply; 2+ messages in thread
From: Ard Biesheuvel @ 2020-03-03  8:06 UTC (permalink / raw)
  To: linux-efi; +Cc: Ard Biesheuvel, Nathan Chancellor

Even though it is uncommon, there are cases where the Exit() EFI boot
service might return, e.g., when we were booted via the EFI handover
protocol from OVMF and the kernel image was specified on the command
line, in which case Exit() attempts to terminate the boot manager,
which is not an EFI application itself. So let's drop into a deadloop
instead.

Cc: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
As a side effect, this also fixes [0], which is as yet undiagnosed.

[0] https://github.com/ClangBuiltLinux/linux/issues/917

 drivers/firmware/efi/libstub/x86-stub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
index 7f3e97c2aad3..5c7480c4d379 100644
--- a/drivers/firmware/efi/libstub/x86-stub.c
+++ b/drivers/firmware/efi/libstub/x86-stub.c
@@ -344,7 +344,7 @@ static void setup_graphics(struct boot_params *boot_params)
 static void __noreturn efi_exit(efi_handle_t handle, efi_status_t status)
 {
 	efi_bs_call(exit, handle, status, 0, NULL);
-	unreachable();
+	for(;;);
 }
 
 void startup_32(struct boot_params *boot_params);
-- 
2.17.1


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

* Re: [PATCH] efi/libstub/x86: deal with exit() boot service returning
  2020-03-03  8:06 [PATCH] efi/libstub/x86: deal with exit() boot service returning Ard Biesheuvel
@ 2020-03-03  8:22 ` Nathan Chancellor
  0 siblings, 0 replies; 2+ messages in thread
From: Nathan Chancellor @ 2020-03-03  8:22 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: linux-efi

On Tue, Mar 03, 2020 at 09:06:48AM +0100, Ard Biesheuvel wrote:
> Even though it is uncommon, there are cases where the Exit() EFI boot
> service might return, e.g., when we were booted via the EFI handover
> protocol from OVMF and the kernel image was specified on the command
> line, in which case Exit() attempts to terminate the boot manager,
> which is not an EFI application itself. So let's drop into a deadloop
> instead.
> 
> Cc: Nathan Chancellor <natechancellor@gmail.com>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> ---
> As a side effect, this also fixes [0], which is as yet undiagnosed.
> 
> [0] https://github.com/ClangBuiltLinux/linux/issues/917

And for that:

Tested-by: Nathan Chancellor <natechancellor@gmail.com> # build

>  drivers/firmware/efi/libstub/x86-stub.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
> index 7f3e97c2aad3..5c7480c4d379 100644
> --- a/drivers/firmware/efi/libstub/x86-stub.c
> +++ b/drivers/firmware/efi/libstub/x86-stub.c
> @@ -344,7 +344,7 @@ static void setup_graphics(struct boot_params *boot_params)
>  static void __noreturn efi_exit(efi_handle_t handle, efi_status_t status)
>  {
>  	efi_bs_call(exit, handle, status, 0, NULL);
> -	unreachable();
> +	for(;;);

I thought this would have tripped up clang's -Wempty-body but it
doesn't so that is good.

>  }
>  
>  void startup_32(struct boot_params *boot_params);
> -- 
> 2.17.1
> 

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

end of thread, other threads:[~2020-03-03  8:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-03  8:06 [PATCH] efi/libstub/x86: deal with exit() boot service returning Ard Biesheuvel
2020-03-03  8:22 ` Nathan Chancellor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).