From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web10.1685.1580857389917988958 for ; Tue, 04 Feb 2020 15:03:11 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=zlz9NmRq; 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=a//mMkKFWEyYAUdgZTpp0CsZ/DrCSkA3U0LY5joz4S8SyAAN0jkVHXUKjvMyE6UfSVOMhmCAqd/QgTgJ2yoW8Xs8PhZDGkhNxCNhtqyabcHaAJPHRg49O/Uw/I63mWWoLdLGAobW2tI1IpnhDRVtACSkWe+XWYFs1pDoqorej8EvngLEhnFMpyOUK5AoT6MoKonNGkmdCVMEJUS9hLmBYM9XQuuTpRZFgAaIuhSrd+iZFb2o2X8+yPfezd1EQu5WD0IrS2SMqRb8hx2UA3GTHMqiRsID8INDtuHxNF/ZCZf0FSYKLTpSfUVkF6QxBrReVcMMJfxu0L/+1bKCujVW4w== 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=ocoGiTnb9S0lUMKlgYerC9dEAFdGQqpobvTdwjEJQKk=; b=Ko+FiEn77WYmgwSWCqPqn+UA1cdxoVGarJXwwZ/iEWg/FvyoiuIevTwpqA/lzWbE06z45Y3nO8U8d2g2NRCql0CQwz0slZXPDFYuNEg3EZL8saqB2D/tPqq6gtd2/qhS6h98xo48/gwKdxw24VRbp9u/3hlmnaCsNGj2ARQCN1IL9TywyrF5B9S0rmmGyuqU6E3viBpXxeDDuF+71ZDliqLs8FMk+hB1eDBeI3aNcj5rQ537w3VWvwnw4bLvgSyduES4MsjWsezcDdxEvAJgYlWwaEGOkbO91ocPuQUYi+Vz0vqwDTw4AfwbHa8cPMrOGitNWJS5Z48mMk47HF0j1Q== 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=ocoGiTnb9S0lUMKlgYerC9dEAFdGQqpobvTdwjEJQKk=; b=zlz9NmRq+uxBCqoxTOl/vVcO9viYJYUOhHskFb49yHLc5J4Y1LFBCzFLSU4EF0w/m3Jfmjwluf1Pn9/4xb6qDBn67xHRy8q9nJ9yss0MAm9BFOJTH/AAdMY8xRDEEjqyLX/OJzv5qmgILsAn5x7vduHEoGeg2QulybLsmEradqw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; Received: from DM6PR12MB3163.namprd12.prod.outlook.com (20.179.71.154) by DM6PR12MB3930.namprd12.prod.outlook.com (10.255.174.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.29; Tue, 4 Feb 2020 23:03:09 +0000 Received: from DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::a0cd:463:f444:c270]) by DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::a0cd:463:f444:c270%7]) with mapi id 15.20.2707.020; Tue, 4 Feb 2020 23:03:09 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io Cc: Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Michael D Kinney , Liming Gao , Eric Dong , Ray Ni , Brijesh Singh Subject: [PATCH v4 39/40] OvmfPkg: Move the GHCB allocations into reserved memory Date: Tue, 4 Feb 2020 17:01:43 -0600 Message-Id: <876b1c9ab30c7e61f1d645024a7ec2f9570a0615.1580857303.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: SN6PR16CA0062.namprd16.prod.outlook.com (2603:10b6:805:ca::39) To DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:15e::26) Return-Path: thomas.lendacky@amd.com MIME-Version: 1.0 Received: from tlendack-t1.amd.com (165.204.77.1) by SN6PR16CA0062.namprd16.prod.outlook.com (2603:10b6:805:ca::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.32 via Frontend Transport; Tue, 4 Feb 2020 23:02:43 +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: 3dab2b76-59c7-4076-299c-08d7a9c657ff X-MS-TrafficTypeDiagnostic: DM6PR12MB3930:|DM6PR12MB3930: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3044; X-Forefront-PRVS: 03030B9493 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4636009)(39860400002)(366004)(376002)(136003)(396003)(346002)(199004)(189003)(4326008)(478600001)(6916009)(81156014)(2616005)(956004)(81166006)(8676002)(966005)(316002)(54906003)(2906002)(6486002)(66476007)(66556008)(52116002)(7696005)(186003)(26005)(16526019)(5660300002)(86362001)(36756003)(66946007)(8936002);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR12MB3930;H:DM6PR12MB3163.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; 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: w0i+kKA7VVGjSS6wsmf3ggUN3nSYVh0HEQETp6rW7FYpOaqOeOkZNhYqgt71nQmTPTwWeAV463xdD4Dfvrbb89r33B//UhPaQ9Kzd6NsYnGwo5AAII30dRj7OnCTuDxpNM1X3ExxzVJYeMu3XC+aBnGq/MdIO9LgzT3bSHPQyAktmbBaPBT33EjUg0+YOqMQU+DmNgcTnybgYacBRdonhLCB7/2vkgkcXAos0O8M0lURf8E9Gjcd/iG5PJebwM2rvVVdKfSNfZFLTNR5iV6/eWXdwjzKVCfl+EFGx+OzMG0bO8YMBqyDIsZsKV8YkTnWu0LlPQpmIOFgeHAOv3rqHKcXLdHNhGTmz9jTuKuvSVJJDtFFbd8YLE4HlGNxT877LKG10V+0xXMKIld1Dvn3yqd+KGmPl7LERDpNdGW5l+tRCAtJ47U0EmR6Zib08cy6vMZc2DI5u9QnM54gLyIsHAncZc/pxk5LHws5MNWmOc77cVyfvIwLjtIzWaZvt2LNv5XwerA7hI6Nq+7sXb4mAg== X-MS-Exchange-AntiSpam-MessageData: Z64TZYjh8hqQjeDb++heEwuqjXul56M3YxV30dqSFQ4ffdrnTSAyVrnl1kE3lz6mmgL3MiWkd9s0GNZwerfITWszZS8eAPa3YEPAdnsDwDJSh7g8u9tKJOiOsr1h+P6HdMvGKbvRbRdbadikZJvImA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3dab2b76-59c7-4076-299c-08d7a9c657ff X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2020 23:02:44.3182 (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: YwOrR61t8Gbz1lSrDJ8mpP6x6/1+6EW73lrCSBFWfEHqPD/gnQVmh1sC+Q1w4GsEnl8hCPS6wlCIJZRVB1LU3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3930 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 b3fd2d86541a..84b337325d5c 100644 --- a/OvmfPkg/PlatformPei/AmdSev.c +++ b/OvmfPkg/PlatformPei/AmdSev.c @@ -49,9 +49,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