From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web10.91.1583214230107484776 for ; Mon, 02 Mar 2020 21:43:50 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=Wheablu/; 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=S+WJ2tij2AHVatmzD9HCL0gB8OQ2cjDd3wQyWdGKslB9TWaz6/KEDboUmGrn+IOBZNIrN8PZpbZLVGQl+LfRc0SBtyj1AwX0MpDm2d4Ii132Pr16oDcbjh9U3CobernnK5D/+oDHOKscZahn0A/7A8tTHIQLAZoR6O3Eh9JM+LXcHwju6VdxEaRIOO8xY9qBp3IkAGmmLTJ41yiGS62zNMMI8CSC7Do30WY0tVnXiPGZhyQHuZ2TCPazh1bWoLxXtcG4A6Z1l4yUzzWy70gWAk+Mbm74ED04atiABt/XJ7ETruouIEQkpbgtKf4zoVnYR1xOPrsM8l+EtsvG3BOyzQ== 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=Xzr3ojIIKQ7kl3UXQ0IgDMlj/BokjpUk5+7us2k94b5txKdt4P7cxO9HqEvc/FKDmv40qgFd9LICEc3+JaerFVc9Ed6LJmTsLWrIP04GEnPp2F0WA9qv8OHTNNo6nHF3/c+Uu2t9oekkOOuV8PNhS7WxaT8TxyF56LUEIQRbWMXQv2ZS5devP7ST/sZ6/I78LqvFDkf2b9Qy1CCgOFqBoIj5MKvAbMcVCvlHlup1XHxzSGWp7UQZDotXX6c6AqzMD2YkxOIXRQVyPxgmcFinon8hdolfoVXdqEJSbh4yx5j9N/okvvxfXzQZly/7yV+EX2vCGCB16+bUlWX4JZUmTw== 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=Wheablu/F0zu5ULW0MYWtbLFTqnZ+wD56EEa7614nPDERBnVqxYZCjYVOb+zyHdbRFLMWmW6Vr2baOWA2AI0xOXKoPcvnhAhT2r5K2Z0rrKJ3l1FbuSUEoLI8LRCkWnJa4o/tzFFD9yfsVHyH2N6BgDNRKsXvCsPg6QsR5Tu1R4= 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 DM6PR12MB3291.namprd12.prod.outlook.com (2603:10b6:5:186::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.16; Tue, 3 Mar 2020 05:43:48 +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.2772.019; Tue, 3 Mar 2020 05:43:48 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io Subject: [PATCH v5 41/42] OvmfPkg: Move the GHCB allocations into reserved memory Date: Mon, 2 Mar 2020 23:43:34 -0600 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: SN4PR0501CA0066.namprd05.prod.outlook.com (2603:10b6:803:41::43) 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 SN4PR0501CA0066.namprd05.prod.outlook.com (2603:10b6:803:41::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2793.5 via Frontend Transport; Tue, 3 Mar 2020 05:43:47 +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: 78a83004-74c7-450a-344d-08d7bf35d827 X-MS-TrafficTypeDiagnostic: DM6PR12MB3291: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3044; X-Forefront-PRVS: 03319F6FEF X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4636009)(136003)(366004)(376002)(346002)(39860400002)(396003)(199004)(189003)(5660300002)(26005)(8676002)(81166006)(6666004)(81156014)(956004)(2616005)(316002)(16526019)(6916009)(66946007)(66476007)(66556008)(186003)(86362001)(36756003)(52116002)(7696005)(2906002)(966005)(6486002)(8936002)(478600001);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR12MB3291;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: 7z2opyOBkHS59TEWV6/eyES49SO6/Tdw0dM1ud8M9KUduNlmVEuKyLKfUaQVJajrKsdUhyCjCqFDZhC2ozllv7bct2MlBjtsF6ohV6snL3mJtSLKQ4X8anUfJL/iDPcjIm1BwVr6ovizTnwSJtnnC8ZkDAnGd9EsdtT/LtcHizjqIP6aXBw0pl6OD7zFMg5R64RqiF53SvrYMHrx3VVJREEE4rqYJZSVebhNk8AWExyrBAEBgu/7YdrJBIhjVKbbO3Zk0AisgV6VeRoCjdKTZKdfn3i/vqKhXRm4QNzJttE7ceeHz3AR6qRKHyIULUgvJXLOk6X4hqR8Lw8Nthp4PFpxMZvX48vbOj5x5amKYob0FxRyFq5XxirTXnzIvqSvkELpWrcyemAodqB6B2Y1t+562eh/u06VyYwBf7c05t7jQvuytlO+P/amyk0MYb0TeXYtdsHqs/j1Eo6J6Whjh3wUwk+k3CarVNM7N7lI9tT3c90n4A5IsuB+bbHeVV7WQ1+vsu+ghD2lnfXItZu0EA== X-MS-Exchange-AntiSpam-MessageData: bujRI6OSSti2KZhMjqe/Z9toYoIG6xvxDlXqJXOPWMJxCpaY6JcRGYoej+CoAYBhfakmJf+UbSfLPr04c8rca1KTgVWZZO1GY4qR0Zd0aVEN38TtjuElhpOqHRcdj1QHkF6tMwMmPaXLlkpUNYTLTA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 78a83004-74c7-450a-344d-08d7bf35d827 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2020 05:43:47.8333 (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: kNdjKCh3ZH5MMv1ocC3PCl+9LQ4V+21+FRZdg3YSVHUBhDERcAHDoJGGUjJqv3+1JEM7e/FRHoYUcRR6fF91qQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3291 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