This patch hooks the final HALT loop prepared in the previous patch into
the ExitBootServices() callback.

Cc: Chen Fan <[email protected]>
Cc: Jeff Fan <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Michael Kinney <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <[email protected]>
---

Notes:
    v2:
    - split out as a separate patch
    - capitalize first letter of subject after "UefiCpuPkg/CpuDxe" prefix
      [Jeff]

 UefiCpuPkg/CpuDxe/CpuMp.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/UefiCpuPkg/CpuDxe/CpuMp.c b/UefiCpuPkg/CpuDxe/CpuMp.c
index 1aa2600..3f56faa 100644
--- a/UefiCpuPkg/CpuDxe/CpuMp.c
+++ b/UefiCpuPkg/CpuDxe/CpuMp.c
@@ -1659,15 +1659,24 @@ EFIAPI
 ExitBootServicesCallback (
   IN EFI_EVENT                Event,
   IN VOID                     *Context
   )
 {
+  CPU_AP_HLT_LOOP *CpuApHltLoop;
+  UINT32          CpuApHltLoopAddress;
+
+  CpuApHltLoop = Context;
+  CpuApHltLoopAddress = (UINT32)(UINTN)Context;
+  DEBUG ((EFI_D_VERBOSE, "%a: %a: HLT loop routine at %04x:%04x\n",
+    gEfiCallerBaseName, __FUNCTION__, CpuApHltLoopAddress >> 4, 0));
+
   //
-  // Avoid APs access invalid buff datas which allocated by BootServices,
-  // so we send INIT IPI to APs to let them wait for SIPI state.
+  // Force all APs to execute the HLT loop. Wait until they all enter the code.
   //
-  SendInitIpiAllExcludingSelf ();
+  SendInitSipiSipiAllExcludingSelf (CpuApHltLoopAddress);
+  WaitForAllApsToEnterHltLoop (CpuApHltLoop,
+    (UINT16)(mMpSystemData.NumberOfProcessors - 1));
 }
 
 /**
   A minimal wrapper function that allows MtrrSetAllMtrrs() to be passed to
   EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() as Procedure.
@@ -1800,11 +1809,11 @@ InitializeMpSupport (
   if (mMpSystemData.NumberOfProcessors > 1) {
     Status = gBS->CreateEvent (
                     EVT_SIGNAL_EXIT_BOOT_SERVICES,
                     TPL_CALLBACK,
                     ExitBootServicesCallback,
-                    NULL,
+                    CpuApHltLoop,
                     &mExitBootServicesEvent
                     );
     ASSERT_EFI_ERROR (Status);
   }
 }
-- 
1.8.3.1


_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to