From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM04-BN3-obe.outbound.protection.outlook.com (NAM04-BN3-obe.outbound.protection.outlook.com [40.107.68.62]) by mx.groups.io with SMTP id smtpd.web11.6708.1596837282771828724 for ; Fri, 07 Aug 2020 14:54:43 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=aJa7Rtoy; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.68.62, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AQHaCl9CUs7wddw4fwqoYGYXkp8V5iIpAUUH4HbClk1zY4z5zici6cY8pImST4OOfi17P4Vzwt7+mnBmK+P6llqoQxTffceDFacu68f7/w6k7VepVeNW+7Tn+R0NC6nJSxKZ/plNM9tn5SnJ+GJXY+jmgvr8hquv/aH0tY6XbzOuVK8QiCGsaF/YhhKazoWk51mmZYsomeoRA4VFi0xVWUIIPkdXGR5K1AeT2Nv/bIY/kgo/A6uHp5fyOwqT2N+WY00Hr/G79I8cJbasbGDxJyEayQh76dRR8DBs1gE6lIq/Nbq8j+cSlBBld7K8MgtSDGFfd5lHit6jnYfeuwTLiw== 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=cYWmh/fcAwIXIlWubzjDdUIKKdxtd9nRLkFVJO7hvKY=; b=n6hnA8jmtHoOEhBgFu4j2yY+VI32d9GKfQKM/B84o9I+t2tlUAEQuPtTmWgVmgV46C5Khdoma6MvrU7meDo/54z5wwhwaO9lvl7gnVYm/oc/pkdaujk+VNtDRnFUuJR6UouXPnIIUiTIk+3aLiliQxZlLX9N7kCAjABio6/WRmUICSHdvvQyvtYuAgEzXHrD4GeW+2pWakLa2FCrmYAfF+EvK9cVH6MZBNqottuqfRXOEF68oK4utwai8e/hwjFJpvnCbQLF72c3R3eiZj/HqQTuOof3HhYF6fND/ZIsAtcdELeG6S4Hr3HpQ8F9eNgIiWR/P9zwhD/hcq6GjUrgfQ== 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=cYWmh/fcAwIXIlWubzjDdUIKKdxtd9nRLkFVJO7hvKY=; b=aJa7RtoyPV/B+mKFMuIUxCN5reSlLdZpFh2Vr2QlG0RjWye7Lbs0HxtNXogO0w9/8bfvst5boVekdwGvrNaBfi63Un02JSoc6ywpk5dQ8mtE0t0QIVIH4+g93W3Jm4yUr33LBF229oyHDdC5jKcc2X602FpBt/5H5C2EVQ+92hA= Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=amd.com; Received: from CY4PR12MB1352.namprd12.prod.outlook.com (2603:10b6:903:3a::13) by CY4PR12MB1717.namprd12.prod.outlook.com (2603:10b6:903:11f::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.20; Fri, 7 Aug 2020 21:54:41 +0000 Received: from CY4PR12MB1352.namprd12.prod.outlook.com ([fe80::9181:78bf:bf0:702b]) by CY4PR12MB1352.namprd12.prod.outlook.com ([fe80::9181:78bf:bf0:702b%5]) with mapi id 15.20.3239.024; Fri, 7 Aug 2020 21:54:41 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io Subject: [PATCH v14 44/46] OvmfPkg: Move the GHCB allocations into reserved memory Date: Fri, 7 Aug 2020 16:53:57 -0500 Message-ID: <1f7624e2bdaa880ceff2b49ba73bea955b36e1db.1596829170.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-ClientProxiedBy: DM6PR18CA0026.namprd18.prod.outlook.com (2603:10b6:5:15b::39) To CY4PR12MB1352.namprd12.prod.outlook.com (2603:10b6:903:3a::13) Return-Path: thomas.lendacky@amd.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from tlendack-t1.amd.com (165.204.77.1) by DM6PR18CA0026.namprd18.prod.outlook.com (2603:10b6:5:15b::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.19 via Frontend Transport; Fri, 7 Aug 2020 21:54:40 +0000 X-Mailer: git-send-email 2.27.0 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 303d2840-872c-4521-737f-08d83b1c7cba X-MS-TrafficTypeDiagnostic: CY4PR12MB1717: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3044; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oFuK7NiYZ+Hc3aTmvtCOXlHFu+El4KcvCVVayfnqO9x1hrdJFYIv6jnzF270GuKtYw/u8PsC8TBOk4PoVFuW/x9IVigqC7eR//Fvf02WCushTU/sH6HpKtE1RakQsSI0Ssl6bFJ7+bqww/Avw2edvPUIuhTo5sTruiQuQOP7AS/G4xRSp5SqojbPinqgWyuNL8DsIDkGZNbpQ1SSfprO2yhmyno7+r/UoW3Bo3Jj7BuFx2SntQ+0P9IHrX8Gmr21NFnkAcYHaiSqZaLGS8srZtDioApgsbuvgN4LkcZuCz170CMBUUzgi3pZg/1jLNaU9AwpW+c2GoTeOOih+lRQOQ+IQr0qXQFrBFnGJCLII2ZtW0dLmJGlmGVJmb5GggmInDuJ6jGyUi5oq8lAK/FdMlrlcgTTgGiikg30Sd9f46nV3pOYAm4ck3PKixVMAwqwpEIREyZ94cv0y2GKXmII/Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR12MB1352.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(346002)(366004)(396003)(376002)(39860400002)(26005)(478600001)(966005)(86362001)(16526019)(36756003)(6486002)(2906002)(6666004)(186003)(6916009)(7696005)(52116002)(8936002)(8676002)(316002)(66476007)(5660300002)(66556008)(66946007)(956004)(2616005)(83380400001)(136400200001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: PlC4BVZSyIgDnjWmpS0in69APm6Ohnt20o93e5JpUpPZuU4duIBsxPpHOOGuUFcr6ZWX99rUzwOeXd6iATiwoPGIAR6lFerMQDIgEmv9tZbISHgO2bdDqOPxx/OX29aAfgAu4gd8U4eg0kCdkEm/OJrzpeZcD2rb19ZIl6MABJqhh+tkNlDkcQ8Bwlnpj3elO+a8+5Gs51A0P/YWm3MrYPNzEY7SylFcDyjrZCzCSaeR8nu16CPrfX0j/gxcFv9vGB77wWOP87jhso5vmBgdENGnu4ji4sYcnmFJxcpTojgkYhXwxSAWg2NP8RLP1TBj2JpcwlsYveo5AFxmh7cEdPfYHw/DbT7A84PUbOLfkbazuKNE+FTSaoYLfJxzC/qLj5YhQC2AWmljzeU6j6okdss9CbjY1/15/vWrKcwAWKvJxnuIMM2Ff42cjUQPUZ5bZ6DTN1L6zjQBwXiDMgQI16UrNuecSulo7DdpJl+9Yimqe6rRpCtaa4Y227Yb/97FJVeNVh18ZgMSE63i/Cf30E184LmMZ9a2qhSyyEuHfXT5wFAwruEJnlBjRk3uQ2R3O0785DhILaj0T7cJZg4QFhwx7whbnv4ZyWKFL2inIcefX0saClojTLNHKt8GH+gxny6PzFaNfCTROCCyd2Fzsw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 303d2840-872c-4521-737f-08d83b1c7cba X-MS-Exchange-CrossTenant-AuthSource: CY4PR12MB1352.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2020 21:54:41.2511 (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: YwtyOmsvQR8Ha+prs3FXvvgnp57BXVHwWifJ9u2Y0JcinCsH9WLyvyGsmj5d+h2WCwmEg/Gdk7JMKZVR7uUK6g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1717 Content-Type: text/plain; charset="us-ascii" 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 Reviewed-by: Laszlo Ersek 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 a2b38c591236..4a515a484720 100644 --- a/OvmfPkg/PlatformPei/AmdSev.c +++ b/OvmfPkg/PlatformPei/AmdSev.c @@ -51,9 +51,11 @@ AmdSevEsInitialize ( =20 // // Allocate GHCB and per-CPU variable 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 !=3D NULL); =20 GhcbBasePa =3D (PHYSICAL_ADDRESS)(UINTN) GhcbBase; --=20 2.27.0