summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/RiscVVirt
diff options
context:
space:
mode:
authorSunil V L <sunilvl@ventanamicro.com>2023-02-25 13:32:00 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-03-01 15:08:07 +0000
commitf80f052277c88a67c55e107b550f504eeea947d3 (patch)
tree8b988eda43211402f27d82fb57f56a2abbd7360a /OvmfPkg/RiscVVirt
parent1eeca0750af5af2f0e78437bf791ac2de74bde74 (diff)
downloadedk2-f80f052277c88a67c55e107b550f504eeea947d3.tar.gz
edk2-f80f052277c88a67c55e107b550f504eeea947d3.tar.bz2
edk2-f80f052277c88a67c55e107b550f504eeea947d3.zip
OvmfPkg/RiscVVirt: Add Stack HOBedk2-stable202302
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4350 Currently, stack HOB is not created for the stack memory. This causes stack memory to be treated as free memory and any memory allocation which happens at this address causes random memory corruption. Fix this by creating the stack HOB which marks the memory as BS data. Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Andrei Warkentin <andrei.warkentin@intel.com> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Sunil V L <sunilvl@ventanamicro.com> Reported-by: Andrei Warkentin <andrei.warkentin@intel.com> Tested-by: Andrei Warkentin <andrei.warkentin@intel.com> Reviewed-by: Andrei Warkentin <andrei.warkentin@intel.com>
Diffstat (limited to 'OvmfPkg/RiscVVirt')
-rw-r--r--OvmfPkg/RiscVVirt/Sec/SecMain.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/OvmfPkg/RiscVVirt/Sec/SecMain.c b/OvmfPkg/RiscVVirt/Sec/SecMain.c
index 73b9b21a67..adf73f2eb6 100644
--- a/OvmfPkg/RiscVVirt/Sec/SecMain.c
+++ b/OvmfPkg/RiscVVirt/Sec/SecMain.c
@@ -55,6 +55,7 @@ SecStartup (
EFI_STATUS Status;
UINT64 UefiMemoryBase;
UINT64 StackBase;
+ UINT32 StackSize;
//
// Report Status Code to indicate entering SEC core
@@ -71,9 +72,9 @@ SecStartup (
FirmwareContext.FlattenedDeviceTree = (UINT64)DeviceTreeAddress;
SetFirmwareContextPointer (&FirmwareContext);
- StackBase = (UINT64)FixedPcdGet32 (PcdOvmfSecPeiTempRamBase) +
- FixedPcdGet32 (PcdOvmfSecPeiTempRamSize);
- UefiMemoryBase = StackBase - SIZE_32MB;
+ StackBase = (UINT64)FixedPcdGet32 (PcdOvmfSecPeiTempRamBase);
+ StackSize = FixedPcdGet32 (PcdOvmfSecPeiTempRamSize);
+ UefiMemoryBase = StackBase + StackSize - SIZE_32MB;
// Declare the PI/UEFI memory region
HobList = HobConstructor (
@@ -86,6 +87,8 @@ SecStartup (
SecInitializePlatform ();
+ BuildStackHob (StackBase, StackSize);
+
//
// Process all libraries constructor function linked to SecMain.
//