From: Jeff Fan Date: Mon, 23 May 2016 05:44:13 +0000 (+0800) Subject: MdeModulePkg/PiSmmIpl: Check order of EndOfDxe and DxeSmmReadyToLock X-Git-Tag: edk2-stable201903~6924 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=265fff39483bc2e1550bbb9546b9c330e6118e25 MdeModulePkg/PiSmmIpl: Check order of EndOfDxe and DxeSmmReadyToLock 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 Cc: Jiewen Yao Cc: Feng Tian Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan Reviewed-by: Michael Kinney Reviewed-by: Jiewen Yao Tested-by: Laszlo Ersek --- diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c index 50c3b34dfd..acfcc83e4f 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.
+ Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
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 #include #include +#include #include "PiSmmCorePrivateData.h" @@ -162,6 +163,20 @@ SmmIplGuidedEventNotify ( IN VOID *Context ); +/** + 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. @@ -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. @@ -556,6 +576,23 @@ SmmIplGuidedEventNotify ( SmmCommunicationCommunicate (&mSmmCommunication, &mCommunicateHeader, &Size); } +/** + 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. @@ -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 6f027a6056..07a765b5d2 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.
+# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
# # 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