summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Mujawar <sami.mujawar@arm.com>2023-05-18 17:17:16 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-05-29 15:14:00 +0000
commit0b4263a2c2cd9d590945a8a01d310d88db3e39b0 (patch)
tree52c8585399a51db08b4be93acb61ca2574006fba
parent647cd40cf6658f52e0c6d4c356620a4dedd425ba (diff)
downloadedk2-0b4263a2c2cd9d590945a8a01d310d88db3e39b0.tar.gz
edk2-0b4263a2c2cd9d590945a8a01d310d88db3e39b0.tar.bz2
edk2-0b4263a2c2cd9d590945a8a01d310d88db3e39b0.zip
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>
-rwxr-xr-xArmVirtPkg/PrePi/PrePi.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/ArmVirtPkg/PrePi/PrePi.c b/ArmVirtPkg/PrePi/PrePi.c
index 3d943b2138..ff51a757a2 100755
--- a/ArmVirtPkg/PrePi/PrePi.c
+++ b/ArmVirtPkg/PrePi/PrePi.c
@@ -1,6 +1,6 @@
/** @file
*
-* Copyright (c) 2011-2014, ARM Limited. All rights reserved.
+* Copyright (c) 2011-2023, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*
@@ -101,7 +101,7 @@ PrePiMain (
ASSERT_EFI_ERROR (Status);
// Load the DXE Core and transfer control to it
- Status = LoadDxeCoreFromFv (NULL, 0);
+ Status = LoadDxeCoreFromFv (NULL, SIZE_128KB);
ASSERT_EFI_ERROR (Status);
}