public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 1/1] OvmfPkg/RiscVVirt: Fix for SCT memory allocation test case failure.
@ 2023-02-20 20:09 Sunil V L
  0 siblings, 0 replies; only message in thread
From: Sunil V L @ 2023-02-20 20:09 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Jiewen Yao, Jordan Justen, Gerd Hoffmann,
	Andrei Warkentin, Heinrich Schuchardt

The stack doesn't grow downwards but upwards for RISC-V.
Hence, fix the UEFI memory range calculation by including the correct
stack memory range. Without this fix, SCT hangs in MemoryAllocation
test cases which call AllocateAddress().

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>
Cc: Andrei Warkentin <andrei.warkentin@intel.com>
Reported-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
---
 OvmfPkg/RiscVVirt/Sec/SecMain.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/OvmfPkg/RiscVVirt/Sec/SecMain.c b/OvmfPkg/RiscVVirt/Sec/SecMain.c
index 054e49ef0c1e..0e1f9b891af9 100644
--- a/OvmfPkg/RiscVVirt/Sec/SecMain.c
+++ b/OvmfPkg/RiscVVirt/Sec/SecMain.c
@@ -54,7 +54,7 @@ SecStartup (
   EFI_RISCV_FIRMWARE_CONTEXT  FirmwareContext;
   EFI_STATUS                  Status;
   UINT64                      UefiMemoryBase;
-  UINT64                      StackBase;
+  UINT64                      StackEnd;
 
   //
   // Report Status Code to indicate entering SEC core
@@ -71,15 +71,16 @@ SecStartup (
   FirmwareContext.FlattenedDeviceTree = (UINT64)DeviceTreeAddress;
   SetFirmwareContextPointer (&FirmwareContext);
 
-  StackBase      = (UINT64)FixedPcdGet32 (PcdOvmfSecPeiTempRamBase);
-  UefiMemoryBase = StackBase +  FixedPcdGet32 (PcdOvmfSecPeiTempRamSize) - SIZE_32MB;
+  StackEnd = (UINT64)FixedPcdGet32 (PcdOvmfSecPeiTempRamBase) +
+             FixedPcdGet32 (PcdOvmfSecPeiTempRamSize);
+  UefiMemoryBase = StackEnd - SIZE_32MB;
 
   // Declare the PI/UEFI memory region
   HobList = HobConstructor (
               (VOID *)UefiMemoryBase,
               SIZE_32MB,
               (VOID *)UefiMemoryBase,
-              (VOID *)StackBase // The top of the UEFI Memory is reserved for the stacks
+              (VOID *)StackEnd // The top of the UEFI Memory is reserved for the stacks
               );
   PrePeiSetHobList (HobList);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-20 20:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-20 20:09 [PATCH 1/1] OvmfPkg/RiscVVirt: Fix for SCT memory allocation test case failure Sunil V L

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox