[edk2-devel] [PATCH 2/3] SimicsOpenBoardPkg: Initialize temporary memory with PcdInitValueInTempStack

Zhiguang Liu zhiguang.liu at intel.com
Tue Apr 25 06:40:02 UTC 2023


From: Ray Ni <ray.ni at intel.com>

PeiCore dumps how many bytes of stack is used by checking stack
contents against PcdInitValueInTempStack.
The assumption is when temporary memory is setup, its initial content
is PcdInitValueInTempStack.

The patch changes X64 version SecCore of QSP to fill the temporary
memory as what PeiCore expects.

This helps to detect if stack in temporary ram is enough.

Cc: Nate DeSimone <nathaniel.l.desimone at intel.com>
Signed-off-by: Ray Ni <ray.ni at intel.com>
---
 .../Intel/SimicsOpenBoardPkg/SecCore/SecMain.inf    |  1 +
 .../SimicsOpenBoardPkg/SecCore/X64/SecEntry.nasm    | 13 +++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/Platform/Intel/SimicsOpenBoardPkg/SecCore/SecMain.inf b/Platform/Intel/SimicsOpenBoardPkg/SecCore/SecMain.inf
index 9dd492a2fb..1de3d012a7 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/SecCore/SecMain.inf
+++ b/Platform/Intel/SimicsOpenBoardPkg/SecCore/SecMain.inf
@@ -68,6 +68,7 @@
   gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress
   gSimicsOpenBoardPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize
   gSimicsOpenBoardPkgTokenSpaceGuid.PcdSimicsDecompressionScratchEnd
+  gEfiMdeModulePkgTokenSpaceGuid.PcdInitValueInTempStack
 
 [FeaturePcd]
   gSimicsX58PkgTokenSpaceGuid.PcdSmmSmramRequire
diff --git a/Platform/Intel/SimicsOpenBoardPkg/SecCore/X64/SecEntry.nasm b/Platform/Intel/SimicsOpenBoardPkg/SecCore/X64/SecEntry.nasm
index 2e6d8f618c..306208a824 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/SecCore/X64/SecEntry.nasm
+++ b/Platform/Intel/SimicsOpenBoardPkg/SecCore/X64/SecEntry.nasm
@@ -24,6 +24,19 @@ extern ASM_PFX(SecCoreStartupWithStack)
 ;
 global ASM_PFX(_ModuleEntryPoint)
 ASM_PFX(_ModuleEntryPoint):
+    ;
+    ; Fill the temporary RAM with the initial stack value.
+    ; The loop below will seed the heap as well, but that's harmless.
+    ;
+    mov     rax, (FixedPcdGet32 (PcdInitValueInTempStack) << 32) | FixedPcdGet32 (PcdInitValueInTempStack)
+                                                                ; qword to store
+    mov     rdi, FixedPcdGet32 (PcdSimicsSecPeiTempRamBase)     ; base address,
+                                                                ;   relative to
+                                                                ;   ES
+    mov     rcx, FixedPcdGet32 (PcdSimicsSecPeiTempRamSize) / 8 ; qword count
+    cld                                                         ; store from base
+                                                                ;   up
+    rep stosq
 
     ;
     ; Load temporary RAM stack based on PCDs
-- 
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103520): https://edk2.groups.io/g/devel/message/103520
Mute This Topic: https://groups.io/mt/98488022/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list