From nobody Sun Dec 29 01:12:46 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; dkim=fail spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1495809895177420.60881381883553; Fri, 26 May 2017 07:44:55 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id EEB1921C8D0AD; Fri, 26 May 2017 07:44:35 -0700 (PDT) Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0612.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe42::612]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C2BDC21B0387D for ; Fri, 26 May 2017 07:44:32 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by SN1PR12MB0158.namprd12.prod.outlook.com (10.162.3.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1124.9; Fri, 26 May 2017 14:44:30 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ZGj/X3NbHLjunee1bMfBRACqMYmiqgZ32KOYZ7E3IPo=; b=ZyhC6lzGw4u09ifNkK+T3Ge19j+KuWNt8UWQbEpemqm4Q+ch07+3Md6OBh8/7Y5G6ycXEQ8pFSZeMjWGwMTxi81yVRU9IabofbiQe6I5cSY61ZITErh3th6BmJXLpMTpl46a0d1tzTwcSAyYrV2O/TOUa/nCSoqAxtyMWV4PMsk= Authentication-Results: lists.01.org; dkim=none (message not signed) header.d=none;lists.01.org; dmarc=none action=none header.from=amd.com; From: Brijesh Singh To: Date: Fri, 26 May 2017 10:43:54 -0400 Message-ID: <1495809845-32472-7-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495809845-32472-1-git-send-email-brijesh.singh@amd.com> References: <1495809845-32472-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR16CA0024.namprd16.prod.outlook.com (10.172.173.34) To SN1PR12MB0158.namprd12.prod.outlook.com (10.162.3.145) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PR12MB0158: X-MS-Office365-Filtering-Correlation-Id: 5695bfda-9315-4d4c-b98d-08d4a445b802 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:SN1PR12MB0158; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0158; 3:v6vUmz0kzQLMh7oaG6fYt0nzDGg0SlwAnEE+V4hWOQFyMUWnZvhZsaUwQ4E9en2AXH34qXT5NmzMuMUW4ruXmQtJQJcBGk1Di/sg0udeL8eCzb1cFSPJq7yUDn8umZTy4VllydtuZu/5oV0iypdnuzDdg9bsd3IRzZWadxu45WZ+GopHGsKdB08FcFtxGAGiymNQmLJbq0LXeUcKFlGGaKtR2j+RqCnSSx3aKm5q7mWo7d+X2+Dra+JURv9Td74DYDaWycTrwSj8fWzD3H61zFjHcQMFF99/82KBkDTjPfBc/vfylLiugKWfOud7wnp2ajRy2+gMbgKCtwzwVFcxj6Drov2NK1DYiz0UBgwhce0=; 25:TKyGNUa8cidUdkWF5NhTuK2zJ70YglpdYC6Pl+zzzoVvbf/ItgQzNy2rqkwor92Mzwzrx2FR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wohP2SypTYz2pky2fNiH1akGw563HvHEMBhq3WfMdW3opqi/WiZVtL8fmIsr0tap8DNBTVsJhgPBdUStIIbsb5zQG8LlFsUe9ug8wvl04e5tqqAhSKD5fxSJsA5 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(6055026)(6041248)(20161123562025)(20161123564025)(20161123555025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(6072148); SRVR:SN1PR12MB0158; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB0158; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0158; 4:TsSuotzmgDHxcHU3Ez/QnwfS2SNQbtrqarr9TiUWR3Nhsfae/m16s4XC8Ft2Rgvprxd3VUy20fo2Z6GUIUlVHytuRX02Ibbn4p3IzM0Aa4uAd6detCA90ujcZFiSQTuAXCpoy24YhF9yfa2TDBbfmVwVOyIoGUxe/yN4vqhBcoQ3yZn6IhoqFOQZgGwFnGVkx5r4oyOwMJZcwmlySa7gblhN/rtm7naEogWEbtLwDJ9oqbE4PgiWlfPd6++RWi/O5DTy5UQs5QRX/tU+edguHYmdDC0ZJmvSdz1MumnggX7IZTWKycN4DXKdr6p/GEQ7T9PyVRKkRzU+P8epFe83pj6bLr2eM+os7+Trn1QwWc0eD5NQBiu3jSYceswJdgNrnejqrNcX/vVJAQf48Z42k3A+/Xng3UzntYpcFKmEQw7FK5uGdtHlutcQvSTErk/SKSijQFDgJJeSaF/yxbKkC4HJ7yH44KBrTS/kMNZdUZ4eJuHen3vx4w721/a+sKnc34maxz2pywNpIf4lN5dc0iStBlz2WP4dbECpqi3SuXI+t9L4IEnr/k6oexNtdcAF+xHGf2KFb2IkdfPnppLNgV5N70e4nYeYMOklSSEyZMsL6BDNUFKC6EGuBP8FdqOzCHVe8O4b/K6XLvbpdZjKmImiX95emh87zJcdZDft+yIKhYE8yO1eb34ryfmoUzGKMiPikgjP6uBmGk9t6LHDP0CY+MvHkJTU/HvelRPRUTqEumHyEskZjeC5F27z/XrT6LSlTccjL2FgleTexxT7F9uiOPLA15ZTymDC8Aq/VKXfDiNWBvNDRQk+GRS5uG6zUIQCa7ftHRmw6EefmWP2csDcksV+S1iw+MbTcgw22WihfE6c/g8A6qRdFiv0k6v3 X-Forefront-PRVS: 031996B7EF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39450400003)(39410400002)(39840400002)(39860400002)(39400400002)(39850400002)(2950100002)(53376002)(6916009)(6666003)(38730400002)(110136004)(50226002)(6306002)(76176999)(36756003)(81166006)(8676002)(53936002)(16799955002)(86362001)(478600001)(48376002)(15188155005)(54906002)(25786009)(5660300001)(50986999)(189998001)(5003940100001)(33646002)(305945005)(6486002)(2906002)(53416004)(47776003)(2351001)(42186005)(966005)(3846002)(6116002)(66066001)(4326008)(50466002)(7736002)(19627235001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0158; H:brijesh-build-machine.amd.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR12MB0158; 23:KZVnm0oJyQxFvMa9U0fDHymK8t/rEaLNITSC6FRpk?= =?us-ascii?Q?EZEZhNSJN6Kfq0R4ovTUpIB/6BB4s0eG66tbiz2IYc4jzt3LgS7OSJC9N9nM?= =?us-ascii?Q?S1STCJXNwQeDJ5BfsOmmBOlSbk3yOGfoO/oIOFnhZVmTUYYz319ZGGOJz3ys?= =?us-ascii?Q?VML0eniSJ18F9CIXr/ajHtHKW8wgFTfx8ZZ6dhCJqAP8bfaINo+jHS/VbXon?= =?us-ascii?Q?ckYCJevuTQgY9+vRlRDcSqpiBfyDAQjPoD/UX/ii/In+5FD/BBWbWlQ/fsml?= =?us-ascii?Q?/xs6fYoZS4C6GH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Q?lX0ng77f6EcPBQsPqG2nN0Jej6WeGHciQhC?= X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0158; 6:xcrIa9BYWNNMxTUCkEQkrt9Xd55z+A0qnyKpnE8mDb41Qmlebs1oKIY3g6ybbZANfEg712WTAbxnPVqyj5ZGQzpeNmrft8rQsk/8JBnaO17cQoUE7TUJH03hvVKx8bJZRivkQdJQmE4lQGnk9F44HwLXr5+AroAVKCv6ZMLE79h8iih88TqwTe+vOK/SnmUTTypHVV+3NcPscljqdGzTMCWYM0iIMUEpLaiNX06+/jowNXETo0Wrq22UojlnCsPvsvr1NvFwrdiVnqdSGb5jTIlL5J+r23vjrr0j6nU1eAT9UII3hXL1WBM6/fKvJRC7vZa7o+tdCVdg8rOilgvU5bLGiHuxJ3ZV9c8hgJL12ZII0xNdi04Iw1izxMcIuwz0QnH8+IiEGzfuBnW79QWSWKtV2k9JdLlfQQfWcpiUEgicpjti3UARyYjwlB7U7NY2rK0APt7Ex3MvtW8g9BtCw6ritVq0NT12T6xilhKSFPoFZMVa8fj1ocJyfiz9MpfBkCGFwoNYPuTp4zoOW4+eQSDi6uECyhFzNxXifaE4CfM=; 5:AikMIHT37aah4aC82gHqDyQt1pY4KOANy/bkJyPZ8onOSYNll90T3l/H5ytRxzXJJnbwpUNKvRsfT84wI7+bqV1bLw9dhfL8sJ1OmJ8sG8zDY2JBQ+5yJgm+CoKjB1KYy5XbObR0Lt4xng/aKontew==; 24:IkX87nTO5+WswzeWHkf0jdvYyoA4ZC+4qHO/3l1K5AE8ONvuKBYTCTNSEXdVBiWxIM9zqwz2u6ODAvkOvLDcD57pxxVN5VC4yikGz7O5W4g= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0158; 7:p+PRo+FaSG1mNPhkqvubHodn8EgkP6/oOJclfDcgRs314xhO5CBxaNz8NUbl52gMjjGCxJU6pv9gzGAjId0oX+raeuv1s1B6Ucd6Xw0yptnTTrKBtTfi57Dqp4AEYbSXPrqwpzTsdnVG+VRZ59zcNL2mOkSd6gU7qONH8StvRYqY+k2X4nXx0M8oSlP7XWgThacwiGU83pt3JOwz2xOflu0Jbd3a9kzirP2ntlt6/IAtCpwJLzonXykM53Xz+xfalS6DkcdCsIZpH4sP4leb3FnCZUVkANF8wwmBEyVy9Q377yKiUbGwflUKYHhBNTQGDoLYWke+aUsK60IypBKa1w==; 20:O0CZiXlKSoNg23GIgwezxwaeWFRWtvOcQbZ/WaPgZjNgFhBHPqM7SJ6R9PLS4HQO2gyw1DeWF8pjY1x1GB2a95mWjQ2MYV5ceXhWwc4+IzwpH3+C1+a+VrlRATueFDk7BshRLG2DRg+uppGIGAtQk4qzoUBkQuXtHYFhzhgvmGOntGE4ck5XmR9T0QKmR0DIva63xGuxfhB0SG7W/rb4lLn4Ov/Afvnmmv7mOSqGg2YA7PFQKmEkr44xZe0qTcbP X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 May 2017 14:44:30.7653 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0158 Subject: [edk2] [PATCH v6 06/17] OvmfPkg: Add AmdSevDxe driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas.Lendacky@amd.com, Jordan Justen , Jiewen Yao , leo.duran@amd.com, Laszlo Ersek Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When SEV is enabled, the MMIO memory range must be mapped as unencrypted (i.e C-bit cleared). We need to clear the C-bit for MMIO GCD entries in order to cover the ranges that were added during the PEI phase (through memory resource descriptor HOBs). Additionally, the NonExistent ranges are processed in order to cover, in advance, MMIO ranges added later in the DXE phase by various device drivers, via the appropriate DXE memory space services. The approach is not transparent for later addition of system memory ranges to the GCD memory space map. (Such ranges should be encrypted.) OVMF does not do such a thing at the moment, so this approach should be OK. The driver is being added to the APRIORI DXE file so that, we clear the C-bit from MMIO regions before any driver accesses it. Cc: Jordan Justen Cc: Laszlo Ersek Cc: Leo Duran Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.0 Suggested-by: Jiewen Yao Signed-off-by: Brijesh Singh Reviewed-by: Jiewen Yao Reviewed-by: Laszlo Ersek --- OvmfPkg/OvmfPkgIa32X64.dsc | 1 + OvmfPkg/OvmfPkgX64.dsc | 1 + OvmfPkg/OvmfPkgIa32X64.fdf | 2 + OvmfPkg/OvmfPkgX64.fdf | 2 + OvmfPkg/AmdSevDxe/AmdSevDxe.inf | 43 +++++++++++ OvmfPkg/AmdSevDxe/AmdSevDxe.c | 75 ++++++++++++++++++++ 6 files changed, 124 insertions(+) diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index dfc2534fc998..8dd6179893a9 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -824,6 +824,7 @@ [Components.X64] !endif =20 OvmfPkg/PlatformDxe/Platform.inf + OvmfPkg/AmdSevDxe/AmdSevDxe.inf =20 !if $(SMM_REQUIRE) =3D=3D TRUE OvmfPkg/SmmAccess/SmmAccess2Dxe.inf diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index 60e42794483b..6324941ca2ab 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -822,6 +822,7 @@ [Components] !endif =20 OvmfPkg/PlatformDxe/Platform.inf + OvmfPkg/AmdSevDxe/AmdSevDxe.inf =20 !if $(SMM_REQUIRE) =3D=3D TRUE OvmfPkg/SmmAccess/SmmAccess2Dxe.inf diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf index 5233314139bc..12871860d001 100644 --- a/OvmfPkg/OvmfPkgIa32X64.fdf +++ b/OvmfPkg/OvmfPkgIa32X64.fdf @@ -190,6 +190,7 @@ [FV.DXEFV] APRIORI DXE { INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf + INF OvmfPkg/AmdSevDxe/AmdSevDxe.inf !if $(SMM_REQUIRE) =3D=3D FALSE INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf !endif @@ -351,6 +352,7 @@ [FV.DXEFV] INF OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf INF OvmfPkg/VirtioGpuDxe/VirtioGpu.inf INF OvmfPkg/PlatformDxe/Platform.inf +INF OvmfPkg/AmdSevDxe/AmdSevDxe.inf =20 !if $(SMM_REQUIRE) =3D=3D TRUE INF OvmfPkg/SmmAccess/SmmAccess2Dxe.inf diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf index 36150101e784..ae6e66a1c08d 100644 --- a/OvmfPkg/OvmfPkgX64.fdf +++ b/OvmfPkg/OvmfPkgX64.fdf @@ -190,6 +190,7 @@ [FV.DXEFV] APRIORI DXE { INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf + INF OvmfPkg/AmdSevDxe/AmdSevDxe.inf !if $(SMM_REQUIRE) =3D=3D FALSE INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf !endif @@ -351,6 +352,7 @@ [FV.DXEFV] INF OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf INF OvmfPkg/VirtioGpuDxe/VirtioGpu.inf INF OvmfPkg/PlatformDxe/Platform.inf +INF OvmfPkg/AmdSevDxe/AmdSevDxe.inf =20 !if $(SMM_REQUIRE) =3D=3D TRUE INF OvmfPkg/SmmAccess/SmmAccess2Dxe.inf diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.inf b/OvmfPkg/AmdSevDxe/AmdSevDxe.= inf new file mode 100644 index 000000000000..41635a57a454 --- /dev/null +++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.inf @@ -0,0 +1,43 @@ +#/** @file +# +# Driver clears the encryption attribute from MMIO regions when SEV is en= abled +# +# Copyright (c) 2017, AMD Inc. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD +# License which accompanies this distribution. The full text of the lice= nse may +# be found at http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# +#**/ + +[Defines] + INF_VERSION =3D 1.25 + BASE_NAME =3D AmdSevDxe + FILE_GUID =3D 2ec9da37-ee35-4de9-86c5-6d9a81dc38a7 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D AmdSevDxeEntryPoint + +[Sources] + AmdSevDxe.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + OvmfPkg/OvmfPkg.dec + +[LibraryClasses] + BaseLib + UefiLib + UefiDriverEntryPoint + UefiBootServicesTableLib + DxeServicesTableLib + DebugLib + MemEncryptSevLib + +[Depex] + TRUE diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.c b/OvmfPkg/AmdSevDxe/AmdSevDxe.c new file mode 100644 index 000000000000..e472096320ea --- /dev/null +++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.c @@ -0,0 +1,75 @@ +/** @file + + AMD Sev Dxe driver. This driver is dispatched early in DXE, due to being= list + in APRIORI. It clears C-bit from MMIO and NonExistent Memory space when = SEV is + enabled. + + Copyright (c) 2017, AMD Inc. All rights reserved.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD + License which accompanies this distribution. The full text of the licen= se may + be found at http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ + +#include + +#include +#include +#include +#include +#include +#include +#include + +EFI_STATUS +EFIAPI +AmdSevDxeEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_GCD_MEMORY_SPACE_DESCRIPTOR *AllDescMap; + UINTN NumEntries; + UINTN Index; + + // + // Do nothing when SEV is not enabled + // + if (!MemEncryptSevIsEnabled ()) { + return EFI_UNSUPPORTED; + } + + // + // Iterate through the GCD map and clear the C-bit from MMIO and NonExis= tent + // memory space. The NonExistent memory space will be used for mapping t= he MMIO + // space added later (eg PciRootBridge). By clearing both known MMIO and + // NonExistent memory space can gurantee that current and furture MMIO a= dds + // will have C-bit cleared. + // + Status =3D gDS->GetMemorySpaceMap (&NumEntries, &AllDescMap); + if (!EFI_ERROR (Status)) { + for (Index =3D 0; Index < NumEntries; Index++) { + CONST EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Desc; + + Desc =3D &AllDescMap[Index]; + if (Desc->GcdMemoryType =3D=3D EfiGcdMemoryTypeMemoryMappedIo || + Desc->GcdMemoryType =3D=3D EfiGcdMemoryTypeNonExistent) { + Status =3D MemEncryptSevClearPageEncMask (0, + Desc->BaseAddress, + EFI_SIZE_TO_PAGES(Desc->Le= ngth), + FALSE); + ASSERT_EFI_ERROR (Status); + } + } + + FreePool (AllDescMap); + } + + return EFI_SUCCESS; +} --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel