x86/efistub: Avoid returning EFI_SUCCESS on error
PATCH 1/2 x86/efistub: Avoid returning EFI_SUCCESS on error
From: Ard Biesheuvel <[email protected]>
The fail label is only used in a situation where the previous EFI API call succeeded, and so status will be set to EFI_SUCCESS. Fix this, by dropping the goto entirely, and call efi_exit() with the correct error code.
--- drivers/firmware/efi/libstub/x86-stub.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/firmware/efi/libstub/x86-stub.c +1 -4
@@ -566,16 +566,13 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,/* Convert unicode cmdline to ascii */ cmdline_ptr =efi_convert_cmdline (image, &options_size);if (!cmdline_ptr) - goto fail; +efi_exit (handle,EFI_OUT_OF_RESOURCES );efi_set_u64_split ((unsigned long )cmdline_ptr, &hdr->cmd_line_ptr, &boot_params.ext_cmd_line_ptr);efi_stub_entry (handle, sys_table_arg, &boot_params);/* not reached */ - -fail: -efi_exit (handle, status); } static void add_e820ext(struct boot_params *params,
Signature · 1 line
2.45.2.803.g4e1b14247a-goog
PATCH 2/2 x86/efistub: Drop redundant clearing of BSS
From: Ard Biesheuvel <[email protected]>
As it turns out, clearing the BSS was not the right fix for the issue that was ultimately fixed by commit decd347c2a75 ("x86/efistub:
Reinstate soft limit for initrd loading"), and given that the Windows EFI loader becomes very unhappy when entered with garbage in BSS, this is one thing that x86 PC EFI implementations can be expected to get right.
So drop it from the pure PE entrypoint. The handover protocol entrypoint still needs this - it is used by the flaky distro bootloaders that barely implement PE/COFF at all.
--- drivers/firmware/efi/libstub/x86-stub.c | 3 --- 1 file changed, 3 deletions(-)
drivers/firmware/efi/libstub/x86-stub.c +0 -3
@@ -541,9 +541,6 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,efi_status_t status;char *cmdline_ptr; -if (efi_is_native ()) -memset (_bss,0 , _ebss - _bss); - efi_system_table = sys_table_arg;/* Check if we were booted by the EFI firmware */
Signature · 1 line
2.45.2.803.g4e1b14247a-goog