* [PATCH 1/1] OvmfPkg/RiscVVirt: Add Stack HOB
@ 2023-02-24 9:39 Sunil V L
2023-02-24 19:52 ` Andrei Warkentin
0 siblings, 1 reply; 2+ messages in thread
From: Sunil V L @ 2023-02-24 9:39 UTC (permalink / raw)
To: devel
Cc: Andrei Warkentin, Ard Biesheuvel, Jiewen Yao, Jordan Justen,
Gerd Hoffmann
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: 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>
---
OvmfPkg/RiscVVirt/Sec/SecMain.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/OvmfPkg/RiscVVirt/Sec/SecMain.c b/OvmfPkg/RiscVVirt/Sec/SecMain.c
index 73b9b21a67ba..adf73f2eb66c 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.
//
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] OvmfPkg/RiscVVirt: Add Stack HOB
2023-02-24 9:39 [PATCH 1/1] OvmfPkg/RiscVVirt: Add Stack HOB Sunil V L
@ 2023-02-24 19:52 ` Andrei Warkentin
0 siblings, 0 replies; 2+ messages in thread
From: Andrei Warkentin @ 2023-02-24 19:52 UTC (permalink / raw)
To: Sunil V L, devel@edk2.groups.io
Cc: Ard Biesheuvel, Yao, Jiewen, Justen, Jordan L, Gerd Hoffmann
This fixes the strange corruption issues seen, when booting with 1GiB or 2GiB of RAM on Qemu. Please pull into stable tag if possible.
Tested-by: Andrei Warkentin <andrei.warkentin@intel.com>
Reviewed-by: Andrei Warkentin <andrei.warkentin@intel.com>
-----Original Message-----
From: Sunil V L <sunilvl@ventanamicro.com>
Sent: Friday, February 24, 2023 3:39 AM
To: devel@edk2.groups.io
Cc: Warkentin, Andrei <andrei.warkentin@intel.com>; Ard Biesheuvel <ardb+tianocore@kernel.org>; Yao, Jiewen <jiewen.yao@intel.com>; Justen, Jordan L <jordan.l.justen@intel.com>; Gerd Hoffmann <kraxel@redhat.com>
Subject: [PATCH 1/1] OvmfPkg/RiscVVirt: Add Stack HOB
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: 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>
---
OvmfPkg/RiscVVirt/Sec/SecMain.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/OvmfPkg/RiscVVirt/Sec/SecMain.c b/OvmfPkg/RiscVVirt/Sec/SecMain.c index 73b9b21a67ba..adf73f2eb66c 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.
//
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-02-24 19:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-24 9:39 [PATCH 1/1] OvmfPkg/RiscVVirt: Add Stack HOB Sunil V L
2023-02-24 19:52 ` Andrei Warkentin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox