From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id 6E1B9AC0F6C for ; Wed, 23 Oct 2024 17:00:11 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=Nxi9vPNgPBUCTh+0IbhDTp8vSKeUlWWakPKsbY3lYeM=; c=relaxed/simple; d=groups.io; h=From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20240830; t=1729702811; v=1; x=1729962009; b=KMtAxzC/JEzU8zST8WZzYNrFPzCcsEI4vseByel3lLaQ0poPdir6Z/S8k/7NyQNSrSFXDGM9 QpunTXLxSNEIMTdulKzO4KgZULh07z53hoLcol1scCribxTMO6m/hVPjTYqfHtKE17J04p2Ks24 IqUDm5o39npGM7rx5R9EN2uhXWSerQaifQxitA2T6IUyfR1H1ZnaHcN8F44TWyrRrZojL/kfPp6 dEX0QIYTgGOmvOUzlW0cbKBJyq72+IzsDSEKzGcjABHgSwk/zmwSZW9lT3PuPYggzs327YcuD3r 4ySDJFPak+fgOMd5hp91GS6ssC96L0BIx3f9h7jTQzQqQ== X-Received: by 127.0.0.2 with SMTP id KQvSYY7687511xiIKF4U74jP; Wed, 23 Oct 2024 10:00:09 -0700 X-Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.104]) by mx.groups.io with SMTP id smtpd.web10.21727.1729257798192141817 for ; Fri, 18 Oct 2024 06:23:18 -0700 X-Received: from SJ2PR10MB7557.namprd10.prod.outlook.com (2603:10b6:a03:538::9) by CH0PR10MB5004.namprd10.prod.outlook.com (2603:10b6:610:de::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.21; Fri, 18 Oct 2024 13:23:12 +0000 X-Received: from SJ2PR10MB7557.namprd10.prod.outlook.com ([fe80::9953:169:6e85:e95c]) by SJ2PR10MB7557.namprd10.prod.outlook.com ([fe80::9953:169:6e85:e95c%5]) with mapi id 15.20.8069.016; Fri, 18 Oct 2024 13:23:12 +0000 From: "Sountharya N via groups.io" To: "devel@edk2.groups.io" , Sountharya N CC: Karthika R , Srinivasan Mani , Prarthana Sagar V , Gayathri Thunuguntla Subject: [edk2-devel] [PATCH] CryptoPkg:Added Standalone support in ProtocolPpi Thread-Topic: [PATCH] CryptoPkg:Added Standalone support in ProtocolPpi Thread-Index: AQHbIWDhi5dXmnbA5kmrj11rV5ZcEQ== Date: Fri, 18 Oct 2024 13:23:12 +0000 Message-ID: <20241018132148.725-1-sountharyan@ami.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SJ2PR10MB7557:EE_|CH0PR10MB5004:EE_ x-ms-office365-filtering-correlation-id: a9f79005-116b-487c-e7cd-08dcef780414 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: =?iso-8859-1?Q?p2pprAAJVujnSq2gRDzTap6v4/w2KEfnZ/Iav2F9FM1VytT9AfMDjvHaZU?= =?iso-8859-1?Q?QwRxtWa5XXPygLKcVix/Vvy876ZsVMISWINghQiZiA45px5J7uoCYDXiP9?= =?iso-8859-1?Q?IISK2zTi9Xl+W2uxCnHcKRSiDdTg9qEyFZea3K60Qe4wfoyfpaByv4Cv++?= =?iso-8859-1?Q?POBddVrGOD+tATXT0Rg/4ShL8tcCvJwXVO6Hj4VJA05R1c09PHElg9UTaK?= =?iso-8859-1?Q?+8kVG2ZMuYGclkUCtIRRTyO4aHDEDbCrTe8y48HWH9dnFwKOpx3q++30SP?= =?iso-8859-1?Q?RiRCRYD/QAg+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= =?iso-8859-1?Q?rNl7J+prWZLmx9TIMP2kJFJ5L1JGHapjhAL7uVAUVH2jzIVeZX5fNFBJf3?= =?iso-8859-1?Q?MZHY2dQjNd/6e7rm/Rc24vaVOP9I6zmO/p2teXtKYkhYWq7yfImLFyMm96?= =?iso-8859-1?Q?sFQNB1tt77gulYbYiG7alZQgyMnw0lMRCTqA1zt9Xw54PMZw+LaapKnxmi?= =?iso-8859-1?Q?xpuV1qSuI3LU8T6+ssiuoXg0uDhfSeF6B/GsWBxEWum2xTyZb0Oh8=3D?= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?SElbU7vuOsVcpbR2xyowOdyRCr0l1OQe0Qc7DUjj1ttIlFzD4ltTbQ2MEI?= =?iso-8859-1?Q?ShfaIKgVkcrcYouZuBb2cE8cOy5miZ/QnFnaP75MCBKHi5lVV2i/qR4Npv?= =?iso-8859-1?Q?cE3Pu0Tav1HRATLEZLe2hh6Babxm1Drkm0pGzSQtFRkjAwAWGqVTMTn9RN?= =?iso-8859-1?Q?/9hWNFENFOSYNo24dRJj5GLXUKqLUtGNUuwuWfQ2+obUwptPBRCFtSBiYY?= =?iso-8859-1?Q?Oua4fMvWhRqwU2Z4v+3igVmovNwmBUUP8ig60/in4zPVDLPqVC9p6sR/30?= =?iso-8859-1?Q?RcM68AFzj6vzDNlpxy6IzIL0aekPTkoYwdZGNbt2O8kgKe0pl3KsVhk2um?= =?iso-8859-1?Q?G+ojOTbxYb3KWR5VNhyYcoleUaL1v+gJPfJ3HiX5hoNAJRn8Wj9BBCPwj8?= =?iso-8859-1?Q?HKBk///9RzJmKb4yggVT4Oog+OX8OHKKs0INcrQH5KfOIqlL0NFmrDjYH4?= =?iso-8859-1?Q?Q6VxNnsjhkENupfslHULkw7chYZq+y/FmYQZ/8YtoC7EVFaHpcMbSfVveV?= =?iso-8859-1?Q?yEX+3C1L/LiPvUOSlfTVZ+2gfM13jERXEa3i8Abo6ry9+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WNoSA6nnWoQk2xkR0KFFkTaqRr0n3KzQSDVjQ?= =?iso-8859-1?Q?Ezhkhzfs6OytTSkvHKQrOCE2HioG9AnK9X1Ri8dNKkYZRrR8LR0ArvJwNY?= =?iso-8859-1?Q?rJR6ZlQ3WrFW5uQSG7ptMBwLSOL5QY55lM9a3Fw9I2dBNU3KYUlDZ+LRk3?= =?iso-8859-1?Q?y8Yt16wUv+zf4N0Idz0rX4OZVAfZt9Tp/d?= MIME-Version: 1.0 X-OriginatorOrg: ami.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SJ2PR10MB7557.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a9f79005-116b-487c-e7cd-08dcef780414 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Oct 2024 13:23:12.3019 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 27e97857-e15f-486c-b58e-86c2b3040f93 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: oP9ZhewFdW4w7Qo+2o4ci2E46vi247NxREie7yoaVYI5nixSYQs8JuuEbUMrk/nA/rp/65VlLkKpoNljSkfRdg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5004 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Wed, 23 Oct 2024 10:00:07 -0700 Resent-From: sountharyan@ami.com Reply-To: devel@edk2.groups.io,sountharyan@ami.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 19sknG5EYp7PZE9FilEF4Wvtx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240830 header.b="KMtAxzC/"; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io Added MM_STANDALONE support in Driver and BaseCryptLibOnProtocolPpi --- CryptoPkg/CryptoPkg.dsc | 59 ++++++++++++++ CryptoPkg/Driver/CryptoStandaloneMm.c | 41 ++++++++++ CryptoPkg/Driver/CryptoStandaloneMm.inf | 48 +++++++++++ .../StandaloneMmCryptLib.c | 79 +++++++++++++++++++ .../StandaloneMmCryptLib.inf | 45 +++++++++++ 5 files changed, 272 insertions(+) create mode 100644 CryptoPkg/Driver/CryptoStandaloneMm.c create mode 100644 CryptoPkg/Driver/CryptoStandaloneMm.inf create mode 100644 CryptoPkg/Library/BaseCryptLibOnProtocolPpi/StandaloneM= mCryptLib.c create mode 100644 CryptoPkg/Library/BaseCryptLibOnProtocolPpi/StandaloneM= mCryptLib.inf diff --git a/CryptoPkg/CryptoPkg.dsc b/CryptoPkg/CryptoPkg.dsc index d4400696b8..cbd11e265e 100644 --- a/CryptoPkg/CryptoPkg.dsc +++ b/CryptoPkg/CryptoPkg.dsc @@ -83,6 +83,11 @@ DEFINE SMM_FULL_GUID =3D 1930CE7E-6598-48ED-8AB1-EBE7E85EC254 DEFINE SMM_STD_ACCEL_GUID =3D 828959D3-CEA6-4B79-B1FC-5AFA0D7F2144 DEFINE SMM_FULL_ACCEL_GUID =3D C1760694-AB3A-4532-8C6D-52D8F86EB1AA + DEFINE MM_STANDALONE_CRYPTO_GUID =3D 4e14baae-8aa0-4f28-b1f0-53215e= 4dea81 + DEFINE MM_STANDALONE_STD_GUID =3D fb88ffe8-c6e3-4752-8e85-0865df= 7cdb1f + DEFINE MM_STANDALONE_FULL_GUID =3D 4a6f4c6e-6207-4801-9706-b94299= 36a38c + DEFINE MM_STANDALONE_STD_ACCEL_GUID =3D 9ef13bfa-912e-4589-8d6a-3eccf1= 156b5e + DEFINE MM_STANDALONE_FULL_ACCEL_GUID =3D 0a13116a-d6bf-4a4e-90dc-615c4c= 0a711d !if $(CRYPTO_SERVICES) =3D=3D TARGET_UNIT_TESTS !include UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.inc @@ -377,6 +382,7 @@ CryptoPkg/Library/BaseCryptLibOnProtocolPpi/PeiCryptLib.inf CryptoPkg/Library/BaseCryptLibOnProtocolPpi/DxeCryptLib.inf CryptoPkg/Library/BaseCryptLibOnProtocolPpi/SmmCryptLib.inf + CryptoPkg/Library/BaseCryptLibOnProtocolPpi/StandaloneMmCryptLib.inf # # Build verification of target-based unit tests # @@ -580,6 +586,59 @@ MSFT:*_*_IA32_DLINK_FLAGS =3D /ALIGN:4096 MSFT:*_*_X64_DLINK_FLAGS =3D /ALIGN:4096 } + # + # CryptoStandaloneMm with OpensslLib instance with no SSL or EC services + # + CryptoPkg/Driver/CryptoStandaloneMm.inf { + + FILE_GUID =3D $(MM_STANDALONE_CRYPTO_GUID) + + OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf + } + # + # CryptoStandaloneMm with OpensslLib instance with no SSL services + # + CryptoPkg/Driver/CryptoStandaloneMm.inf { + + FILE_GUID =3D $(MM_STANDALONE_STD_GUID) + + OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf + } + # + # CryptoStandaloneMm with OpensslLib instance with no all services + # + CryptoPkg/Driver/CryptoStandaloneMm.inf { + + FILE_GUID =3D $(MM_STANDALONE_FULL_GUID) + + OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibFull.inf + } + # + # CryptoStandaloneMm with IA32/X64/AARCH64 performance optimized Openssl= Lib instance with no EC services + # IA32/X64 assembly optimizations required larger alignments + # + CryptoPkg/Driver/CryptoStandaloneMm.inf { + + FILE_GUID =3D $(MM_STANDALONE_STD_ACCEL_GUID) + + OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibAccel.inf + + MSFT:*_*_IA32_DLINK_FLAGS =3D /ALIGN:64 + MSFT:*_*_X64_DLINK_FLAGS =3D /ALIGN:256 + } + # + # CryptoStandaloneMm with IA32/X64/AARCH64 performance optimized Openssl= Lib instance with all services + # IA32/X64 assembly optimizations required larger alignments + # + CryptoPkg/Driver/CryptoStandaloneMm.inf { + + FILE_GUID =3D $(MM_STANDALONE_FULL_ACCEL_GUID) + + OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibFullAccel.inf + + MSFT:*_*_IA32_DLINK_FLAGS =3D /ALIGN:4096 + MSFT:*_*_X64_DLINK_FLAGS =3D /ALIGN:4096 + } !endif [BuildOptions] diff --git a/CryptoPkg/Driver/CryptoStandaloneMm.c b/CryptoPkg/Driver/Crypt= oStandaloneMm.c new file mode 100644 index 0000000000..1f0ad88061 --- /dev/null +++ b/CryptoPkg/Driver/CryptoStandaloneMm.c @@ -0,0 +1,41 @@ +/** @file + Installs the EDK II Crypto SMM Protocol in Standalone MM. + + Copyright (C) Microsoft Corporation. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include + +extern CONST EDKII_CRYPTO_PROTOCOL mEdkiiCrypto; + +/** + The module Entry Point of the Crypto Standalone MM Driver. + + @param[in] ImageHandle The firmware allocated handle for the EFI ima= ge. + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The entry point is executed successfully. + @retval Other Some error occurs when executing this entry point= . + +**/ +EFI_STATUS +EFIAPI +CryptoStandaloneMmEntry ( + IN EFI_HANDLE ImageHandle, + IN EFI_MM_SYSTEM_TABLE *MmSystemTable + ) +{ + EFI_HANDLE Handle; + + Handle =3D NULL; + return gMmst->MmInstallProtocolInterface ( + &Handle, + &gEdkiiSmmCryptoProtocolGuid, + EFI_NATIVE_INTERFACE, + (EDKII_CRYPTO_PROTOCOL *)&mEdkiiCrypto + ); +} diff --git a/CryptoPkg/Driver/CryptoStandaloneMm.inf b/CryptoPkg/Driver/Cry= ptoStandaloneMm.inf new file mode 100644 index 0000000000..fc5c832304 --- /dev/null +++ b/CryptoPkg/Driver/CryptoStandaloneMm.inf @@ -0,0 +1,48 @@ +## @file +# Produces the EDK II SMM Crypto Protocol using the library services from +# BaseCryptLib and TlsLib for Standalone MM. +# +# Copyright (C) Microsoft Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001B + PI_SPECIFICATION_VERSION =3D 0x00010032 + BASE_NAME =3D CryptoStandaloneMm + MODULE_UNI_FILE =3D Crypto.uni + FILE_GUID =3D B7946FEA-15EF-43F4-9FF6-0F71E032ECF5 + MODULE_TYPE =3D MM_STANDALONE + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D CryptoStandaloneMmEntry + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 +# + +[Sources] + Crypto.c + CryptoStandaloneMm.c + +[Packages] + MdePkg/MdePkg.dec + CryptoPkg/CryptoPkg.dec + +[LibraryClasses] + BaseCryptLib + DebugLib + MmServicesTableLib + StandaloneMmDriverEntryPoint + TlsLib + +[Protocols] + gEdkiiSmmCryptoProtocolGuid ## PRODUCES + +[Pcd] + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable ## CONSUMES + +[Depex] + TRUE diff --git a/CryptoPkg/Library/BaseCryptLibOnProtocolPpi/StandaloneMmCryptL= ib.c b/CryptoPkg/Library/BaseCryptLibOnProtocolPpi/StandaloneMmCryptLib.c new file mode 100644 index 0000000000..618d1c5646 --- /dev/null +++ b/CryptoPkg/Library/BaseCryptLibOnProtocolPpi/StandaloneMmCryptLib.c @@ -0,0 +1,79 @@ +/** @file + Implements the GetCryptoServices() API that retuns a pointer to the EDK = II + SMM Crypto Protocol. + + Copyright (C) Microsoft Corporation. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include + +EDKII_SMM_CRYPTO_PROTOCOL *mSmmCryptoProtocol =3D NULL; + +/** + Internal worker function that returns the pointer to an EDK II Crypto + Protocol/PPI. The layout of the PPI, DXE Protocol, and SMM Protocol are + identical which allows the implementation of the BaseCryptLib functions = that + call through a Protocol/PPI to be shared for the PEI, DXE, and SMM + implementations. + + This SMM implementation returns the pointer to the EDK II SMM Crypto Pro= tocol + that was found in the library constructor SmmCryptLibConstructor(). +**/ +VOID * +GetCryptoServices ( + VOID + ) +{ + return (VOID *)mSmmCryptoProtocol; +} + +/** + Constructor looks up the EDK II SMM Crypto Protocol and verifies that it= is + not NULL and has a high enough version value to support all the BaseCryp= tLib + functions. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param MmSystemTable A pointer to the MM System Table. + + @retval EFI_SUCCESS The EDK II SMM Crypto Protocol was found. + @retval EFI_NOT_FOUND The EDK II SMM Crypto Protocol was not found. +**/ +EFI_STATUS +EFIAPI +StandaloneMmCryptLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_MM_SYSTEM_TABLE *MmSystemTable + ) +{ + EFI_STATUS Status; + UINTN Version; + + Status =3D gMmst->MmLocateProtocol ( + &gEdkiiSmmCryptoProtocolGuid, + NULL, + (VOID **)&mSmmCryptoProtocol + ); + if (EFI_ERROR (Status) || (mSmmCryptoProtocol =3D=3D NULL)) { + DEBUG ((DEBUG_ERROR, "[StandaloneMmCryptLib] Failed to locate Crypto S= MM Protocol. Status =3D %r\n", Status)); + ASSERT_EFI_ERROR (Status); + ASSERT (mSmmCryptoProtocol !=3D NULL); + mSmmCryptoProtocol =3D NULL; + return EFI_NOT_FOUND; + } + + Version =3D mSmmCryptoProtocol->GetVersion (); + if (Version < EDKII_CRYPTO_VERSION) { + DEBUG ((DEBUG_ERROR, "[StandaloneMmCryptLib] Crypto SMM Protocol unsup= ported version %d\n", Version)); + ASSERT (Version >=3D EDKII_CRYPTO_VERSION); + mSmmCryptoProtocol =3D NULL; + return EFI_NOT_FOUND; + } + + return EFI_SUCCESS; +} \ No newline at end of file diff --git a/CryptoPkg/Library/BaseCryptLibOnProtocolPpi/StandaloneMmCryptL= ib.inf b/CryptoPkg/Library/BaseCryptLibOnProtocolPpi/StandaloneMmCryptLib.i= nf new file mode 100644 index 0000000000..5e95a03716 --- /dev/null +++ b/CryptoPkg/Library/BaseCryptLibOnProtocolPpi/StandaloneMmCryptLib.inf @@ -0,0 +1,45 @@ +## @file +# Implements the BaseCryptLib and TlsLib using the services of the EDK II = Crypto +# SMM Protocol for Stdandalone MM. +# +# Copyright (C) Microsoft Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D StandaloneMmCryptLib + MODULE_UNI_FILE =3D CryptLib.uni + FILE_GUID =3D FA7EB4FD-7B3B-4FE4-BA95-1CE47CD0BE3E + VERSION_STRING =3D 1.0 + PI_SPECIFICATION_VERSION =3D 0x00010032 + MODULE_TYPE =3D MM_STANDALONE + LIBRARY_CLASS =3D BaseCryptLib | MM_STANDALONE + LIBRARY_CLASS =3D TlsLib | MM_STANDALONE + CONSTRUCTOR =3D StandaloneMmCryptLibConstructor + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 +# + +[Packages] + MdePkg/MdePkg.dec + CryptoPkg/CryptoPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + MmServicesTableLib + +[Sources] + StandaloneMmCryptLib.c + CryptLib.c + +[Protocols] + gEdkiiSmmCryptoProtocolGuid ## CONSUMES + +[Depex] + gEdkiiSmmCryptoProtocolGuid -- 2.46.2.windows.1 -The information contained in this message may be confidential and propriet= ary to American Megatrends (AMI). This communication is intended to be read= only by the individual or entity to whom it is addressed or by their desig= nee. If the reader of this message is not the intended recipient, you are o= n notice that any distribution of this message, in any form, is strictly pr= ohibited. Please promptly notify the sender by reply e-mail or by telephone= at 770-246-8600, and then delete or destroy all copies of the transmission= . -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#120669): https://edk2.groups.io/g/devel/message/120669 Mute This Topic: https://groups.io/mt/109174503/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-