UefiCpuPkg/CpuDxe: Put APs in wait for SIPI state at ExitBootServices

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.fnst@cn.fujitsu.com>
Tested-by: Gabriel Somlo <somlo@cmu.edu>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16397 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Chen Fan 2014-11-17 14:54:09 +00:00 committed by lersek
parent f442002764
commit 9840b1299d
1 changed files with 33 additions and 1 deletions

View File

@ -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;
@ -1464,6 +1465,28 @@ InitMpSystemData (
return EFI_SUCCESS;
}
/**
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);
}