Accordingly 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 <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Feng Tian <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <[email protected]>
Reviewed-by: Michael Kinney <[email protected]>
Reviewed-by: Jiewen Yao <[email protected]>
---
 MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c   | 48 +++++++++++++++++++++++++++++++-
 MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf |  3 +-
 2 files changed, 49 insertions(+), 2 deletions(-)

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

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to