From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=zf27X7sk; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.78.59, mailfrom: thomas.lendacky@amd.com) Received: from NAM03-BY2-obe.outbound.protection.outlook.com (NAM03-BY2-obe.outbound.protection.outlook.com [40.107.78.59]) by groups.io with SMTP; Thu, 19 Sep 2019 12:52:46 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kX1krXRC9xgc3zEkIhzVcMsezHSEmvaDxpIVFmgF7J17O3Aoezz6QQPW0RbKJP1yXa1qWCyKcc1nzjb4Bq9VWO2/CubH3P+ODjIY4ZXBY5kC0SyRJlB0cq4PPWLjmgbINAsf2Dy5IyqPn36KohCzevMtD+5GmqgY8ogsdFsb49GhVRmDqg+QuPxS6E7afJPwqWfWN2fxxQPNGF2CEC5c8ky6PvRVpe4lHWvKDYuLcRyGR/EDeWB3LBuxmPhoirsgid6AsW+yJu6PeyJcS4LGLOrlTVgR2zUKd1VF1xQmqlTuFP2AwwaLWkNxskupz77eADoBegfAxCiQLBYLHU/Uvw== 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=rwxQ9iULABB5wfFKCzKwIgQa8RFvb35XfNPiSuO9b9I=; b=C2/poVLcT66HWnBWfpOR4geBUINkKpOSF+GyROB0xoLcg5rJd8M/LoDQrpZeHgI0rrdSaslLG53vZ09B5h2lXrTPVL4+PoY29ZNbYDUaxwaepZ2gUyDtRjuSprJyLhUC4F44bhzVfvqgoqzi0fTkBSXOu3hg6ocMxJftfX0u61qfFF51Wx6C+SJrKmSDLGsc0Lm6t2uTwn3jlhpsRDcSfIDdWn6Ur4t98VeFC4oHciNWMBLaidOg2/uXn5a8D2nZ1NuM0VpzU1vSfVBfas1BWWjvDjWefNxU94/dNYKkdC9m2H3pWMInd/UUxYHOcU3XfukFcbNCc8csVQVSiDaFvw== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rwxQ9iULABB5wfFKCzKwIgQa8RFvb35XfNPiSuO9b9I=; b=zf27X7skvcIN7IXItaX43bn1rRsai+EZOU5AWqRL0ZuunOyu68uNGjJLxMiJ1OT0p6WmOeI0Z1dtCibAEHRqHw7tcaVIbJWoP8f69IBQ1AkYJqu28eZ8zRPBX8Ir3QYqhpin+p22preSdx7osxlOJkJXHEYaWR8+lZ8VSNFv8F0= Received: from DM6PR12MB3163.namprd12.prod.outlook.com (20.179.104.150) by DM6PR12MB3228.namprd12.prod.outlook.com (20.179.105.96) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.13; Thu, 19 Sep 2019 19:52:45 +0000 Received: from DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::400e:f0c3:7ca:2fcc]) by DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::400e:f0c3:7ca:2fcc%6]) with mapi id 15.20.2284.009; Thu, 19 Sep 2019 19:52:45 +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 , "Singh, Brijesh" Subject: [RFC PATCH v2 18/44] OvmfPkg/Sec: Enable cache early to speed up booting Thread-Topic: [RFC PATCH v2 18/44] OvmfPkg/Sec: Enable cache early to speed up booting Thread-Index: AQHVbyPOUvXgJnyOjkKLsmulOdwS/Q== Date: Thu, 19 Sep 2019 19:52:45 +0000 Message-ID: <4d83b7925ad4f808774f442a2a969cc1daf377fe.1568922729.git.thomas.lendacky@amd.com> References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.17.1 x-clientproxiedby: SN4PR0501CA0146.namprd05.prod.outlook.com (2603:10b6:803:2c::24) To DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:182::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [165.204.78.1] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 06c6a937-8e3c-47b8-861b-08d73d3af081 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020);SRVR:DM6PR12MB3228; x-ms-traffictypediagnostic: DM6PR12MB3228: x-ms-exchange-purlcount: 1 x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 016572D96D x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(4636009)(1496009)(366004)(376002)(396003)(136003)(39860400002)(346002)(189003)(199004)(4326008)(26005)(446003)(25786009)(52116002)(14444005)(71200400001)(71190400001)(8936002)(81156014)(81166006)(256004)(8676002)(186003)(50226002)(2351001)(2616005)(102836004)(486006)(11346002)(476003)(66066001)(386003)(6506007)(66446008)(14454004)(76176011)(99286004)(6486002)(36756003)(5640700003)(66556008)(118296001)(3846002)(316002)(7736002)(2501003)(1730700003)(6116002)(5660300002)(478600001)(54906003)(6916009)(966005)(6436002)(2906002)(64756008)(305945005)(86362001)(6512007)(6306002)(66476007)(66946007);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR12MB3228;H:DM6PR12MB3163.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: dKEa+JtYSKeCGD4zBZbVHE6EXtEWh6mCQkpDWR2sBRGUFQT8eIsAcncVU/tvw2fFdqU09e/oegfzJ50bYSJeuC/IQumRyGvKDBolZyDsPwXf73vP5iyiKX6fYnefBR+sfCASTgkRsUoIpMz4C4P1wuLHFStJB9/cTiutf475rPA4d1fuqlEPXf8AmBYdYipfcjhcQMdFmSBsSpONkzWw4EL8pnHTBGVx8/MvRnHz8WLVrP4QVYYY5Qwz8wN/IerHM06rXUKxfHeYUdi6mkFBwDPW6HKx1WmH0BaO0bw0NGlX5rrV2/LSM4MQ96lS3cbu40Y7i6Os9RgcAIik/ePTuWH1+YkswIwjUP7vbN0x64Np4Zuch8xlpXFO8I8PZE3JR0t/dCmzAxZz1iFmfRElpPbvWSynpptjtTRl2lTgV00= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 06c6a937-8e3c-47b8-861b-08d73d3af081 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Sep 2019 19:52:45.0731 (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: jxEwn1t76k9BK5MHj9ktK8NjD6mTOU3/teOMqjc+QgLJ8pXpxLgIW0jwXsxJMX8yUj3mgcSi+nCfLPL4mvsHdA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3228 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable From: Tom Lendacky 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 --- OvmfPkg/Sec/SecMain.inf | 1 + OvmfPkg/Sec/SecMain.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/OvmfPkg/Sec/SecMain.inf b/OvmfPkg/Sec/SecMain.inf index 7f53845f5436..fdf00e5d8be3 100644 --- a/OvmfPkg/Sec/SecMain.inf +++ b/OvmfPkg/Sec/SecMain.inf @@ -51,6 +51,7 @@ [LibraryClasses] ExtractGuidedSectionLib LocalApicLib CpuExceptionHandlerLib + MemEncryptSevLib =20 [Ppis] gEfiTemporaryRamSupportPpiGuid # PPI ALWAYS_PRODUCED diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c index 7f1dfb2e57c1..20716d484ab0 100644 --- a/OvmfPkg/Sec/SecMain.c +++ b/OvmfPkg/Sec/SecMain.c @@ -25,6 +25,7 @@ #include #include #include +#include =20 #include =20 @@ -755,6 +756,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 (MemEncryptSevEsIsEnabled()) { + AsmEnableCache (); + } + DEBUG ((EFI_D_INFO, "SecCoreStartupWithStack(0x%x, 0x%x)\n", (UINT32)(UINTN)BootFv, --=20 2.17.1