From: Jordan Justen <[email protected]>

This sequence should happen:
* CpuMp.c: Allocate a stack for the APs
* ApStartup.c: Send Start IPI to wake APs in 16-bit real mode
* MpAsm.S: AP enters CpuDxe driver code without stack
  - AP grabs a lock
  - AP sets up stack
  - AP calls CpuMp.c:ApEntryPointInC

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <[email protected]>
Signed-off-by: Chen Fan <[email protected]>
---
 UefiCpuPkg/CpuDxe/CpuMp.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/UefiCpuPkg/CpuDxe/CpuMp.c b/UefiCpuPkg/CpuDxe/CpuMp.c
index 7e12103..e38670d 100644
--- a/UefiCpuPkg/CpuDxe/CpuMp.c
+++ b/UefiCpuPkg/CpuDxe/CpuMp.c
@@ -1365,17 +1365,25 @@ InitializeMpSupport (
   VOID
   )
 {
+  gApStackSize = (UINTN) PcdGet32 (PcdCpuApStackSize);
+
+  mCommonStack = AllocatePages (EFI_SIZE_TO_PAGES (gApStackSize));
+  mTopOfApCommonStack = (VOID*) ((UINTN)mCommonStack + gApStackSize);
+  if (mCommonStack == NULL) {
+    return;
+  }
+
   mNumberOfProcessors = 1;
   mIndexOfProcessors = 1;
 
+  StartApsStackless (AsmApEntryPoint);
+
   if (mNumberOfProcessors == 1) {
-    return;
+    goto EXIT;
   }
 
   DEBUG ((DEBUG_INFO, "Detect CPU count: %d\n", mNumberOfProcessors));
 
-  gApStackSize = (UINTN) PcdGet32 (PcdCpuApStackSize);
-
   mApStackStart = AllocatePages (EFI_SIZE_TO_PAGES ((mNumberOfProcessors - 1) 
* gApStackSize));
   ASSERT (mApStackStart != NULL);
 
@@ -1399,5 +1407,10 @@ InitializeMpSupport (
   while (mApDoneCount != (mNumberOfProcessors - 1)) {
     CpuPause ();
   };
+
+EXIT:
+  mTopOfApCommonStack = NULL;
+  FreePages (mCommonStack, EFI_SIZE_TO_PAGES (gApStackSize));
+  mCommonStack = NULL;
 }
 
-- 
1.9.3


------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to