From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-BL2-obe.outbound.protection.outlook.com (NAM02-BL2-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web12.629.1587616437172260741 for ; Wed, 22 Apr 2020 21:33:58 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=Em5kW+sA; 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=b+R9+HiXHW3S1mvIkwzst5WSJEo8FW5TAyKbo+jnLr9TEWrFhV9GBpZ+tiZJccGERtBBf2xMyxnB9oPzf8LD9sOD0chiXMrfcTNsBdoxSDG/2l3sRMoTup3cumbwPzrnm4nv0c0Ys1wc+AtHlMfm95PK52I3Zx9/PMo1pjlQIDLSoEInCVu30wbemyxvbgsUt/te4BeaADmmPvcKPaMOxLDtWZcVwsFaTTvt+fdHL8PX2UmMFwT4NJUnG562n2O19x//+gEfS0sxzC162u6HbTSNMsC8Im90c5kzHTPxRK9/lIiiX2prQF3l+kzEbSTDQrXTSS6uXyy5JnXJOnq4DQ== 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=h/HsJtfcCrSFBrqeh53xWY83LTIhtvHdgADj1Yi5fEg=; b=gzZbNYGARE9EV+cMi3xcLu9tRkSHzOKXNvoT2tm8oDjRKSxV/oNoCFsLISi9tSzBa8Najik29dRsNQvDW1u8thuE9wVKiKP8B+rBrQPokywLwegTfHdq+vlU8svB6N3cJVmtncWYhcljcmgmyMjUCCoHW9nh2g73wgpIa437hSlKqR5fi4jC0NrnrnvP/jjrvgMyLnrpYdEkQ8afEN5cX402oTg8rCxnxtCWEgCm+HsChEOAeMGsMnjut1rw0nVvU5XZuYDhi1MKXJjB3veAUuVhVItCkFtqxlh5VUOgX/Imauc1yBCPzrb4vATGMv4ZjS7vr1d4KtNICk/EB+0X6Q== 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=h/HsJtfcCrSFBrqeh53xWY83LTIhtvHdgADj1Yi5fEg=; b=Em5kW+sAgpGI6ZrqB3ep3G+vM21k/ZVegU6QblwWb0aIZM/JcbaA2ljzeYdJsaj1x4zSPIflOYyoOBt4xWI+va/j7lMZ1lPKWyzZuEF1O2IQgmyfjBA8Jp3NFGO9ER3DkoBmIikCP9RC/qz+RnXZQ+PgVaRLevvRjm5FbCqyg30= 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 DM6PR12MB3228.namprd12.prod.outlook.com (2603:10b6:5:18c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.29; Thu, 23 Apr 2020 04:33:56 +0000 Received: from DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::9ae:cb95:c925:d5bf]) by DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::9ae:cb95:c925:d5bf%4]) with mapi id 15.20.2921.032; Thu, 23 Apr 2020 04:33:56 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io Subject: [PATCH v7 42/43] OvmfPkg: Move the GHCB allocations into reserved memory Date: Wed, 22 Apr 2020 23:33:42 -0500 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: SN4PR0201CA0053.namprd02.prod.outlook.com (2603:10b6:803:20::15) 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 SN4PR0201CA0053.namprd02.prod.outlook.com (2603:10b6:803:20::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.13 via Frontend Transport; Thu, 23 Apr 2020 04:33:55 +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: 198d7a41-6859-4a50-4452-08d7e73f88c3 X-MS-TrafficTypeDiagnostic: DM6PR12MB3228: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3044; X-Forefront-PRVS: 03827AF76E X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB3163.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(10009020)(4636009)(396003)(39860400002)(366004)(136003)(346002)(376002)(2906002)(186003)(6666004)(16526019)(86362001)(66556008)(66476007)(966005)(316002)(66946007)(7696005)(26005)(6916009)(6486002)(8676002)(8936002)(36756003)(52116002)(5660300002)(81156014)(956004)(478600001)(2616005)(136400200001);DIR:OUT;SFP:1101; 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: YdsV/GbMBQlBjX6UF6pCK2lgyZeg7fXutM/JwLEdup0BF42fgmHlznFb3etokvhSnHs5MM21tSxxIiU8Fl+l8jEGfubb18LYXDM6GKzoZuBoyZpvni2uTliCF9KjZKRpW8CMCX5rly9RkW5j7JW+6EI2p56he2MViOa6m/82PCf5Wo+luBpfSONS227XLS/CIEm2TKGuizHP9OqYuMSJBjvSrPcQcQ6dEECQb4P/Ne9790po/uwUlM8dYo9HEtRtTVgcJqu7xwaYIcr4MX3BtslB6HFpWxXJ7hmy4OAzklfIQopDLYPI3MR77adJbK5T/SFk599vfu1RU3vs5IRIWhO5CqV9jY+DzfMWHvup4XrrszsiVehEojClyhoHlewWDE6MAxFzYG/LP8sCnHiuuFTSizvHiOZiVTVidhEnY6LzwPqv8QGJI3rJ84nI9sJBsbzBpg2PZ4c0TiLNHhAkLIpD7q0ek1AwoK2XIpDcm63UyM04IJCPO8kK16gvxPa4McrnSq5N8tgU85hkEq1FzfTZlLpaRs/WMWam3+TkaVbJq+PveBXBWaemJby3SbwGkQgjnGa5t2ZP+Ldd9rIRVg== X-MS-Exchange-AntiSpam-MessageData: 1SjMrxauRT+du34ZOvvM+IIA3wdvKsMSqn+9VI6ABoERjxwC2KUE2MDjK03h7pS806C6FeQ1nz3gNHN5/s97Ho9Swndxu1bCmfVOi3Ypq8Kh0+GPpNVRDKHMjDSLlFxmmCxhGnlfW/8fu/HWWxIAsQ== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 198d7a41-6859-4a50-4452-08d7e73f88c3 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2020 04:33:56.3406 (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: ep0F2jw4ViSPlwA3QOdjsQuyyspJNWiDkbNZ0RNLKOAMf6cuYzks77P8IGrqh3PYGNBybpK7h/DJfHRKgdL1YA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3228 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 a2b38c591236..4a515a484720 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