]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/PiSmmIpl: Check order of EndOfDxe and DxeSmmReadyToLock
authorJeff Fan <jeff.fan@intel.com>
Mon, 23 May 2016 05:44:13 +0000 (13:44 +0800)
committerJeff Fan <jeff.fan@intel.com>
Mon, 30 May 2016 01:41:02 +0000 (09:41 +0800)
According to PI specification, EndOfDxe Event should be signaled before
DxeSmmReadyToLock protocol installation. This update is ASSERT if EndOfDxe
Event is not signaled when DxeSmmReadyToLock protocol installed. And do
REPORT_STATUS_CODE() also.

Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf

index 50c3b34dfd34d65819ea6a5e6eaf47b55ace8784..acfcc83e4f56b1e8499337d154a2aa7896d49f02 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   SMM IPL that produces SMM related runtime protocols and load the SMM Core into SMRAM\r
 \r
-  Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials are licensed and made available \r
   under the terms and conditions of the BSD License which accompanies this \r
   distribution.  The full text of the license may be found at        \r
@@ -38,6 +38,7 @@
 #include <Library/UefiLib.h>\r
 #include <Library/UefiRuntimeLib.h>\r
 #include <Library/PcdLib.h>\r
+#include <Library/ReportStatusCodeLib.h>\r
 \r
 #include "PiSmmCorePrivateData.h"\r
 \r
@@ -162,6 +163,20 @@ SmmIplGuidedEventNotify (
   IN VOID       *Context\r
   );\r
 \r
+/**\r
+  Event notification that is fired when EndOfDxe Event Group is signaled.\r
+\r
+  @param  Event                 The Event that is being processed, not used.\r
+  @param  Context               Event Context, not used.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+SmmIplEndOfDxeEventNotify (\r
+  IN EFI_EVENT  Event,\r
+  IN VOID       *Context\r
+  );\r
+\r
 /**\r
   Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.\r
 \r
@@ -243,6 +258,7 @@ EFI_SMM_CONTROL2_PROTOCOL  *mSmmControl2;
 EFI_SMM_ACCESS2_PROTOCOL   *mSmmAccess;\r
 EFI_SMRAM_DESCRIPTOR       *mCurrentSmramRange;\r
 BOOLEAN                    mSmmLocked = FALSE;\r
+BOOLEAN                    mEndOfDxe  = FALSE;\r
 EFI_PHYSICAL_ADDRESS       mSmramCacheBase;\r
 UINT64                     mSmramCacheSize;\r
 \r
@@ -271,6 +287,10 @@ SMM_IPL_EVENT_NOTIFICATION  mSmmIplEvents[] = {
   //\r
   { FALSE, TRUE,  &gEfiEndOfDxeEventGroupGuid,        SmmIplGuidedEventNotify,           &gEfiEndOfDxeEventGroupGuid,        TPL_CALLBACK, NULL },\r
   //\r
+  // Declare event notification on EndOfDxe event.  This is used to set EndOfDxe event signaled flag.\r
+  //\r
+  { FALSE, TRUE,  &gEfiEndOfDxeEventGroupGuid,        SmmIplEndOfDxeEventNotify,         &gEfiEndOfDxeEventGroupGuid,        TPL_CALLBACK, NULL },\r
+  //\r
   // Declare event notification on the DXE Dispatch Event Group.  This event is signaled by the DXE Core\r
   // each time the DXE Core dispatcher has completed its work.  When this event is signalled, the SMM Core\r
   // if notified, so the SMM Core can dispatch SMM drivers.\r
@@ -556,6 +576,23 @@ SmmIplGuidedEventNotify (
   SmmCommunicationCommunicate (&mSmmCommunication, &mCommunicateHeader, &Size);\r
 }\r
 \r
+/**\r
+  Event notification that is fired when EndOfDxe Event Group is signaled.\r
+\r
+  @param  Event                 The Event that is being processed, not used.\r
+  @param  Context               Event Context, not used.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+SmmIplEndOfDxeEventNotify (\r
+  IN EFI_EVENT  Event,\r
+  IN VOID       *Context\r
+  )\r
+{\r
+  mEndOfDxe = TRUE;\r
+}\r
+\r
 /**\r
   Event notification that is fired when DxeDispatch Event Group is signaled.\r
 \r
@@ -711,6 +748,15 @@ SmmIplReadyToLockEventNotify (
     DEBUG ((DEBUG_WARN, "SMM IPL!  DXE SMM Ready To Lock Protocol not installed before Ready To Boot signal\n"));\r
   }\r
 \r
+  if (!mEndOfDxe) {\r
+    DEBUG ((DEBUG_ERROR, "EndOfDxe Event must be signaled before DxeSmmReadyToLock Protocol installation!\n"));\r
+    REPORT_STATUS_CODE (\r
+      EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED,\r
+      (EFI_SOFTWARE_SMM_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)\r
+      );\r
+    ASSERT (FALSE);\r
+  }\r
+\r
   //\r
   // Lock the SMRAM (Note: Locking SMRAM may not be supported on all platforms)\r
   //\r
index 6f027a6056a378cc4d3cb2db3bb59251a28a6b2c..07a765b5d2ce087b486a0d2a468d0190e1d44c1e 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 #  This module provide an SMM CIS compliant implementation of SMM IPL.\r
 #\r
-#  Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -50,6 +50,7 @@
   UefiRuntimeLib\r
   DxeServicesLib\r
   PcdLib\r
+  ReportStatusCodeLib\r
   \r
 [Protocols]\r
   gEfiSmmBase2ProtocolGuid                      ## PRODUCES\r