From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (NAM02-SN1-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web12.56.1585079095434268982 for ; Tue, 24 Mar 2020 12:44:56 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=KtfiEfuC; spf=none, err=SPF record not found (domain: amd.com, ip: , mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QsxDleNxhJEosu8I4Sw5IL5wnhjDCQB5+WWOskgt5noZ5iPY32EVpVmuxoCvKYOxgu7dHAP/4fpgEjJVTuKfLfyzqpr2z/F7CwEAeIXJtLggrSNX/m3mqMapG2aYqbxZjaJOJfUfv9W79Ab0JA/BDHtcknHnXwfpfdZRkcGohyiZzbqWdd4aw75iKfzBf4R828doQ/tY/2PoHx55lzQslNc2E21fM0h0FN6SvYCZrHjjqyXuln2CFCN1I4Iq/oAoOpU0CYBvSx6CR5z55sfrsx5vI/NJHE/d1z0liu9G+12GYCuDGovAjEXnWgF0HKdCWYVRD4gN4yNsAEpQ+bs4cw== 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=/gD3/JiWWH6lCijCxIDgMBaXHOePBFx/x5o72hLTxhU=; b=KOb7uUf9VyNMFv49X0GilOC8QOiQ4Mts9o9GGNVouGZnM921RlEql4pWBivOCFQshXANtMQhifwn85/Hw+KiCIYRtoTS4HcdC7DAyoLUoEa5f8psanptIG4Mz3CfMiq4OxT5v3028Ry6qb7+41P8hrq81etWvvGTMKCj6O7vBOhODCBWfyOjaYjeTgRxeB1FVPci4IiCBcT9PKqdpWvDBYVEPkrizAu7A9f0+rXX4IlKPE3R9FiSp4gP9lO3aA2+smEClC8jNWzdEz9GcqaGpuxd5FABkPGb/ZY18FhPp2R6mMFLzOkdifSXMjvt+m93uhP/fyCRoJPe6FDBgX1kPQ== 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=/gD3/JiWWH6lCijCxIDgMBaXHOePBFx/x5o72hLTxhU=; b=KtfiEfuCCiwqJ587Ib/pxWtVugh1zZz4f8YXMtB1fZDsSwyh5Py2haqR8srcwHcPRjT1y+hUxho3+U6daPm1ByXCh3YmKFnQiXPw8EuJdCk4AO5/uLLPeTWhho214J9dHEKn74tm0gn5B9M6biGz+UgWbDCpgA4ZW6VyPH3J5IA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; Received: from DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:15e::26) by DM6PR12MB4547.namprd12.prod.outlook.com (2603:10b6:5:2a9::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.20; Tue, 24 Mar 2020 19:44:54 +0000 Received: from DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::f0f9:a88f:f840:2733]) by DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::f0f9:a88f:f840:2733%7]) with mapi id 15.20.2835.023; Tue, 24 Mar 2020 19:44:54 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io Subject: [PATCH v6 41/42] OvmfPkg: Move the GHCB allocations into reserved memory Date: Tue, 24 Mar 2020 14:44:37 -0500 Message-Id: <3768ad6c4f2180f583504ae05550367bd527d994.1585071656.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: DM3PR12CA0109.namprd12.prod.outlook.com (2603:10b6:0:55::29) To DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:15e::26) 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 DM3PR12CA0109.namprd12.prod.outlook.com (2603:10b6:0:55::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.20 via Frontend Transport; Tue, 24 Mar 2020 19:44:53 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 2b02c236-346c-4d78-8e15-08d7d02bd2cb X-MS-TrafficTypeDiagnostic: DM6PR12MB4547: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3044; X-Forefront-PRVS: 03524FBD26 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4636009)(366004)(346002)(39860400002)(376002)(396003)(136003)(66476007)(2906002)(66946007)(8676002)(66556008)(966005)(6486002)(36756003)(5660300002)(7696005)(52116002)(956004)(8936002)(2616005)(186003)(81156014)(81166006)(86362001)(316002)(16526019)(6916009)(26005)(478600001)(6666004)(136400200001);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR12MB4547;H:DM6PR12MB3163.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2qZxtbcgQYnHQ9drInrHlTe86ncJDbQAhoD1arOYSC3MMJ29tXs+axCto24movmdIFOC4fSjmES5m3ve2ZTQhYFdhnlcBvVfgf7g1kfRVc2vUUIYOL4JYatKOfkfMvnWRdVWvG4BxNhWrGwVBFHEgaz9ly4P+E7fhgxfx0m45p/Nzx2QvndRHCjErf3sIYN1wjust0IbvLqAEfAIG3ZUbAcBKJA1ibp+TldZH+wvYC2Gdhqkfi9qJljurLYF/9/SD62TyUJnhjsYMQjLCxlpF+3w+Zf0mRMcRaWYQgHtOAlS/jGG5uFZYahXHexM15HC35hEiKAynH0JV5LmnbKV7K84Hkr0op1yMl6neDGF34WSJNSBoOGFZmlmgDUuibngOFYIYK4nBAyy2cKtBYIH2YpSpABok8UBf/MC9bBOAMVWCWoflA/DfFn2wvS/cvNY4Mj5HzSMHy/2QSuJlKaTGGVSoiu4Ecztu4GtdLtJZu9jt/I37WS/naWAIU2mzmEaj64P+1K865aE56vkERNnjQg/M3SNM0zLP/qiZHUMjjQ4GNM9xBKPXqH2QyWqRDzi8TTHN8lFo7DeLSXxd9yRCQ== X-MS-Exchange-AntiSpam-MessageData: axa6+lpooK62oF4EuMaWO3LP4W8PSm6eUTGTD9jxikswDcjNgAOOP73VQ+A446PoMnNNSiSZ5zqh1j4S2wGotbHa2Q6bIILUOHS/De73YdOLUkQykhGKLsTQnGEv8edN118wfRjCQgs0ceUkkCofuw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2b02c236-346c-4d78-8e15-08d7d02bd2cb X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2020 19:44:53.7929 (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: jjaBseLPHkp4OGcdshMYlTeX8XQKqPNNfVIPK8p3TAn2Bw93eqNReBQOhEBHB/pNnMJLX5NKg5sMjBdKq2NqVQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4547 Content-Type: text/plain BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2198 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 38885de359af..2b6c965808e9 100644 --- a/OvmfPkg/PlatformPei/AmdSev.c +++ b/OvmfPkg/PlatformPei/AmdSev.c @@ -51,9 +51,11 @@ AmdSevEsInitialize ( // // Allocate GHCB and per-CPU variable pages. + // Since the pages must survive across the UEFI to OS transition + // make them reserved. // GhcbPageCount = mMaxCpuCount * 2; - GhcbBase = AllocatePages (GhcbPageCount); + GhcbBase = AllocateReservedPages (GhcbPageCount); ASSERT (GhcbBase != NULL); GhcbBasePa = (PHYSICAL_ADDRESS)(UINTN) GhcbBase; -- 2.17.1