Skip to content

Commit 5ad5dcf

Browse files
ardbiesheuvelSasha Levin
authored and
Sasha Levin
committed
x86/efistub: Don't clear BSS twice in mixed mode
[ Upstream commit df7ecce ] Clearing BSS should only be done once, at the very beginning. efi_pe_entry() is the entrypoint from the firmware, which may not clear BSS and so it is done explicitly. However, efi_pe_entry() is also used as an entrypoint by the mixed mode startup code, in which case BSS will already have been cleared, and doing it again at this point will corrupt global variables holding the firmware's GDT/IDT and segment selectors. So make the memset() conditional on whether the EFI stub is running in native mode. Fixes: b3810c5 ("x86/efistub: Clear decompressor BSS in native EFI entrypoint") Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent ae863aa commit 5ad5dcf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/firmware/efi/libstub/x86-stub.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,8 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
467467
efi_status_t status;
468468
char *cmdline_ptr;
469469

470-
memset(_bss, 0, _ebss - _bss);
470+
if (efi_is_native())
471+
memset(_bss, 0, _ebss - _bss);
471472

472473
efi_system_table = sys_table_arg;
473474

0 commit comments

Comments
 (0)