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.79]) by mx.groups.io with SMTP id smtpd.web10.1108.1610663815223608921 for ; Thu, 14 Jan 2021 14:36:55 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@outlook.com header.s=selector1 header.b=AJ2LnW1E; spf=pass (domain: outlook.com, ip: 40.92.4.79, mailfrom: kun.q@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jsDlnJ7IxgbQHG6Z1Wi5oxz5ZSlni7vT7OJU8WhattYX3HLWYtsinblUdGKCJ6mXfH/OCQwIk922TDE82pHeqs+VrgbTrOaEROt6pXzcF8wwzhuvdt7LSY4A9CSkXzsj1K7cfMN93kMeSyXuKiulXEkRhbWWgnEIYlTLxqincgfea0cLGCeiSldEiGyFglhwEr+OFpDo2rErwqBX4mCXQuJDpJnjGybbX+lO1y7hZ6VJv7WgYf2ny046XovkuhDJ0GIjMo7m4e8/mTGJlqTqYMCJmRyix4TSGN+hQOkDID6LK9HTeF1T8adveGmX5L3/kvE3sl8XCMXWRK+L2xsRcQ== 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=g7UHiFRHgb2kaR7vfc5Q3V+0zCvN3mIN0WXFr+ZuWDg=; b=BZ6Rk/7ADlOyqOnHl2StJhLYVI9WaFvWvWrUBc7RSxKvLhGp8BDMoj0pcYU5urzL4dDpCr5XtKA5sCopcLFWeIWG8x0WqSz3UMOaQRuzAf12ykyk3PpvJ/oNgLUoUeLHmkjSo7WYiPwJ+4G19hDfadS3+cTagSUy5Xzd2SHqHo3pyVntBGlzJFDriGWtri4VeEE13MGqszTjEb/ueOxkjqrj5vFlSjxx4uop4t6FnAZbVCW4ume475txIYjIJzbII0EHJnd3wc7p80up8ddC78rlxgYksZwT+ouhcmTpZ2WBV0vgMdvGJtHqffbHFp1RNk93gsp/KUJaIY/OsYsjEA== 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=g7UHiFRHgb2kaR7vfc5Q3V+0zCvN3mIN0WXFr+ZuWDg=; b=AJ2LnW1E/GIEwOSbiJXJbtMzV3HHKDlD0Ps8o0BL133P+Bd0+CCEHKj1J4bMKC/+hAP1KdGJEBBMwcUfDEmjh9r5yQJjiVbRdMjlpcjvrB2WOPfxJZarzVQ4Ub9xbC2XLu3xvJG+OeU4uLVxOt6kU6GcXnXcBuDSOhJHRcYDqyZ4tv0rL80LoRsx4k8CR9813a8iV+FyynWBofqV+el0By7F8WOQIFtWiStbnCHhg75/Sy9xLqI3hCd/XCunZismewDUAXb1IaN0qcdiQew4H20PtQYIaGZ8TeMJtFj6AIpmWVTgYq9q4SZSFs7PzHBF6y6lxf58AL7lpOl18shmRg== Received: from CY1NAM02FT023.eop-nam02.prod.protection.outlook.com (10.152.74.59) by CY1NAM02HT067.eop-nam02.prod.protection.outlook.com (10.152.75.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Thu, 14 Jan 2021 22:36:54 +0000 Received: from MWHPR06MB3102.namprd06.prod.outlook.com (2a01:111:e400:7e45::41) by CY1NAM02FT023.mail.protection.outlook.com (2a01:111:e400:7e45::237) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Thu, 14 Jan 2021 22:36:54 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:A4BB51172D4A56EC2B5606169713545960E1C9E2B09E2C999091338CBC1C65B3;UpperCasedChecksum:DD3F0AF35AC1846BDA1C25D7F9A2099ED661DFAC14F20463646C85530A624742;SizeAsReceived:7452;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.3742.012; Thu, 14 Jan 2021 22:36:54 +0000 From: "Kun Qin" To: devel@edk2.groups.io CC: Jian J Wang , Hao A Wu , Eric Dong Subject: [PATCH v3 06/18] MdeModulePkg: SmmLockBoxSmmLib: Support StandaloneMm for SmmLockBoxLib Date: Thu, 14 Jan 2021 14:36:25 -0800 Message-ID: X-Mailer: git-send-email 2.30.0.windows.1 In-Reply-To: <20210114223637.2737-1-kun.q@outlook.com> References: <20210114223637.2737-1-kun.q@outlook.com> X-TMN: [JkC5RWe6SqygL1l2i59r4Hf3AG4xbhu0] X-ClientProxiedBy: MW4PR04CA0389.namprd04.prod.outlook.com (2603:10b6:303:81::34) To MWHPR06MB3102.namprd06.prod.outlook.com (2603:10b6:301:3e::35) Return-Path: kun.q@outlook.com X-Microsoft-Original-Message-ID: <20210114223637.2737-2-kun.q@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (50.35.88.161) by MW4PR04CA0389.namprd04.prod.outlook.com (2603:10b6:303:81::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Thu, 14 Jan 2021 22:36:53 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 7a2f6973-9165-44c1-bc11-08d8b8dce4b5 X-MS-TrafficTypeDiagnostic: CY1NAM02HT067: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TAxB+uFi2OKiXL/yO+VHbIhXLs3WGvPy4Ezez2G61VNMYB4KE+zMcjnSMaViZV+uqnSPwBu7Hgs26QWJmuD8y24HteU7bWmv3QhZPeukGthXrtLBmnSROdN0+Qd1gl5wEz+1Qlh1rqY8AGKO/aCjxmDXvQO+xI7ut4t7ZJUY7en3CsaW+JQgfyKbFnfrZQc/vEcuwNCJ4pympZbwg9ae73tySd6c6LbVqI1cTAeM+xaL+4jYgOS2sXEjgwTcUFqb X-MS-Exchange-AntiSpam-MessageData: WLHufk1pBrbjVSupreH2L6M/vq8u8URhmDIbwCkPGzE7faN4W0PgseY5ju60plN+DuLXKUCK3sbBZF+J+e32Wh2JW1uPl7sJWIjn3JRrHUzjcYL66ZZ2SprDfE8ykAlAqO6/j3PilUUYc4lWQ3GJgQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2021 22:36:54.1566 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: 7a2f6973-9165-44c1-bc11-08d8b8dce4b5 X-MS-Exchange-CrossTenant-AuthSource: CY1NAM02FT023.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: CY1NAM02HT067 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: v3: - Previously reviewed. No change. =20 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