]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg PiSmmCore: Unregister each other for LegacyBoot and EBS
authorStar Zeng <star.zeng@intel.com>
Fri, 8 Dec 2017 10:57:29 +0000 (18:57 +0800)
committerStar Zeng <star.zeng@intel.com>
Tue, 12 Dec 2017 10:30:07 +0000 (18:30 +0800)
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>
MdeModulePkg/Core/PiSmmCore/PiSmmCore.c

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