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=Ex8tnM2H; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.81.83, mailfrom: thomas.lendacky@amd.com) Received: from NAM01-BY2-obe.outbound.protection.outlook.com (NAM01-BY2-obe.outbound.protection.outlook.com [40.107.81.83]) by groups.io with SMTP; Fri, 20 Sep 2019 06:16:47 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iT81yz+fcWiGkebDbAJrnM65V+02x18pQQAhxKEKp5f/KCLmdS07mkXNDloCNef+nqLPbVaHYabOax9qwzUydRE+ywamWoXU/O1EHOUFpsh3fGOLIKHs1UbQotIrmmMl7zZSk40/EEZfEMKwefMK3C73uLA0f5mkJzkGpb/2Vewu8ppwN+Id5LhnhIWxXrcNfsO+untqrkkASwFKlvJgGTZyeupsfL9fJ3Wjf8kCXqdmjeNdAL/4MyaYnl6GcPvJ7XbJNtG0b3ubIC+9aH8gKIhrqyYFlLW4sWe+QS5XBl0p+PeMukEpMcSQUp5VU8+MUwQ4SnVxR2L4acl43lwJ7A== 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=Ypb/cN3XEpC6nmzam0gTbuuSFGKYA6mgpPzL+8E5OtM=; b=YS1kLfLo5U/OG/1U/Zh79seFgKb+0+06s6DTD6tvxivyqEBO6d/xJmIU+pZ6EIuV1qJiGyyGuSzgeMeyjiA/c+J3B2J9VG3b+CquPRpr/L/XlHubMuOWEpuNSSQuDOK0/AeD0Zo3REhMnumutjmQ5zy1xMHT3+LWU05R0FC5L929tUbFsb6gTFcMEBMkmR+i+0vNIr5XJEyUDSm4NHGNUAtzhFYDeiT5Yr+lbWzELhOPAKXPlp6XPojmXmzAPwf9zOUSNRgtyVIJegCXCx2GZ9cB69OZkaaqtyPYxNPnvHstoJdV/1J8ue7EPqKHYwXRL/VuAIc+IgC+N8nHdPrzFg== 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=Ypb/cN3XEpC6nmzam0gTbuuSFGKYA6mgpPzL+8E5OtM=; b=Ex8tnM2HPxfzuFtTHKbWLkvKTMmlSMptbDWyLemBjNTNwVEohEx9I5T+tPuq4KjYWK43m6EKroVV7GuXFgj2aQYh2lBf6rytaX2W+znJ+kmOOF1tFvk/8HZaD7vCXesYBuZjz/Zm3S3jmb3Ws6IWOUtSm5d3Cb+anWjhj4N/oPE= Received: from DM6PR12MB3163.namprd12.prod.outlook.com (20.179.104.150) by DM6PR12MB3995.namprd12.prod.outlook.com (10.255.175.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.23; Fri, 20 Sep 2019 13:16:46 +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; Fri, 20 Sep 2019 13:16:45 +0000 From: "Lendacky, Thomas" To: "devel@edk2.groups.io" Subject: [RFC PATCH v2 39/44] OvmfPkg: Move the GHCB allocations into reserved memory Thread-Topic: [RFC PATCH v2 39/44] OvmfPkg: Move the GHCB allocations into reserved memory Thread-Index: AQHVb7WmcbqDkeRSr0uzt9gjRcV44g== Date: Fri, 20 Sep 2019 13:16:45 +0000 Message-ID: <7a169f2dd9e6ae7f266b8ef2b690865dc04b4764.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: SN6PR06CA0023.namprd06.prod.outlook.com (2603:10b6:805:8e::36) 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: 4dbac3fb-a7e5-49ce-25e3-08d73dccc949 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:DM6PR12MB3995; x-ms-traffictypediagnostic: DM6PR12MB3995: x-ms-exchange-purlcount: 1 x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3044; x-forefront-prvs: 0166B75B74 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(4636009)(39860400002)(366004)(396003)(376002)(136003)(346002)(199004)(189003)(118296001)(186003)(36756003)(99286004)(6512007)(966005)(2906002)(25786009)(66556008)(66476007)(66946007)(50226002)(2501003)(26005)(52116002)(76176011)(64756008)(446003)(11346002)(5640700003)(305945005)(6436002)(5660300002)(7736002)(316002)(6486002)(66066001)(8676002)(14444005)(71200400001)(102836004)(66446008)(6116002)(256004)(3846002)(2616005)(476003)(478600001)(6916009)(1730700003)(81156014)(71190400001)(81166006)(14454004)(6306002)(8936002)(6506007)(386003)(486006)(86362001)(2351001);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR12MB3995;H:DM6PR12MB3163.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX: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: 8xvjs7rb0q5O0BL3Ncpw/7i0ltS1/q7w2HLHwKYet3XhlMs0Ajf/j0Lw6TjTktKjFHvcCkOM37q7EcFCUhh7EYFGK7SliNyGfeGqzBerFnNCk0jeGlqqXURHxSu5hzqQrpwR5CxOjb6uD3KohQyyJWG9/0jDM+ytjk2crvS/hjpQNlpFln4KRiVW4GYfLg6fDZJswp1kt3KccCI7I178C2fs3gwEbqO/kqQWvGfgXVRC0NUpL/xBPiBOvmzmG3l1FOVZBRfmSFA9x3/scJBvbRcqsKfB+zMTho7lSCUzhSrrCsHbM4f+bCEecMsv2w/WwjVfbL+DTm8HtUMJ/s1InX5wANylGKlD9GYHtC41q1jq+gomb4O2zIOkyjDlVL1xL2TMWVQFUouAZ15O5Ccqg721jKy+0n1dHsw4EBQG80A= x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4dbac3fb-a7e5-49ce-25e3-08d73dccc949 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Sep 2019 13:16:45.8190 (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: tgBt/nh87vS/Rn50oM6LxBjZ5jtg3BYCQrmX/MnPq0Lp4z/G/0zWX5G3TEk55NdnsakY5KNWh+iaiZC5HG7ENA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3995 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 After having transitioned from UEFI to the OS, the OS will need to boot the APs. For an SEV-ES guest, the APs will have been parked by UEFI using GHCB pages allocated by UEFI. The hypervisor will write to the GHCB SW_EXITINFO2 field of the GHCB when the AP is booted. As a result, the GHCB pages must be marked reserved so that the OS does not attempt to use them and experience memory corruption because of the hypervisor write. Change the GHCB allocation from the default boot services memory to reserved memory. Cc: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel Signed-off-by: Tom Lendacky --- OvmfPkg/PlatformPei/AmdSev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/PlatformPei/AmdSev.c b/OvmfPkg/PlatformPei/AmdSev.c index d6733447bdf2..53eeb59702ae 100644 --- a/OvmfPkg/PlatformPei/AmdSev.c +++ b/OvmfPkg/PlatformPei/AmdSev.c @@ -49,9 +49,11 @@ AmdSevEsInitialize ( =20 // // Allocate GHCB pages. + // Since the pages must survive across the UEFI to OS transition + // make them reserved. // GhcbPageCount =3D mMaxCpuCount * 2; - GhcbBase =3D AllocatePages (GhcbPageCount); + GhcbBase =3D AllocateReservedPages (GhcbPageCount); ASSERT (GhcbBase); =20 GhcbBasePa =3D (PHYSICAL_ADDRESS)(UINTN) GhcbBase; --=20 2.17.1