diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c index 0a50b5b70e..e49661a006 100644 --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c @@ -245,7 +245,6 @@ SmmEntryPoint ( { EFI_STATUS Status; EFI_SMM_COMMUNICATE_HEADER *CommunicateHeader; - BOOLEAN OldInSmm; // // Update SMST using the context @@ -264,9 +263,8 @@ SmmEntryPoint ( } // - // Save current InSmm state and set InSmm state to TRUE, it will be used by SmmBase2 protocol + // Mark the InSmm flag as TRUE, it will be used by SmmBase2 protocol // - OldInSmm = gSmmCorePrivate->InSmm; gSmmCorePrivate->InSmm = TRUE; // @@ -301,9 +299,9 @@ SmmEntryPoint ( } // - // Restore original InSmm state as we are going to leave SMM + // Clear the InSmm flag as we are going to leave SMM // - gSmmCorePrivate->InSmm = OldInSmm; + gSmmCorePrivate->InSmm = FALSE; } /** diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c index c3c2afaec8..e372e7ecf1 100644 --- a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c @@ -397,6 +397,13 @@ SmmCommunicationCommunicate ( return EFI_INVALID_PARAMETER; } + // + // Don't allow call SmiManage() directly when SMRAM is closed or locked. + // + if (!mSmmAccess->OpenState || mSmmAccess->LockState) { + return EFI_INVALID_PARAMETER; + } + // // Save current InSmm state and set InSmm state to TRUE //