efi/x86: Setup stack correctly for efi_pe_entry
authorArvind Sankar <nivedita@alum.mit.edu>
Wed, 17 Jun 2020 13:19:57 +0000 (09:19 -0400)
committerSasha Levin <sashal@kernel.org>
Tue, 30 Jun 2020 19:36:04 +0000 (15:36 -0400)
commit3669b9600dce61a9c08bf5e2ea074bee298a5ceb
tree7d849f79bc6e97272dae5fcc492cf335d3238527
parent883043a6c4a1b0575d66c4e4114fc2a75efd805c
efi/x86: Setup stack correctly for efi_pe_entry

[ Upstream commit 41d90b0c1108d1e46c48cf79964636c553844f4c ]

Commit

  17054f492dfd ("efi/x86: Implement mixed mode boot without the handover protocol")

introduced a new entry point for the EFI stub to be booted in mixed mode
on 32-bit firmware.

When entered via efi32_pe_entry, control is first transferred to
startup_32 to setup for the switch to long mode, and then the EFI stub
proper is entered via efi_pe_entry. efi_pe_entry is an MS ABI function,
and the ABI requires 32 bytes of shadow stack space to be allocated by
the caller, as well as the stack being aligned to 8 mod 16 on entry.

Allocate 40 bytes on the stack before switching to 64-bit mode when
calling efi_pe_entry to account for this.

For robustness, explicitly align boot_stack_end to 16 bytes. It is
currently implicitly aligned since .bss is cacheline-size aligned,
head_64.o is the first object file with a .bss section, and the heap and
boot sizes are aligned.

Fixes: 17054f492dfd ("efi/x86: Implement mixed mode boot without the handover protocol")
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Link: https://lore.kernel.org/r/20200617131957.2507632-1-nivedita@alum.mit.edu
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/boot/compressed/head_64.S