MdeModulePkg PiSmmCore: Unregister each other for LegacyBoot and EBS

Otherwise, LegacyBoot may be triggered wrongly by other code in UEFI OS,
or vice versa.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
Star Zeng 2017-12-08 18:57:29 +08:00
parent 7b9b55b2ef
commit c6ded48cdd
1 changed files with 22 additions and 0 deletions

View File

@ -157,6 +157,7 @@ SmmLegacyBootHandler (
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_HANDLE SmmHandle; EFI_HANDLE SmmHandle;
UINTN Index;
// //
// Install SMM Legacy Boot protocol. // Install SMM Legacy Boot protocol.
@ -173,6 +174,16 @@ SmmLegacyBootHandler (
SmiHandlerUnRegister (DispatchHandle); SmiHandlerUnRegister (DispatchHandle);
//
// It is legacy boot, unregister ExitBootService SMI handler.
//
for (Index = 0; mSmmCoreSmiHandlers[Index].HandlerType != NULL; Index++) {
if (CompareGuid (mSmmCoreSmiHandlers[Index].HandlerType, &gEfiEventExitBootServicesGuid)) {
SmiHandlerUnRegister (mSmmCoreSmiHandlers[Index].DispatchHandle);
break;
}
}
return Status; return Status;
} }
@ -201,6 +212,7 @@ SmmExitBootServicesHandler (
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_HANDLE SmmHandle; EFI_HANDLE SmmHandle;
UINTN Index;
// //
// Install SMM Exit Boot Services protocol. // Install SMM Exit Boot Services protocol.
@ -215,6 +227,16 @@ SmmExitBootServicesHandler (
SmiHandlerUnRegister (DispatchHandle); SmiHandlerUnRegister (DispatchHandle);
//
// It is UEFI boot, unregister LegacyBoot SMI handler.
//
for (Index = 0; mSmmCoreSmiHandlers[Index].HandlerType != NULL; Index++) {
if (CompareGuid (mSmmCoreSmiHandlers[Index].HandlerType, &gEfiEventLegacyBootGuid)) {
SmiHandlerUnRegister (mSmmCoreSmiHandlers[Index].DispatchHandle);
break;
}
}
return Status; return Status;
} }