diff options
author | Star Zeng <star.zeng@intel.com> | 2016-05-26 13:21:08 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2016-07-06 16:43:13 +0800 |
commit | 03c41ca1a3308766e3d4aa8e30f1b7bb18ea45a4 (patch) | |
tree | 007c6753146057e26f0dc3bb7d4eb83f9c902b00 /MdeModulePkg | |
parent | 558b76905298a822e58ba2b96c3d0eaa8edb8fad (diff) | |
download | edk2-platforms-03c41ca1a3308766e3d4aa8e30f1b7bb18ea45a4.tar.xz |
MdeModulePkg SmmLockBoxSmmLib: Add DESTRUCTOR SmmLockBoxSmmDestructor
SmmLockBoxSmmLib is linked to SMM modules. If the module entry-point
function returns error, the module will be unloaded and the global
variables will point to undefined memory.
This patch is to add DESTRUCTOR SmmLockBoxSmmDestructor to uninstall
SmmLockBoxCommunication configuration table if it has been installed
in Constructor.
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 738df706c1192a546bd88f017dc00d263f2bc1c2)
Diffstat (limited to 'MdeModulePkg')
-rw-r--r-- | MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.c | 39 | ||||
-rw-r--r-- | MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf | 1 |
2 files changed, 40 insertions, 0 deletions
diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.c b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.c index 38be18560f..4960df7555 100644 --- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.c +++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.c @@ -30,6 +30,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. SMM_LOCK_BOX_CONTEXT mSmmLockBoxContext;
LIST_ENTRY mLockBoxQueue = INITIALIZE_LIST_HEAD_VARIABLE (mLockBoxQueue);
+BOOLEAN mSmmConfigurationTableInstalled = FALSE;
+
/**
This function return SmmLockBox context from SMST.
@@ -114,6 +116,7 @@ SmmLockBoxSmmConstructor ( sizeof(mSmmLockBoxContext)
);
ASSERT_EFI_ERROR (Status);
+ mSmmConfigurationTableInstalled = TRUE;
DEBUG ((EFI_D_INFO, "SmmLockBoxSmmLib SmmLockBoxContext - %x\n", (UINTN)&mSmmLockBoxContext));
DEBUG ((EFI_D_INFO, "SmmLockBoxSmmLib LockBoxDataAddress - %x\n", (UINTN)&mLockBoxQueue));
@@ -123,6 +126,42 @@ SmmLockBoxSmmConstructor ( }
/**
+ Destructor for SmmLockBox library.
+ This is used to uninstall SmmLockBoxCommunication configuration table
+ if it has been installed in Constructor.
+
+ @param[in] ImageHandle Image handle of this driver.
+ @param[in] SystemTable A Pointer to the EFI System Table.
+
+ @retval EFI_SUCEESS The destructor always returns EFI_SUCCESS.
+
+**/
+EFI_STATUS
+EFIAPI
+SmmLockBoxSmmDestructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+
+ DEBUG ((EFI_D_INFO, "SmmLockBoxSmmLib SmmLockBoxSmmDestructor in %a module\n", gEfiCallerBaseName));
+
+ if (mSmmConfigurationTableInstalled) {
+ Status = gSmst->SmmInstallConfigurationTable (
+ gSmst,
+ &gEfiSmmLockBoxCommunicationGuid,
+ NULL,
+ 0
+ );
+ ASSERT_EFI_ERROR (Status);
+ DEBUG ((EFI_D_INFO, "SmmLockBoxSmmLib uninstall SmmLockBoxCommunication configuration table\n"));
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
This function return SmmLockBox queue address.
@return SmmLockBox queue address.
diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf index d722f57a66..eb7ba0bb2e 100644 --- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf +++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf @@ -23,6 +23,7 @@ VERSION_STRING = 1.0
LIBRARY_CLASS = LockBoxLib|DXE_SMM_DRIVER
CONSTRUCTOR = SmmLockBoxSmmConstructor
+ DESTRUCTOR = SmmLockBoxSmmDestructor
#
# The following information is for reference only and not required by the build tools.
|