From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web12.1408.1589993813327368455 for ; Wed, 20 May 2020 09:56:54 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=lNnZE/LI; 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=Ye+yroEbJ6CrBSM9GBN8/tsjUMCUVc6Bv+9YnqdJjTsFq8b1TOoWe34REVA4xaYe/issHSkQZdChzmAQ07x8MN2pALRDh5UiDDkMMjfRq7agxklZNXKp4gs7e4l3zMUwAeFyv9asjI3OGIJ74hcFDNE3UxrnQMKK34SoP/QlUzhf4hys/DNkDv+CNgvCRnatL3oTx4djJ9dF5bUz/YJBeZ0q5pY3/54uFa4cDJsV7+7ChdDDTRNJKZntI9TlP3Y5/bX1ySgV7LI61+kfoiQ0JAJAIEMeY4wn8HcTsTMyxaCNE/MysEciYRnJSZagNtOKdhct3IRhjYuX1KN+0M5jzw== 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=ivI3lLvjlX/89++8Q9GsWSFFNQ5zLypLhp+8HoZGnarPqzeOSeYFf7W6rVnFIDKegyQBJB8sThKiOeAdWr7plLpaYW/Lm9Ua4QI0DXQjvw+sXUT3fxWtUsLlK864JJWqxIVVhGZIBhPoVaPD9qfX6IdNZGnYd7rNQuxgJVxOo468Q0PB14qRa83QeP8oQIh2VUyNW8qBFxWmXgNCG6gOOEHVNB6GUzXYu8TQ19tPo/GpjJ83XT5+l6fjWrsUxHzJDEt5uAqDTaaXRDVg5T94bBsEEsX1Ssa4YK6E+EGwLHz2SClC6XV2/Mszokm2T+HeZgEtwq7O3zvbqudBHQzA+Q== 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=lNnZE/LIYioK59Mabf5b8YiACM9xa2d7Rqtmz2waHKCJ8GFva4vCFSpy0I/MljRsWXxtP6hCXuLfJeMpIA2QQ0LmRh8Zvxo1s3qfWTjHv4x/yoRsUhh/K6SYryrAifeR6M6a3xdsV18xvx3/tWbsBIWjbgG3gmyBDP+PUV9wrP0= 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 DM5PR12MB1578.namprd12.prod.outlook.com (2603:10b6:4:e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.25; Wed, 20 May 2020 16:56:53 +0000 Received: from DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::4ce1:9947:9681:c8b1]) by DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::4ce1:9947:9681:c8b1%10]) with mapi id 15.20.3000.034; Wed, 20 May 2020 16:56:53 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io Subject: [PATCH v8 44/46] OvmfPkg: Move the GHCB allocations into reserved memory Date: Wed, 20 May 2020 11:56:37 -0500 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: DM6PR08CA0026.namprd08.prod.outlook.com (2603:10b6:5:80::39) 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 DM6PR08CA0026.namprd08.prod.outlook.com (2603:10b6:5:80::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23 via Frontend Transport; Wed, 20 May 2020 16:56:52 +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: 1ab7a1b0-4d60-46fa-cf97-08d7fcdecbca X-MS-TrafficTypeDiagnostic: DM5PR12MB1578: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3044; X-Forefront-PRVS: 04097B7F7F X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZElFWV6I1y/SGbGOMV6gtEcb//4VSYpGcIzm1wSKk+y/e5lrSuk11QNxe5i+ulAh3PyWtEIlo3ep+mPtoT2JrQzZz/UrxAkVUKrLlZx+hIGowJ9qR6wFswHn4AkY/zEiwJAR0xZ1KDp8e5EOn3YJD5CZaRa7NY/5Sv1xZWHx1srocz2o9SVKBAkvfhnWxPg7iDlSh9ugVXKHVFfphJC/V3aEp1+ljfAgiOpAOyIEwW+YumX5wf7sG5JVxOE8XZhTFBV/KcqlQFW7XBGQC8KyCs8CzE5bRiuBAeCW61OmuYjx8Nq90sQqN4OR1w3VvG4Dh9rG3V3IWDLDZFURavwg0b43GrrbG8ivf5aOZmf86rT5XnXGXjaH5EKgdTcIpnt1HMiKleCUr7+29HGEVKdcgY0ISIwUaGUqDyjTmtVF+Y8hULAxgTMTFcF+EISIVAEBqGeqy8WGl6BEhOoIkjzbYCSl1+5qao6VZFMbKBin3oCuuBCzialwkDl+aEi675PxhfMz5JIAyLc3ccHjMPa1P7k0SsM7Jck9Viq4uvbaBny5z86QXxEOAeKMIsK74oq0NhXYhYBMi1WUUVMXK0xXyw== 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)(136003)(366004)(39860400002)(396003)(346002)(376002)(5660300002)(2906002)(956004)(66476007)(6916009)(6666004)(66556008)(66946007)(966005)(8676002)(8936002)(316002)(36756003)(7696005)(52116002)(2616005)(26005)(186003)(478600001)(6486002)(16526019)(86362001)(136400200001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: hvoV+NEVkMHaph7y3dX31hNutISkg1ci7ukI71OkEHqXxkdaw8vftKJbQqY2mLcU2uBxByXS+Z6zT8ddGCfeZDEi3/kuVcDsMDptGvQaDZE0KgI+5cLtmEKEhk7R91EC9aZiCZcH5MVMim2obDG+RfK9OESE5C0zjwT0g2ROjnLgN2E4A7CHZE5eVazXAHdDu2Wb5Qr7B4YwlAziB9xv7e8z8x8D3O2JP75VsAmg8ebBnbmVHl5jYxINm+78+V0EQGJ9jfEYHV0IaE7ddy0iTmF4mJX83fyz9Qi9gM1DRWvAt+daN2tr0gr8kKNt9Fnv5asMOOHLb0/YgRjFOm3D8KJLmoSeDvSMkJTAEmbuGvVQaHC+BMsAe2bzgMjIcS8hIuSy5rjCWsrJSukCCKJ/lF5FXcqDtuolQi7JX+dBS3RVKn8jYAKlfKsBuxJ59S9+Rd5wciTuO4exRPOAfdwaB5+qcs8m0I32Y0KB2YBea4Q= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1ab7a1b0-4d60-46fa-cf97-08d7fcdecbca X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2020 16:56:53.0938 (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: Rk7ESgVLPyo7ODTJ/K7XGmx0QHSx4nqLP/7xphygvvdLdW+Aq9PoraX2eWr97ZE2XknC6DMbnCLJ24gqlHfE2g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1578 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