audk/ArmVirtPkg/PrePi
Sami Mujawar 0b4263a2c2 ArmVirtPkg/PrePi: Allocate separate stack for Dxe phase
The patch "f07a9df9af60 ArmVirtPkg: Enable stack guard"
enabled stack overflow detection for ArmVirtPkg. Following
this patch, running UEFI shell command 'dmpstore' resulted
in a crash indicating a stack overflow. Invoking 'dmpstore'
results in recursive calls to CascadeProcessVariables ()
which apparently consumes the available stack space and
overflows.

Normally, SEC and PEI run off the initial stack, and the
DxeIpl PEIM is in charge of launching the DxeCore with a
full-sized stack and remapping it non-executable as well.

PrePi platforms take some shortcuts and the DXE and BDS
run off the initial stack which is relatively small. It
is therefore desirable to allocate 128 KiB worth of boot
services data memory as the stack for the Dxe phase.

The PrePiMain () in ArmVirtPkg/PrePi/PrePi.c invokes the
LoadDxeCoreFromFv () to load the Dxe core and transfers
control. The second parameter to LoadDxeCoreFromFv () is
the stack size, which is currently set to 0.
LoadDxeCoreFromFv () is implemented in PrePiLib and if the
stack size is 0, it continues to use the initial stack.
However, if a stack size is specified in the call to
LoadDxeCoreFromFv (), memory is allocated for a new stack
and the stack is switched to use the newly allocated stack
for the Dxe phase.

Therefore, specify 128 KiB as the stack size in the call to
LoadDxeCoreFromFv () so that a separate stack is allocated
and used for the Dxe phase.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
2023-05-29 15:14:00 +00:00
..
AArch64 ArmVirtPkg/PrePi: use standard PeCoff routines for self-relocation 2020-06-12 22:17:46 +00:00
Arm ArmVirtPkg/PrePi: use standard PeCoff routines for self-relocation 2020-06-12 22:17:46 +00:00
ArmVirtPrePiUniCoreRelocatable.inf ArmVirtPkg/PrePi: use standard PeCoff routines for self-relocation 2020-06-12 22:17:46 +00:00
FdtParser.c ArmVirtPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
PrePi.c ArmVirtPkg/PrePi: Allocate separate stack for Dxe phase 2023-05-29 15:14:00 +00:00
PrePi.h ArmVirtPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00