From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (NAM02-CY1-obe.outbound.protection.outlook.com [40.92.4.50]) by mx.groups.io with SMTP id smtpd.web10.1683.1609873195677974083 for ; Tue, 05 Jan 2021 10:59:55 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@outlook.com header.s=selector1 header.b=lTORctoy; spf=pass (domain: outlook.com, ip: 40.92.4.50, mailfrom: kun.q@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=higlSAtaJXglDQlbsktrK1EF0O7Ti115uZUrQk8jyhXge25cUV/mFUY2ExVnDQuzgbTiRNN4NisJ09Z64U1XtMhh4FhFcHXTm7VkOinfi6fiFB15KcegQGkil2nUctKp3SfFbTvQJrIhwOOTE6o1x2/nfpxF4z7YCw/pLTS6hB+fth26ihOwSpH20C3kIwsxA/yZIC2mZHY9TNvkHrUS4OvfaJCAneQ5JjCdp7QJqv9hZnKkyYmiBbLE9Xtr+T05+MeT1RWU+q7ktWzSztQbL4cGpdxoPq/t6EZwCw7xRcS9HElWnlrDx+7Ay8shne34fTYQfBQf2npv/EPxtZ61Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vp9iWpWY2498e1cX8PDJMiiPEvsdRJywHA4APR4FI+E=; b=OORLGaoY1INVzMKPe66rS6SfJU0kwJHkzzNgqCAqM2YsJ/oXpbHJzmy015WV7X96Qo0LnMXUSYl4Cf2cPXk9J/goHm12Al5BpNVNKcMgcdnuRNmmVSN8DiOm74oiOVU3GDyjcigax+vL3FvGhglqQrq4Hd1gVIpPN8fwuNdGKLAqVmY9msJBmarIbUtTzGFckSq4bAMA342IDzKZIqIY8M4ozhBIUjeRCHQ9hZliOyYhvMlTO+e0YmzRNWNo98wcjhVlxJkq2QDYvGwHwWOGRd/oxmKhfbF9PtQLRXKd6EBkRny7/rX9von+C8IMHDAZdMLCwYbr7MmVom6GhUNTCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vp9iWpWY2498e1cX8PDJMiiPEvsdRJywHA4APR4FI+E=; b=lTORctoypK1DF+wdfvGVzp1kCoEaITOMLM3C6w5jU2IGy/6bamw85alzc8ZI2Efr3/hMPnVtF1rg0sZySBK1H7LwNI0Delw6zYqlbMSjlanspR9EOCkTzMN8aZETcKvr0Pjqq0xtUbuI+AMQ5st8kGUvqOLbCKlM/a0RNxwlrAkDBc+m5aY3qIN9OYTC6lzhVRE+V9XiCow7rnz7hVbZJbR4Rh/XeA3CE+dM3YQXmB+J03A2naAGqZbh1z87W2qb+OQXnYLDPGFyd8PC81cGY7tt/FrnAjQAi+drNM61phpDkdCGIeo8wrFWLOHo8SZmtb0H8UNHhO8Gq0q5GWHq1Q== Received: from CY1NAM02FT003.eop-nam02.prod.protection.outlook.com (10.152.74.56) by CY1NAM02HT203.eop-nam02.prod.protection.outlook.com (10.152.75.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.22; Tue, 5 Jan 2021 18:59:54 +0000 Received: from MWHPR06MB3102.namprd06.prod.outlook.com (2a01:111:e400:7e45::53) by CY1NAM02FT003.mail.protection.outlook.com (2a01:111:e400:7e45::151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.22 via Frontend Transport; Tue, 5 Jan 2021 18:59:54 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:0FA433CE097C1B3760CCF974F0333F68F5041D69923D82DE8198271A20E777F0;UpperCasedChecksum:1391640E1F19B20994605D5EFE087412092AD65CD064D1FEA57980CC73DA540E;SizeAsReceived:7441;Count:47 Received: from MWHPR06MB3102.namprd06.prod.outlook.com ([fe80::acb3:ab69:563d:b0d6]) by MWHPR06MB3102.namprd06.prod.outlook.com ([fe80::acb3:ab69:563d:b0d6%5]) with mapi id 15.20.3721.024; Tue, 5 Jan 2021 18:59:54 +0000 From: "Kun Qin" To: devel@edk2.groups.io CC: Jian J Wang , Hao A Wu , Eric Dong Subject: [PATCH v2 05/16] MdeModulePkg: SmmLockBoxSmmLib: Support StandaloneMm for SmmLockBoxLib Date: Tue, 5 Jan 2021 10:59:24 -0800 Message-ID: X-Mailer: git-send-email 2.30.0.windows.1 In-Reply-To: <20210105185935.3769-1-kun.q@outlook.com> References: <20210105185935.3769-1-kun.q@outlook.com> X-TMN: [dzvxD5GyXaQbP/OHGOf0T8nBtyVC/XE9] X-ClientProxiedBy: MWHPR22CA0045.namprd22.prod.outlook.com (2603:10b6:300:69::31) To MWHPR06MB3102.namprd06.prod.outlook.com (2603:10b6:301:3e::35) Return-Path: kun.q@outlook.com X-Microsoft-Original-Message-ID: <20210105185935.3769-6-kun.q@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (50.35.88.161) by MWHPR22CA0045.namprd22.prod.outlook.com (2603:10b6:300:69::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 5 Jan 2021 18:59:53 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: d5bfc380-7d3b-4c41-a1bf-08d8b1ac16bd X-MS-TrafficTypeDiagnostic: CY1NAM02HT203: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JgubB3NKd7fw01k9Z62yjziF8nOkPSbm+s8UaHvwMV3ScnKDgHjbq06RVzyTtJs5rFoYtIIPNgJfi/t1/6X6N/WBEhOyAVyk2whWDaKOO8BY0ihKkvq694yL9I/UIdbBgyjekHouVVnUB1uiiYChw5y2+y5zzbBek3BUs1/MmCmRkPY1JX7WfrWsIOsbf6Fm0+FFuDe6SsPe29I9VC1RtYIIOgiLFQrMX4sWiFzoaWNkLDZ/ObE8Q2kXm4WdSVSv X-MS-Exchange-AntiSpam-MessageData: WZZisvT+5RGg6IwX5/eG1+Do3N43K1qsVDXVLRKuzxpJnVvuzsKLWPLjnEcc0fbzXzkz9z6wxXvMbtUSpemRTvNjVDf6H6XfJzpNao/jFtc55xmcd2RbwqPygsPAgPnd8wHPzPVCPpp5Qdi0WAEr8A== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2021 18:59:54.6643 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: d5bfc380-7d3b-4c41-a1bf-08d8b1ac16bd X-MS-Exchange-CrossTenant-AuthSource: CY1NAM02FT003.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1NAM02HT203 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain This change added support of StandaloneMm for SmmLockBoxLib. It replaces gSmst with gMmst to support both traditional MM and standalone MM. The contructor and desctructor functions are abstracted to support different function prototype definitions. Cc: Jian J Wang Cc: Hao A Wu Cc: Eric Dong Signed-off-by: Kun Qin Reviewed-by: Hao A Wu --- Notes: v2: - Removed "EFIAPI" for internal library functions [Hao] - Added Reviewed-by tag [Hao] MdeModulePkg/Library/SmmLockBoxLib/{SmmLockBoxSmmLib.c =3D> SmmLockBoxMmLi= b.c} | 82 +++++++++----------- MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.c = | 53 +++++++++++++ MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxTraditionalMmLib.c = | 53 +++++++++++++ MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxLibPrivate.h = | 25 ++++++ MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf = | 15 ++-- MdeModulePkg/Library/SmmLockBoxLib/{SmmLockBoxSmmLib.inf =3D> SmmLockBoxSt= andaloneMmLib.inf} | 26 ++++--- MdeModulePkg/MdeModulePkg.dsc = | 2 + 7 files changed, 191 insertions(+), 65 deletions(-) diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.c b/MdeMod= ulePkg/Library/SmmLockBoxLib/SmmLockBoxMmLib.c similarity index 89% rename from MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.c rename to MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxMmLib.c index 4cc0e8b78e5b..a709851806eb 100644 --- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.c +++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxMmLib.c @@ -6,16 +6,16 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 -#include -#include +#include +#include #include #include #include #include #include #include -#include -#include +#include +#include #include =20 #include "SmmLockBoxLibPrivate.h" @@ -49,13 +49,13 @@ InternalGetSmmLockBoxContext ( // // Check if gEfiSmmLockBoxCommunicationGuid is installed by someone // - for (Index =3D 0; Index < gSmst->NumberOfTableEntries; Index++) { - if (CompareGuid (&gSmst->SmmConfigurationTable[Index].VendorGuid, &gEf= iSmmLockBoxCommunicationGuid)) { + for (Index =3D 0; Index < gMmst->NumberOfTableEntries; Index++) { + if (CompareGuid (&gMmst->MmConfigurationTable[Index].VendorGuid, &gEfi= SmmLockBoxCommunicationGuid)) { // // Found. That means some other library instance is already run. // No need to install again, just return. // - return (SMM_LOCK_BOX_CONTEXT *)gSmst->SmmConfigurationTable[Index].V= endorTable; + return (SMM_LOCK_BOX_CONTEXT *)gMmst->MmConfigurationTable[Index].Ve= ndorTable; } } =20 @@ -142,8 +142,8 @@ SmmLockBoxSmmEndOfDxeNotify ( // // Locate SmmSxDispatch2 protocol. // - Status =3D gSmst->SmmLocateProtocol ( - &gEfiSmmSxDispatch2ProtocolGuid, + Status =3D gMmst->MmLocateProtocol ( + &gEfiMmSxDispatchProtocolGuid, NULL, (VOID **)&SxDispatch ); @@ -191,29 +191,24 @@ SmmLockBoxEndOfS3ResumeNotify ( Constructor for SmmLockBox library. This is used to set SmmLockBox context, which will be used in PEI phase = in S3 boot path later. =20 - @param[in] ImageHandle Image handle of this driver. - @param[in] SystemTable A Pointer to the EFI System Table. - @retval EFI_SUCEESS @return Others Some error occurs. **/ EFI_STATUS -EFIAPI -SmmLockBoxSmmConstructor ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable +SmmLockBoxMmConstructor ( + VOID ) { EFI_STATUS Status; SMM_LOCK_BOX_CONTEXT *SmmLockBoxContext; =20 - DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SmmLockBoxSmmConstructor - Enter\n= ")); + DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SmmLockBoxMmConstructor - Enter\n"= )); =20 // // Register SmmReadyToLock notification. // - Status =3D gSmst->SmmRegisterProtocolNotify ( - &gEfiSmmReadyToLockProtocolGuid, + Status =3D gMmst->MmRegisterProtocolNotify ( + &gEfiMmReadyToLockProtocolGuid, SmmLockBoxSmmReadyToLockNotify, &mSmmLockBoxRegistrationSmmReadyToLock ); @@ -222,8 +217,8 @@ SmmLockBoxSmmConstructor ( // // Register SmmEndOfDxe notification. // - Status =3D gSmst->SmmRegisterProtocolNotify ( - &gEfiSmmEndOfDxeProtocolGuid, + Status =3D gMmst->MmRegisterProtocolNotify ( + &gEfiMmEndOfDxeProtocolGuid, SmmLockBoxSmmEndOfDxeNotify, &mSmmLockBoxRegistrationSmmEndOfDxe ); @@ -232,7 +227,7 @@ SmmLockBoxSmmConstructor ( // // Register EndOfS3Resume notification. // - Status =3D gSmst->SmmRegisterProtocolNotify ( + Status =3D gMmst->MmRegisterProtocolNotify ( &gEdkiiEndOfS3ResumeGuid, SmmLockBoxEndOfS3ResumeNotify, &mSmmLockBoxRegistrationEndOfS3Resume @@ -249,7 +244,7 @@ SmmLockBoxSmmConstructor ( // No need to install again, just return. // DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SmmLockBoxContext - already inst= alled\n")); - DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SmmLockBoxSmmConstructor - Exit\= n")); + DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SmmLockBoxMmConstructor - Exit\n= ")); return EFI_SUCCESS; } =20 @@ -263,8 +258,8 @@ SmmLockBoxSmmConstructor ( } mSmmLockBoxContext.LockBoxDataAddress =3D (EFI_PHYSICAL_ADDRESS)(UINTN)&= mLockBoxQueue; =20 - Status =3D gSmst->SmmInstallConfigurationTable ( - gSmst, + Status =3D gMmst->MmInstallConfigurationTable ( + gMmst, &gEfiSmmLockBoxCommunicationGuid, &mSmmLockBoxContext, sizeof(mSmmLockBoxContext) @@ -274,7 +269,7 @@ SmmLockBoxSmmConstructor ( =20 DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SmmLockBoxContext - %x\n", (UINTN)= &mSmmLockBoxContext)); DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib LockBoxDataAddress - %x\n", (UINTN= )&mLockBoxQueue)); - DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SmmLockBoxSmmConstructor - Exit\n"= )); + DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SmmLockBoxMmConstructor - Exit\n")= ); =20 return Status; } @@ -284,26 +279,21 @@ SmmLockBoxSmmConstructor ( This is used to uninstall SmmLockBoxCommunication configuration table if it has been installed in Constructor. =20 - @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. =20 **/ EFI_STATUS -EFIAPI -SmmLockBoxSmmDestructor ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable +SmmLockBoxMmDestructor ( + VOID ) { EFI_STATUS Status; =20 - DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SmmLockBoxSmmDestructor in %a modu= le\n", gEfiCallerBaseName)); + DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SmmLockBoxMmDestructor in %a modul= e\n", gEfiCallerBaseName)); =20 if (mSmmConfigurationTableInstalled) { - Status =3D gSmst->SmmInstallConfigurationTable ( - gSmst, + Status =3D gMmst->MmInstallConfigurationTable ( + gMmst, &gEfiSmmLockBoxCommunicationGuid, NULL, 0 @@ -316,8 +306,8 @@ SmmLockBoxSmmDestructor ( // // Unregister SmmReadyToLock notification. // - Status =3D gSmst->SmmRegisterProtocolNotify ( - &gEfiSmmReadyToLockProtocolGuid, + Status =3D gMmst->MmRegisterProtocolNotify ( + &gEfiMmReadyToLockProtocolGuid, NULL, &mSmmLockBoxRegistrationSmmReadyToLock ); @@ -327,8 +317,8 @@ SmmLockBoxSmmDestructor ( // // Unregister SmmEndOfDxe notification. // - Status =3D gSmst->SmmRegisterProtocolNotify ( - &gEfiSmmEndOfDxeProtocolGuid, + Status =3D gMmst->MmRegisterProtocolNotify ( + &gEfiMmEndOfDxeProtocolGuid, NULL, &mSmmLockBoxRegistrationSmmEndOfDxe ); @@ -338,7 +328,7 @@ SmmLockBoxSmmDestructor ( // // Unregister EndOfS3Resume notification. // - Status =3D gSmst->SmmRegisterProtocolNotify ( + Status =3D gMmst->MmRegisterProtocolNotify ( &gEdkiiEndOfS3ResumeGuid, NULL, &mSmmLockBoxRegistrationEndOfS3Resume @@ -453,7 +443,7 @@ SaveLockBox ( // // Allocate SMRAM buffer // - Status =3D gSmst->SmmAllocatePages ( + Status =3D gMmst->MmAllocatePages ( AllocateAnyPages, EfiRuntimeServicesData, EFI_SIZE_TO_PAGES (Length), @@ -468,14 +458,14 @@ SaveLockBox ( // // Allocate LockBox // - Status =3D gSmst->SmmAllocatePool ( + Status =3D gMmst->MmAllocatePool ( EfiRuntimeServicesData, sizeof(*LockBox), (VOID **)&LockBox ); ASSERT_EFI_ERROR (Status); if (EFI_ERROR (Status)) { - gSmst->SmmFreePages (SmramBuffer, EFI_SIZE_TO_PAGES (Length)); + gMmst->MmFreePages (SmramBuffer, EFI_SIZE_TO_PAGES (Length)); DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SaveLockBox - Exit (%r)\n", EFI_= OUT_OF_RESOURCES)); return EFI_OUT_OF_RESOURCES; } @@ -662,7 +652,7 @@ UpdateLockBox ( DEBUG_INFO, "SmmLockBoxSmmLib UpdateLockBox - Allocate new buffer to enlarge= .\n" )); - Status =3D gSmst->SmmAllocatePages ( + Status =3D gMmst->MmAllocatePages ( AllocateAnyPages, EfiRuntimeServicesData, EFI_SIZE_TO_PAGES (Offset + Length), @@ -679,7 +669,7 @@ UpdateLockBox ( // CopyMem ((VOID *)(UINTN)SmramBuffer, (VOID *)(UINTN)LockBox->Smram= Buffer, (UINTN)LockBox->Length); ZeroMem ((VOID *)(UINTN)LockBox->SmramBuffer, (UINTN)LockBox->Leng= th); - gSmst->SmmFreePages (LockBox->SmramBuffer, EFI_SIZE_TO_PAGES ((UIN= TN)LockBox->Length)); + gMmst->MmFreePages (LockBox->SmramBuffer, EFI_SIZE_TO_PAGES ((UINT= N)LockBox->Length)); =20 LockBox->SmramBuffer =3D SmramBuffer; } diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.c= b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.c new file mode 100644 index 000000000000..722121da430b --- /dev/null +++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.c @@ -0,0 +1,53 @@ +/** @file + +Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) Microsoft Corporation. + +SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +#include "SmmLockBoxLibPrivate.h" + +/** + Constructor for SmmLockBox library. + This is used to set SmmLockBox context, which will be used in PEI phase = in S3 boot path later. + + @param[in] ImageHandle Image handle of this driver. + @param[in] SystemTable A Pointer to the EFI System Table. + + @retval EFI_SUCEESS + @return Others Some error occurs. +**/ +EFI_STATUS +EFIAPI +SmmLockBoxStandaloneMmConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_MM_SYSTEM_TABLE *SystemTable + ) +{ + return SmmLockBoxMmConstructor (); +} + +/** + 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 +SmmLockBoxStandaloneMmDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_MM_SYSTEM_TABLE *SystemTable + ) +{ + return SmmLockBoxMmDestructor (); +} diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxTraditionalMmLib.= c b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxTraditionalMmLib.c new file mode 100644 index 000000000000..a748abb16c54 --- /dev/null +++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxTraditionalMmLib.c @@ -0,0 +1,53 @@ +/** @file + +Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) Microsoft Corporation. + +SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +#include "SmmLockBoxLibPrivate.h" + +/** + Constructor for SmmLockBox library. + This is used to set SmmLockBox context, which will be used in PEI phase = in S3 boot path later. + + @param[in] ImageHandle Image handle of this driver. + @param[in] SystemTable A Pointer to the EFI System Table. + + @retval EFI_SUCEESS + @return Others Some error occurs. +**/ +EFI_STATUS +EFIAPI +SmmLockBoxTraditionalConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + return SmmLockBoxMmConstructor (); +} + +/** + 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 +SmmLockBoxTraditionalDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + return SmmLockBoxMmDestructor (); +} diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxLibPrivate.h b/Md= eModulePkg/Library/SmmLockBoxLib/SmmLockBoxLibPrivate.h index 35311cb85d69..449333e94bc6 100644 --- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxLibPrivate.h +++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxLibPrivate.h @@ -43,5 +43,30 @@ typedef struct { =20 #pragma pack() =20 +/** + Constructor for SmmLockBox library. + This is used to set SmmLockBox context, which will be used in PEI phase = in S3 boot path later. + + @retval EFI_SUCEESS + @return Others Some error occurs. +**/ +EFI_STATUS +SmmLockBoxMmConstructor ( + VOID + ); + +/** + Destructor for SmmLockBox library. + This is used to uninstall SmmLockBoxCommunication configuration table + if it has been installed in Constructor. + + @retval EFI_SUCEESS The destructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +SmmLockBoxMmDestructor ( + VOID + ); + #endif =20 diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf b/MdeM= odulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf index 2b6cc983b988..44f7b63c5d20 100644 --- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf +++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf @@ -15,8 +15,8 @@ [Defines] MODULE_TYPE =3D DXE_SMM_DRIVER VERSION_STRING =3D 1.0 LIBRARY_CLASS =3D LockBoxLib|DXE_SMM_DRIVER - CONSTRUCTOR =3D SmmLockBoxSmmConstructor - DESTRUCTOR =3D SmmLockBoxSmmDestructor + CONSTRUCTOR =3D SmmLockBoxTraditionalConstructor + DESTRUCTOR =3D SmmLockBoxTraditionalDestructor =20 # # The following information is for reference only and not required by the = build tools. @@ -25,7 +25,8 @@ [Defines] # =20 [Sources] - SmmLockBoxSmmLib.c + SmmLockBoxTraditionalMmLib.c + SmmLockBoxMmLib.c SmmLockBoxLibPrivate.h =20 [Packages] @@ -33,14 +34,14 @@ [Packages] MdeModulePkg/MdeModulePkg.dec =20 [LibraryClasses] - SmmServicesTableLib + MmServicesTableLib BaseLib DebugLib =20 [Protocols] - gEfiSmmReadyToLockProtocolGuid ## NOTIFY - gEfiSmmEndOfDxeProtocolGuid ## NOTIFY - gEfiSmmSxDispatch2ProtocolGuid ## NOTIFY + gEfiMmReadyToLockProtocolGuid ## NOTIFY + gEfiMmEndOfDxeProtocolGuid ## NOTIFY + gEfiMmSxDispatchProtocolGuid ## NOTIFY =20 [Guids] ## SOMETIMES_CONSUMES ## UNDEFINED # SmmSystemTable diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf b/MdeM= odulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.inf similarity index 52% copy from MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf copy to MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.inf index 2b6cc983b988..d46dfb3f9aa8 100644 --- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf +++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.inf @@ -2,6 +2,7 @@ # SMM LockBox library instance. # # Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) Microsoft Corporation. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -9,14 +10,14 @@ =20 [Defines] INF_VERSION =3D 0x00010005 - BASE_NAME =3D SmmLockBoxSmmLib - MODULE_UNI_FILE =3D SmmLockBoxSmmLib.uni - FILE_GUID =3D E04894D6-290D-4171-A362-0ACFD939F3C8 - MODULE_TYPE =3D DXE_SMM_DRIVER + BASE_NAME =3D SmmLockBoxStandaloneMmLib + FILE_GUID =3D 3C05978B-30CA-4544-9C5A-AB99265EFC31 + MODULE_TYPE =3D MM_STANDALONE VERSION_STRING =3D 1.0 - LIBRARY_CLASS =3D LockBoxLib|DXE_SMM_DRIVER - CONSTRUCTOR =3D SmmLockBoxSmmConstructor - DESTRUCTOR =3D SmmLockBoxSmmDestructor + PI_SPECIFICATION_VERSION =3D 0x00010032 + LIBRARY_CLASS =3D LockBoxLib|MM_STANDALONE + CONSTRUCTOR =3D SmmLockBoxStandaloneMmConstructor + DESTRUCTOR =3D SmmLockBoxStandaloneMmDestructor =20 # # The following information is for reference only and not required by the = build tools. @@ -25,7 +26,8 @@ [Defines] # =20 [Sources] - SmmLockBoxSmmLib.c + SmmLockBoxStandaloneMmLib.c + SmmLockBoxMmLib.c SmmLockBoxLibPrivate.h =20 [Packages] @@ -33,14 +35,14 @@ [Packages] MdeModulePkg/MdeModulePkg.dec =20 [LibraryClasses] - SmmServicesTableLib + MmServicesTableLib BaseLib DebugLib =20 [Protocols] - gEfiSmmReadyToLockProtocolGuid ## NOTIFY - gEfiSmmEndOfDxeProtocolGuid ## NOTIFY - gEfiSmmSxDispatch2ProtocolGuid ## NOTIFY + gEfiMmReadyToLockProtocolGuid ## NOTIFY + gEfiMmEndOfDxeProtocolGuid ## NOTIFY + gEfiMmSxDispatchProtocolGuid ## NOTIFY =20 [Guids] ## SOMETIMES_CONSUMES ## UNDEFINED # SmmSystemTable diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index 6d4e361afd51..9afd40eeed46 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -167,6 +167,7 @@ [LibraryClasses.common.MM_STANDALONE] MemoryAllocationLib|MdeModulePkg/Library/BaseMemoryAllocationLibNull/Bas= eMemoryAllocationLibNull.inf StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoint= /StandaloneMmDriverEntryPoint.inf MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/Standalon= eMmServicesTableLib.inf + LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.= inf =20 [LibraryClasses.ARM, LibraryClasses.AARCH64] ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf @@ -484,6 +485,7 @@ [Components.IA32, Components.X64] MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.inf MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.inf MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf + MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.inf MdeModulePkg/Library/SmmCorePlatformHookLibNull/SmmCorePlatformHookLibNu= ll.inf MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.inf MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaArchCustomDecompressLib= .inf --=20 2.30.0.windows.1