From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (NAM02-CY1-obe.outbound.protection.outlook.com [40.107.76.70]) by mx.groups.io with SMTP id smtpd.web12.4696.1594756268258668135 for ; Tue, 14 Jul 2020 12:51:08 -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=nbfr3fVv; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.76.70, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lMfry+mLMllIqNxmi2AAlK9Pse3IdJb7T6izT2h0OwiBjK0KhY6OjCZwee8Jum6qeBok2LS45qofIOcnsvv362Jsn3+orA+wAVo0ePe+Hu2lbyvmBA4axDS6W5+9WQeLUNtYvyCBT0DbyZQC7jVDqSQfNt/wwuys91n/UiJfPGDT+92XKCbbo7WGhyr1CgdaUjI29m87NWz5iKbxKuyLdJG8XsD8Zkp7q5IzubRKiQOyLmZKDBXS5O7xH3sW+HhdNHsikHN4rQB8CBem952kIi5EfAPng8G5xGiIzUfR4igAaYFZxvbQbiPdTSbXpyQpg7wDCiEimvpw2OVN/kqwXQ== 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=hOzRAUXWVeQ6wEdl7TozimjQXxlLIMnsnmTNG8XfEGI50y72kFkRVt8Mz6rQBAw4YWHKIXeyOOGIy8WokgLrDHH9VIgnmFt/9yBDK99H7OdQpSnEJ4o18eujJkKV5109b/++nLTNXF8bKuVjh2aSY04pUR90PHmDqSf0ne5jEt2yJ4+g5pA9hNZTpUZMPkvWLhYPJIlgMNRkX9yqIBwaJzAztV5jwibBmhke3Vh2JANrl+c5TRBIaPvtdEMmR10jq/RNQVoSNDYEckmvclShKqUhFMaQ8l5UoHgLnlPks4G5MVsxIr5oul3zuCXW65sMJy+nISTyF6x43k+q5cs3Jw== 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=nbfr3fVvkn1yEOTjiIWRXJ6QPlqygUJd1ZCRCYFPj+7G+lI2MADZzALa9vVknhi5bMcwR1nW9/E94tKY/mzrZBvUSy7GwTcyUcsnRMxUE3U3d5+bYvBZH45OtWdghEdYVPeE+Yd2/NRzkboomxc2iPy2YcOGBeJJcp9bhxauD3E= 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 DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) by DM5PR12MB1834.namprd12.prod.outlook.com (2603:10b6:3:10a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.17; Tue, 14 Jul 2020 19:51:07 +0000 Received: from DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::25ec:e6ba:197c:4eb0]) by DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::25ec:e6ba:197c:4eb0%8]) with mapi id 15.20.3174.026; Tue, 14 Jul 2020 19:51:07 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io Subject: [PATCH v10 44/46] OvmfPkg: Move the GHCB allocations into reserved memory Date: Tue, 14 Jul 2020 14:50:24 -0500 Message-ID: <2fb723fe6cecc060c587abd5cfdcf0c12a484fd0.1594736896.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-ClientProxiedBy: SN2PR01CA0041.prod.exchangelabs.com (2603:10b6:804:2::51) To DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) 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 SN2PR01CA0041.prod.exchangelabs.com (2603:10b6:804:2::51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.22 via Frontend Transport; Tue, 14 Jul 2020 19:51:06 +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: 632ec85d-8bd4-4911-6f48-08d8282f3fb8 X-MS-TrafficTypeDiagnostic: DM5PR12MB1834: 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: LMIToNNYZrqvz3LzsgZdr2/dPJv6f1CELrN6SFjjlXjn51z3utnPNGJ8iMNliyCnyXBLUyW3YaqxFUGFdZkY08oW173PXwKb9llI6OcBKNBrBfOTec2a3ASJYv5sN4vdh9LYkRD8g08u5ongGTug5SOJTm9kwJpmGDoVXF3rNy/DGUCW10MML4m8WfzVrQqZJIpYqYBuwzSuUtfkpouH1LtxsUFi2ycA5vWVmULqSxqAbw96UVNZn9y6pQjq84vFVHdrVho2Eab4Q0vXHQ105RBcQ/u3C/rcl9FeqSRpLckFQcJZJz3t/YzGNKbQKlwigrYoLb0dcS3+k5Ov/SH3BlxOi8j8H2rWr4VAq/rIn7MsrLcIYpeT6KAW4Ax0ipDIPpZ06z2cyiADBo0QNI8RhpU2u/CqnrX5rewQL/yxE7sDAS+gnm/XaiACkl7yw341HJhNLl1L5o36L3f2ESXmZA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR12MB1355.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(366004)(39860400002)(376002)(396003)(136003)(346002)(186003)(966005)(26005)(66946007)(8676002)(16526019)(5660300002)(66556008)(86362001)(66476007)(6916009)(2616005)(6666004)(956004)(7696005)(8936002)(478600001)(2906002)(83380400001)(52116002)(316002)(6486002)(36756003)(136400200001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: lgpdd3U26mpJTjHK03ZbIYdxpa5vJOy7nJ9ierpI/KZcj4uIAHZJ8uo7kNk8Cq6SvovTtb2iq4FzH34Sp6h/QOyVHSOy6YxDbrloMT+7PUz5X/8VuQOt8oIbI3zsy+3L5+vF+xmp7h7tqSk16XR0T3F0HL/tI9VEHpSCoV0sGIvqqdSRuluUutrhe/N0h4zavL+WDv+xGbOGnVtJa1wM1QA7zi05GqSckb6fEfNZpRYKiDNpo+/VK7tMuDtgWUWIw8WaFAk+NUY42X8rHYItnQbccr2I6X25ueFIJdPGTe+IWjCcyCVWpu56uaW7WkSIf2dhLU9f2nQJVWmSjBANp8z2TtHKeXXdlAwd0T7CaJZUmNr7rcnUDYKhDKyuz9mfKcTTJ4Tid/rqJhY1UT1g6xvPb+qi6ZldsYITXD3GRu3mfcr7cgU29bFy4Jo1YgYRKjfFb2MyWbU9MCCnLbtcXruofqGBoGXABaap/3IGd0s= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 632ec85d-8bd4-4911-6f48-08d8282f3fb8 X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1355.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2020 19:51:07.2050 (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: jb2rIDe3SYCMIzX0HZrw6rRbfkRQ5NI9KWedmu2pWtSEq9igN2YE2zavwqZR8Dp+kmNnjvBuGhq4clAIr4H0ug== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1834 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