From nobody Mon Feb 9 00:50:06 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+50971+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1574280499763861.1653929121196; Wed, 20 Nov 2019 12:08:19 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id KpCyYY1788612xO369Swoke3; Wed, 20 Nov 2019 12:08:19 -0800 X-Received: from NAM02-CY1-obe.outbound.protection.outlook.com (NAM02-CY1-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web11.13474.1574280498533258490 for ; Wed, 20 Nov 2019 12:08:18 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XFebBZFpulx8X+UXGZjZOAzfGihOzoL6iR90W0sSeWj5w4RuOyh8krKCjUYMO164+N7cYfheciDBM9OHGtw0d/5bPyumPe+m7fERVoB0wLOo0qHLjkgQqmOJeWrwYXW0kSOtpuGSqt5vnOYPjq4gJBpllWHIpfTo+7FB4b56B2HJKBYHkPVip+QeAzdfqmaX8ieM7KFFvR0ZxuFbtKxEZ1gOwC5fJ8Mn3kS39ex3pLyi+luCIs02wpPX4YazvS1bXHSbj83YfN4XhshgEoDiTZCMKQfGdvoOmWut7Q/l2h5QaPIFQzS+3R/VBIHMY8xZ0cXXJnDFVDmRWQUxourdAA== 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=1Y84KFEcZs8RAjXbX/edJMg/AwxPJkkQUr0tM1fBtkM=; b=PFES+zaCeFPCoIozx1NupngAyvipbK7n5nEMjHr0l+UC4AYtBZLHnGhvNRo/a3A6qASZuo0NHzQUB1QZPwBByzE02I2jG++RjyeToJvP1nRX9z1FJqNf0HzVuCix+uJ92i1gsHA0fuYpD3+2fwd8wlQO5fbVlEXXzv6jbRV6uFePJoqnwfjLVUd0FcUNRYIVEoVz/L/5q4ivzQZFsg1chPXjUs2STbvSRXJCqzzfzje7SI54z4Klj4YkmvHCsjYU52LyCHa77L1j6xqDX/KstIWUqXoQpIky+0G6du+n83+QAWYG9hfRsP977zdow9dggKjfSaECCPtGThkCnJltHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none X-Received: from DM6PR12MB3163.namprd12.prod.outlook.com (20.179.71.154) by DM6PR12MB3675.namprd12.prod.outlook.com (10.255.76.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.28; Wed, 20 Nov 2019 20:08:17 +0000 X-Received: from DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::dd0c:8e53:4913:8ef4]) by DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::dd0c:8e53:4913:8ef4%5]) with mapi id 15.20.2451.031; Wed, 20 Nov 2019 20:08:17 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io Cc: Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Michael D Kinney , Liming Gao , Eric Dong , Ray Ni , Brijesh Singh Subject: [edk2-devel] [RFC PATCH v3 31/43] OvmfPkg/Sec: Enable cache early to speed up booting Date: Wed, 20 Nov 2019 14:06:53 -0600 Message-Id: <1239290da9310bd688d9d25fb83737c5ca122882.1574280425.git.thomas.lendacky@amd.com> In-Reply-To: References: X-ClientProxiedBy: DM3PR12CA0087.namprd12.prod.outlook.com (2603:10b6:0:57::31) To DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:15e::26) MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ffa2b7b4-a1a1-4e59-20e5-08d76df55053 X-MS-TrafficTypeDiagnostic: DM6PR12MB3675: X-MS-Exchange-PUrlCount: 1 X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+50971+1787277+3901457@groups.io; helo=web01.groups.io; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: zsXyI9QOyvrVpImwMLl5JV4N7kgFpYuNcyMZjV1Nj8FpRFGJuqSDOspxrFgsBt2EXi9zgoTrF5xW9IZC/LRmJbTCDsTn4Kj9sTCzybVvMVQKZk5gN5p7wLmRyRFShGAzND+wrTeXxQM8zTJEv8dH/lFn7rp7fTedGqDRIs8l+i7g4cVrsEqx4pxUPsJWr8xpJEGA1NSK2NgAdhmwQe5mnP7/seGWVJV5HXUfKKTzZH8fFSAoAM0NrBYTz/KRCUJu2Sn0oRdITsv/FP/kjWB713b4b4i6GBXKPKS0JxTGjvgbMLPfBcIsemk5dmZ4jp/s6Fw7sBBW3SvfBT6FJuOsafaqyej2bL05EUURXKMwL2Hve1EPniNn720/m9BDBoHqvvK0S9Iep8XNcM895XI9xbnkWco1acdz3VzaspHyO4Jci8/ClC00ZlGqWyZ61ngn8/nwvbbO6NfrpVOQeqW7Z2k7KU5/wVCm11xwTGHEyNI= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ffa2b7b4-a1a1-4e59-20e5-08d76df55053 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2019 20:07:48.0233 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kZA1A5Ti6T00EDZjysEnIQ1zvUNFo+syKYbH79m5N7P/8sOcPV56wyg8xGHg7Iyce3Gj/jfILkbF8m1JhHb54Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3675 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,thomas.lendacky@amd.com X-Gm-Message-State: MetWkiDgIoOdmSxRJ6wRIjPbx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1574280499; bh=6r799F8dMaRAL++jw0AzYXY9jo8DkBmrctIh2FiGqO4=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=g2lSnC90n9L323NCw9zJcJo8Uy7BHMjKRQZrtrMFOCn6aw6YZwKikxLKRyfZJaEwM+/ 5YdRn17tZkO9sufEKb3Qe9yPT/THV7dtDkNCIO1b06ZQ5OdJWcaWA1c5hy5sJHaLgQoa4 9qsTjVDy4CrGW4lE13Vsb2CUGlbGmg6vjLs= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2198 Currently, the OVMF code relies on the hypervisor to enable the cache support on the processor in order to improve the boot speed. However, with SEV-ES, the hypervisor is not allowed to change the CR0 register to enable caching. Update the OVMF Sec support to enable caching in order to improve the boot speed when running as an SEV-ES guest. Cc: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel Signed-off-by: Tom Lendacky Reviewed-by: Laszlo Ersek --- OvmfPkg/Sec/SecMain.c | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c index db319030ee58..53c850134897 100644 --- a/OvmfPkg/Sec/SecMain.c +++ b/OvmfPkg/Sec/SecMain.c @@ -25,6 +25,9 @@ #include #include #include +#include +#include +#include =20 #include =20 @@ -713,6 +716,39 @@ FindAndReportEntryPoints ( return; } =20 +STATIC +BOOLEAN +SevEsIsEnabled ( + VOID + ) +{ + UINT32 RegEax; + CPUID_MEMORY_ENCRYPTION_INFO_EAX Eax; + MSR_SEV_STATUS_REGISTER Msr; + + // + // Check if the memory encryption leaf exist + // + AsmCpuid (CPUID_EXTENDED_FUNCTION, &RegEax, NULL, NULL, NULL); + if (RegEax >=3D CPUID_MEMORY_ENCRYPTION_INFO) { + // + // CPUID Fn8000_001F[EAX] Bit 1 (Sev supported) + // + AsmCpuid (CPUID_MEMORY_ENCRYPTION_INFO, &Eax.Uint32, NULL, NULL, NULL); + if (Eax.Bits.SevBit && Eax.Bits.SevEsBit) { + // + // Check MSR_0xC0010131 Bit 1 (Sev-Es Enabled) + // + Msr.Uint32 =3D AsmReadMsr32 (MSR_SEV_STATUS); + if (Msr.Bits.SevEsBit) { + return TRUE; + } + } + } + + return FALSE; +} + VOID EFIAPI SecCoreStartupWithStack ( @@ -755,6 +791,15 @@ SecCoreStartupWithStack ( =20 ProcessLibraryConstructorList (NULL, NULL); =20 + // + // Under SEV-ES, the hypervisor can't modify CR0 and so can't enable + // caching in order to speed up the boot. Enable caching early for + // an SEV-ES guest. + // + if (SevEsIsEnabled()) { + AsmEnableCache (); + } + DEBUG ((EFI_D_INFO, "SecCoreStartupWithStack(0x%x, 0x%x)\n", (UINT32)(UINTN)BootFv, --=20 2.17.1 -=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 (#50971): https://edk2.groups.io/g/devel/message/50971 Mute This Topic: https://groups.io/mt/60973138/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-