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 [40.107.75.48]) by mx.groups.io with SMTP id smtpd.web10.11916.1595390793757931178 for ; Tue, 21 Jul 2020 21:06:33 -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=RIq0JTyP; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.75.48, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V/cHB9QzmtALPJNsyU4Lt1Rd3RK/dTEhAn0R0/0aeaIFZqYTnQHP/mnQW3aWA1RmH4ewuHt4MkMXxKABFn4+T7sXGaXNKuclgkIH7mmZGCLiA1KQflccrwfaLIqKW+h7Z2dgJ+mBVmOFkKtkYXXmtlaYLOBJUFyVWSS2X10xA9CsgcjNKF8fLk7rZlt44kQkxGeR3P9kRblIkvvPt6aiBOQ0IpQhDyD/AIE89w3uzodpDsMRg5oG/tnKWENbU7R3wCVw6Mx3Mo5/8SPMEoVun4adfJyGgJpLiIASzaA5MnKXfDFTTSRIUVIbDsgPeJm6vHhgMxYaiavnKvfa9tnsjQ== 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=jGgZjT7f4rh2id+QfliuBKJk3oTrdloVO4vDq4rsuhNbVYcLqzDzsSVdd5aWjbLSd9f2STYuPEtXO8arwcMjhYsGG0gLGgrH1otjZK3a6n+kLM47yTcjf1KXHuDaYaYN9FGK4Af2QBtyCo0Jvwp05TS0LWCcKS2vpdsY8ygCuxhUhvg52XNb1yk986vNzy5OyTLuphdJHn3O3Z7ClQjfcJW+DoyCh/w9keaLr8lYtifdxpS4713/9GRebSd6pyATR4HMeFzvNsKJXeVzXT4dZyxB43BpNapuJHNS9YTdt0Q1bKBNeXNifzepF99xFjuvrBnEZ78dos+0nNLadDN1xg== 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=RIq0JTyPK9O/hPRLKsoigzQWsAkm4ggw+vETd3jxjswhFblg+k8werWuz3Q13CsrJ5AXt9OVjzcSrbLB9ck2gBSKnxLJwRwpCBKWbiV8GWi8i7nwT4QMr1AgL7wKsh8GZihfWjoGVdhk3Y6/QzkLET4LChJLECb6EoMRS4b05qo= 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 DM6PR12MB3372.namprd12.prod.outlook.com (2603:10b6:5:11b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.24; Wed, 22 Jul 2020 04:06:32 +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.3216.021; Wed, 22 Jul 2020 04:06:32 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io Subject: [PATCH v11 44/46] OvmfPkg: Move the GHCB allocations into reserved memory Date: Tue, 21 Jul 2020 23:05:48 -0500 Message-ID: <0ad2c75541fcc5da38f54659252bd579994b5fb5.1595366363.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-ClientProxiedBy: SN2PR01CA0079.prod.exchangelabs.com (2603:10b6:800::47) 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 SN2PR01CA0079.prod.exchangelabs.com (2603:10b6:800::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.22 via Frontend Transport; Wed, 22 Jul 2020 04:06:31 +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: eeee0599-89b9-435c-3eaa-08d82df49de6 X-MS-TrafficTypeDiagnostic: DM6PR12MB3372: 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: QTIIk/jbTtVThYSGRkuQoFXNdBE7GJ6b86wpt/AjUp2ap2EMITR8dZBIXNN0+GxtcqxiES72cLoe70Hmknmt7yQsUOSZVdkBzscduUFVHSjhtVYnpAFDq7gChFIb+8yQacnEHl+cN/GShaYOGoysPu+1LDkRVAAbMwhntPw044/GjLfHg3TGG0lpLtiqYOZS7IoZCwO1l0khff+sb2P5lRJUypREU4nPROJGm5Vsl/OYcVqWaeonZR5u9Ck3JTVM8jswFBiBEl6KJ/TZVLFXvDpeLLuWL3ROJ6lBAyn/hLNHwe4aJMkUOiWcIioQC2HdGqXrE4ugr4Lc3CdDJyXiSVDCRu2RiiAslJkoW//gs2SkO630a0ZxFbIVYtaFL9b9jMOKjS4z5/vjRG3F8LJp/FTPxy2CQl4PNzUjetxlas05PESLG2zuvLmpMzxSj4Ps55pTZbHXUsnrpfHLBpUgTQ== 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)(26005)(956004)(5660300002)(2906002)(83380400001)(966005)(36756003)(6486002)(2616005)(86362001)(6916009)(6666004)(8676002)(52116002)(186003)(16526019)(66946007)(8936002)(66556008)(498600001)(66476007)(7696005)(136400200001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 5HD6VyLeX2YdnbdtRp7Nb7WU0gMrIg/kHfiRRLmqpXqr2PGUEnpzEXoilRLWLkLoCE7CI/tV1EBFtFN8jmVTH0DIJM6qARgdbzHgpEzNKxcTsdKsz6SE4l5e6JmS7L0rHA7LaB39ct5+C3vX29BP+h60BPqTKyFzwmGrk9gsUsFmSKRfSoW8G5TJbeybqkRBsrL/z30bBOjGuMQ/NuvP6vwd62TnTdbTYM4h+0D7FZzq/V5Nnb2Gj1hXZSi6BeRqAYsCdxg2cc6QswWmSR3faZB12agCepsYo7XwM71fx5LMg7e5ByklR7IDmUnpXKsCss+nOo4sK0on4zo1XMBLj+Ko7YyaRhAG1fP+rX/Z8CgnlKwAWELpZ882NlwZ5ezVzgXM2d2+BnsORMnhWPR4pp0EW2qOcYUZcvTxuFtrmiT2PZS8KK0qQO0lR70bW/ryC44wvXkCzS+lrJD/TDz+WjkOXHOG9xi/BKlVDXgTe30= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: eeee0599-89b9-435c-3eaa-08d82df49de6 X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1355.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2020 04:06:31.9106 (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: 4Be3bO4e2ye/RK4bKqGIkDWW0Omc11kzy4fAr1FgkrlIf0tNS1QzymsGJo5qMMrrg6CYFxtAGf3t4YBmXybkOA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3372 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