UefiCpuPkg: Extend SMM CPU Service with rendezvous support.
REF? https://bugzilla.tianocore.org/show_bug.cgi?id=3815 This patch define a new Protocol with the new services SmmWaitForAllProcessor(), which can be used by SMI handler to optionally wait for other APs to complete SMM rendezvous in relaxed AP mode. A new library SmmCpuRendezvousLib is provided to abstract the service into library API to simple SMI handler code. Cc: Eric Dong <eric.dong@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Cc: Rahul Kumar <rahul1.kumar@intel.com> Cc: Siyuan Fu <siyuan.fu@intel.com> Cc: Zhihao Li <zhihao.li@intel.com> Signed-off-by: Zhihao Li <zhihao.li@intel.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
Implementation of SMM CPU Services Protocol.
|
||||
|
||||
Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2011 - 2022, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
@@ -20,6 +20,13 @@ EFI_SMM_CPU_SERVICE_PROTOCOL mSmmCpuService = {
|
||||
SmmRegisterExceptionHandler
|
||||
};
|
||||
|
||||
//
|
||||
// EDKII SMM CPU Rendezvous Service Protocol instance
|
||||
//
|
||||
EDKII_SMM_CPU_RENDEZVOUS_PROTOCOL mSmmCpuRendezvousService = {
|
||||
SmmCpuRendezvous
|
||||
};
|
||||
|
||||
/**
|
||||
Gets processor information on the requested processor at the instant this call is made.
|
||||
|
||||
@@ -350,6 +357,7 @@ SmmRegisterExceptionHandler (
|
||||
@param ImageHandle The firmware allocated handle for the EFI image.
|
||||
|
||||
@retval EFI_SUCCESS EFI SMM CPU Services Protocol was installed successfully.
|
||||
@retval OTHER Fail to install Protocol.
|
||||
**/
|
||||
EFI_STATUS
|
||||
InitializeSmmCpuServices (
|
||||
@@ -365,5 +373,64 @@ InitializeSmmCpuServices (
|
||||
&mSmmCpuService
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = gSmst->SmmInstallProtocolInterface (
|
||||
&Handle,
|
||||
&gEdkiiSmmCpuRendezvousProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
&mSmmCpuRendezvousService
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
Wait for all processors enterring SMM until all CPUs are already synchronized or not.
|
||||
|
||||
If BlockingMode is False, timeout value is zero.
|
||||
|
||||
@param This A pointer to the EDKII_SMM_CPU_RENDEZVOUS_PROTOCOL instance.
|
||||
@param BlockingMode Blocking mode or non-blocking mode.
|
||||
|
||||
@retval EFI_SUCCESS All avaiable APs arrived.
|
||||
@retval EFI_TIMEOUT Wait for all APs until timeout.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmCpuRendezvous (
|
||||
IN EDKII_SMM_CPU_RENDEZVOUS_PROTOCOL *This,
|
||||
IN BOOLEAN BlockingMode
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Return success immediately if all CPUs are already synchronized.
|
||||
//
|
||||
if (mSmmMpSyncData->AllApArrivedWithException) {
|
||||
Status = EFI_SUCCESS;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
if (!BlockingMode) {
|
||||
Status = EFI_TIMEOUT;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// There are some APs outside SMM, Wait for all avaiable APs to arrive.
|
||||
//
|
||||
SmmWaitForApArrival ();
|
||||
Status = mSmmMpSyncData->AllApArrivedWithException ? EFI_SUCCESS : EFI_TIMEOUT;
|
||||
|
||||
ON_EXIT:
|
||||
if (!mSmmMpSyncData->AllApArrivedWithException) {
|
||||
DEBUG ((DEBUG_INFO, "EdkiiSmmWaitForAllApArrival: Timeout to wait all APs arrival\n"));
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
Reference in New Issue
Block a user