when gBS->ExitBootServices() is called, the APs should avoid to access
the unsafed buff datas which were allocated by boot services.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.f...@cn.fujitsu.com>
Tested-by: Gabriel Somlo <so...@cmu.edu>
Reviewed-by: Jordan Justen <jordan.l.jus...@intel.com>
---
 v2-v1:
    Move creating Exit callback into InitializeMpSupport()

 UefiCpuPkg/CpuDxe/CpuMp.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/UefiCpuPkg/CpuDxe/CpuMp.c b/UefiCpuPkg/CpuDxe/CpuMp.c
index f864de1..b65300c 100644
--- a/UefiCpuPkg/CpuDxe/CpuMp.c
+++ b/UefiCpuPkg/CpuDxe/CpuMp.c
@@ -20,7 +20,8 @@ UINTN gApStackSize;
 UINTN gPollInterval = 100; // 100 microseconds
 
 MP_SYSTEM_DATA mMpSystemData;
-EFI_HANDLE     mMpServiceHandle = NULL;
+EFI_HANDLE     mMpServiceHandle       = NULL;
+EFI_EVENT      mExitBootServicesEvent = (EFI_EVENT)NULL;
 
 VOID *mCommonStack = 0;
 VOID *mTopOfApCommonStack = 0;
@@ -1465,6 +1466,28 @@ InitMpSystemData (
 }
 
 /**
+  Callback function for ExitBootServices.
+
+  @param  Event                 Event whose notification function is being 
invoked.
+  @param  Context               The pointer to the notification function's 
context,
+                                which is implementation-dependent.
+
+**/
+VOID
+EFIAPI
+ExitBootServicesCallback (
+  IN EFI_EVENT                Event,
+  IN VOID                     *Context
+  )
+{
+  //
+  // Avoid APs access invalid buff datas which allocated by BootServices,
+  // so we send INIT IPI to APs to let them wait for SIPI state.
+  //
+  SendInitIpiAllExcludingSelf ();
+}
+
+/**
   Initialize Multi-processor support.
 
 **/
@@ -1531,4 +1554,13 @@ InitializeMpSupport (
                                 (gMaxLogicalProcessorNumber - 
mMpSystemData.NumberOfProcessors) *
                                 gApStackSize));
   }
+
+  Status = gBS->CreateEvent (
+                  EVT_SIGNAL_EXIT_BOOT_SERVICES,
+                  TPL_CALLBACK,
+                  ExitBootServicesCallback,
+                  NULL,
+                  &mExitBootServicesEvent
+                  );
+  ASSERT_EFI_ERROR (Status);
 }
-- 
1.9.3


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to