From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.92.18.95]) by mx.groups.io with SMTP id smtpd.web09.1155.1608317430988144870 for ; Fri, 18 Dec 2020 10:50:31 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@outlook.com header.s=selector1 header.b=h8tKJIlf; spf=pass (domain: outlook.com, ip: 40.92.18.95, mailfrom: kun.q@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lVvs+n1uF07VW6qMawT92uKpY2oPxF9Qr9eKp+z1Unk0+qTDtQpBIT+9L+/CQz8MMLyBYdQfahQnrAPPdUl69QeLrwsxpRySPR4yb1ehDgxSLUWAnYA8KHzcZtwb1nHiQeS0PVPJpxjMRao68UstGmvdU8rKBWbNX3fz4Oue1JYUwRfzIdtB39Pipk2dFvXDcH0seEE9//gWXApQ64a82WPi+Hb5oPgVaLFY8yhlT0ZzMhMpEMM56MWExbcKJzc/pmqN4aXEvDyra0C19w4RFUH7I3WKRRgHEzlj1fh7lZlGOK2CtB20n60YljKU31Svsb0zEL4o+HpF5n9j4KJH1Q== 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=Z7OYxWnB+uhInFLBbRSWvh+cZDL7K/bMo3pFL+8rLu0=; b=DnGbaXyrrejsmz5feS7/Jo/ZId1L/bboBFOcQZtPaDsuBoUe5FYZ69NTgXvv+qX8kXh1HYBs4tKKXcwVBBeyeOh+WRXeObfW7mTQ+2XfLzA3+VYAmzD7YouAg1aUSB56+tWnpL7a2qoQXKb7kY44RqiUwuwhS5pmnZ6VMlvdNJvUZ0rjV7Ei7VHqgEJWIjrli1xtPM9AwZ1L67SZas1GKtKPLyVtf8JYBa8ivFsBkQDanE5yJPdfTkQwFTQjl01LrhxnceIhUj1Zfhmvi/4ALkXXQrGQjU/XqPcTLMYD8jNq/RT3AVNCY3jf200qLC2Tyqotb0EYwxyK8rXF4dAx9g== 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=Z7OYxWnB+uhInFLBbRSWvh+cZDL7K/bMo3pFL+8rLu0=; b=h8tKJIlfb5KO+WeYowDukeHHylFd8hrsthvU8SfAOhNqK/Cb1ijdQnLVNfpNseGyUJQZv+0qBSozDKn3kGJKON6qd7ZKm9BQMyPvhWj8S+AEsCAzXa+W65cDyePxyC0Ll+UaeJsazvONEcoJHXBpbKv7vjql7JYAjSqgQjiBKbiYdvrc1px0dNODEdZtqm3m8y+G8PqyMqkhXuvgnWhDxifap3UcR6ScG5vdoL8n3W+b1bKW/Ad05SJdu6ZveXlQlCwfA9KrCOx9CvGgVs/E/qRC7vsW0ruJnvEN/7GeAdMtCc3Gq6RzdHMz9n2MPq/Il0n7YPD8A7rH0QECFLpe6w== Received: from DM6NAM11FT039.eop-nam11.prod.protection.outlook.com (2a01:111:e400:fc4d::49) by DM6NAM11HT117.eop-nam11.prod.protection.outlook.com (2a01:111:e400:fc4d::156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.25; Fri, 18 Dec 2020 18:50:30 +0000 Received: from MWHPR06MB3102.namprd06.prod.outlook.com (2a01:111:e400:fc4d::48) by DM6NAM11FT039.mail.protection.outlook.com (2a01:111:e400:fc4d::83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.25 via Frontend Transport; Fri, 18 Dec 2020 18:50:30 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:E80493BD0509C36B69A65F25473AF88386620B00C0787B3F1D4F31D49195CB6C;UpperCasedChecksum:B9D041B159CBA975BF9E778DFF8AF6781A26D7A8446694BD313B6DAF0D6CFFB1;SizeAsReceived:7438;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.3654.026; Fri, 18 Dec 2020 18:50:30 +0000 From: "Kun Qin" To: devel@edk2.groups.io CC: Jian J Wang , Hao A Wu , Eric Dong Subject: [PATCH v1 05/15] MdeModulePkg: SmmLockBoxSmmLib: Support StandaloneMm for SmmLockBoxLib Date: Fri, 18 Dec 2020 10:50:01 -0800 Message-ID: X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20201218185011.1366-1-kun.q@outlook.com> References: <20201218185011.1366-1-kun.q@outlook.com> X-TMN: [Pmf5OVYyhnLJI1Bg7qA8DpJnhuJ+ezEM] X-ClientProxiedBy: MW2PR16CA0018.namprd16.prod.outlook.com (2603:10b6:907::31) To MWHPR06MB3102.namprd06.prod.outlook.com (2603:10b6:301:3e::35) Return-Path: kun.q@outlook.com X-Microsoft-Original-Message-ID: <20201218185011.1366-6-kun.q@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (50.35.88.161) by MW2PR16CA0018.namprd16.prod.outlook.com (2603:10b6:907::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Fri, 18 Dec 2020 18:50:29 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: c86964f1-3614-4872-d904-08d8a385cabf X-MS-TrafficTypeDiagnostic: DM6NAM11HT117: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jza8a245aEzqlmbSToutLaDL8WKXtFkcIamg6tU99aaFyzHhkkzqOzoSmCzzklYryNYMajcMEdVyh/VZo4uvO/sYz3VSpgYwDdOZ6/FJ9L8u9oz+eumNbToof51Op4/JOdfGu6xWUenU18R280jBY/o4BEKZ8sNSJJb5mDH/iPysLFDP5DNItJKKzDAK1RLC7EKpLAfGvm5s91K9oFW8eDarTqlGAdbbv4n3txFxCC5uX6K05xmedm+8mBm+So+c X-MS-Exchange-AntiSpam-MessageData: quKvaP/o21aVsfCAHc+VGhq/SwRHrxpWBYeoaVR5ngPb97XmfSaFFbv6cHjZK9nd+YdOHhswi8ACN5/mG0+v39qFhHaIEj9wVsL6iml6jM6tsAkEBUtP1+wmTTtADTXziuX/bg5XKTe/0I0jLMbKFg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2020 18:50:29.9714 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: c86964f1-3614-4872-d904-08d8a385cabf X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT039.eop-nam11.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: DM6NAM11HT117 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 --- MdeModulePkg/Library/SmmLockBoxLib/{SmmLockBoxSmmLib.c =3D> SmmLockBoxMmLi= b.c} | 77 +++++++++----------- MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.c = | 53 ++++++++++++++ MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxTraditionalMmLib.c = | 53 ++++++++++++++ MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxLibPrivate.h = | 27 +++++++ MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf = | 15 ++-- MdeModulePkg/Library/SmmLockBoxLib/{SmmLockBoxSmmLib.inf =3D> SmmLockBoxSt= andaloneMmLib.inf} | 26 ++++--- MdeModulePkg/MdeModulePkg.dsc = | 2 + 7 files changed, 193 insertions(+), 60 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..68fcf2a78ed6 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,25 @@ 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 +218,8 @@ SmmLockBoxSmmConstructor ( // // Register SmmEndOfDxe notification. // - Status =3D gSmst->SmmRegisterProtocolNotify ( - &gEfiSmmEndOfDxeProtocolGuid, + Status =3D gMmst->MmRegisterProtocolNotify ( + &gEfiMmEndOfDxeProtocolGuid, SmmLockBoxSmmEndOfDxeNotify, &mSmmLockBoxRegistrationSmmEndOfDxe ); @@ -232,7 +228,7 @@ SmmLockBoxSmmConstructor ( // // Register EndOfS3Resume notification. // - Status =3D gSmst->SmmRegisterProtocolNotify ( + Status =3D gMmst->MmRegisterProtocolNotify ( &gEdkiiEndOfS3ResumeGuid, SmmLockBoxEndOfS3ResumeNotify, &mSmmLockBoxRegistrationEndOfS3Resume @@ -249,7 +245,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 +259,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 +270,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; } @@ -292,18 +288,17 @@ SmmLockBoxSmmConstructor ( **/ 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 +311,8 @@ SmmLockBoxSmmDestructor ( // // Unregister SmmReadyToLock notification. // - Status =3D gSmst->SmmRegisterProtocolNotify ( - &gEfiSmmReadyToLockProtocolGuid, + Status =3D gMmst->MmRegisterProtocolNotify ( + &gEfiMmReadyToLockProtocolGuid, NULL, &mSmmLockBoxRegistrationSmmReadyToLock ); @@ -327,8 +322,8 @@ SmmLockBoxSmmDestructor ( // // Unregister SmmEndOfDxe notification. // - Status =3D gSmst->SmmRegisterProtocolNotify ( - &gEfiSmmEndOfDxeProtocolGuid, + Status =3D gMmst->MmRegisterProtocolNotify ( + &gEfiMmEndOfDxeProtocolGuid, NULL, &mSmmLockBoxRegistrationSmmEndOfDxe ); @@ -338,7 +333,7 @@ SmmLockBoxSmmDestructor ( // // Unregister EndOfS3Resume notification. // - Status =3D gSmst->SmmRegisterProtocolNotify ( + Status =3D gMmst->MmRegisterProtocolNotify ( &gEdkiiEndOfS3ResumeGuid, NULL, &mSmmLockBoxRegistrationEndOfS3Resume @@ -453,7 +448,7 @@ SaveLockBox ( // // Allocate SMRAM buffer // - Status =3D gSmst->SmmAllocatePages ( + Status =3D gMmst->MmAllocatePages ( AllocateAnyPages, EfiRuntimeServicesData, EFI_SIZE_TO_PAGES (Length), @@ -468,14 +463,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 +657,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 +674,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..f729c6cceeea 100644 --- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxLibPrivate.h +++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxLibPrivate.h @@ -43,5 +43,32 @@ 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 +EFIAPI +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 +EFIAPI +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 90165ca443bf..cd91a70b4fdd 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 @@ -483,6 +484,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.28.0.windows.1