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 [40.107.244.83]) by mx.groups.io with SMTP id smtpd.web11.2925.1608065577587608720 for ; Tue, 15 Dec 2020 12:52:57 -0800 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=XYMZgsR8; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.244.83, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=muokHvDl7y5XwMOT4ZTq4ixTYWeEmOFVouaYIgBrBW6B8hwGKces6nm2It7YV8nVF4grSA/WAVJf3+vkN/WceBqXLLAMkfVM7R0q90pZKA0z+VcCI+VdVwCqbzyJSDWJg52tBzCjsAm7xxwIw/kAmp+xDwYkaovPB/MJlXG/qywn01pQ15fus+8xqaPWBUI9jzUn5RgJ0l7caTY0o5O9VkUbJ+spTFg2Vf4ZlupRoh7MbYwD5nNU98xXgiG+L+CZ3wrx7xwuyImUWWXLe0X8y818HDQkRHQq3Xnxp6r0s0HdLv9Fpx9gP7SyckumQ3oIy+H4tj4/Gdb5aukpzGh4jQ== 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=yQEgagDEeKwAQVEjA6tJNseRNmPXZb5+++558chndg0=; b=TEgeA5dHkXVJySMAMb7ff2x0PMxe9kz6ocuvAdgmd9ZV+YEOKFMKgnK03gxq+5cKqVc0NQlRi4ePDIQX1UrobVOfxol9WL5TcSb6n6LPYfeVZFaDlWRP1ly57GcCM+UmTW8v3Ua5Gz/3W41+NTYVtreJemnZG5SQ0vlww0/ewWRJ8S9RsfIBGZlb6De+BgvrdkhwRtnAUdNaTHPGSwz6oxQaNSa8ukDqpf9v/kJF/iwS6qLDgdd1CguT01PWfQh405k+TPWvecManDmwVcWb/kXugj6khD3J25QB12bYFuVU33MXqF9Qgdtc9PtkyJAwQCFYdKQJRMl2kDt1pzU80w== 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=yQEgagDEeKwAQVEjA6tJNseRNmPXZb5+++558chndg0=; b=XYMZgsR8THTXVA4bZcv1i9NCByScoSs5huNRDgQHMjO34OgFZ0Jp2epe6gVSjXLUJfChY9PaD33N93e6hkuGUZobh7pUIDMh4R6PTYwgK3/iy1TtolanCpUZ+uRKeOgMRUbALigU3drBAzziGHMczqHxOQ5IwxwUoVfCD8N+xiQ= 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 (10.168.234.7) by DM6PR12MB4155.namprd12.prod.outlook.com (10.141.8.79) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.15; Tue, 15 Dec 2020 20:52:55 +0000 Received: from DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::d95e:b9d:1d6a:e845]) by DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::d95e:b9d:1d6a:e845%12]) with mapi id 15.20.3654.025; Tue, 15 Dec 2020 20:52:55 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io CC: Brijesh Singh , James Bottomley , Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Anthony Perard , Julien Grall Subject: [PATCH 11/12] OvmfPkg/PlatformPei: Reserve GHCB backup pages if S3 is supported Date: Tue, 15 Dec 2020 14:51:10 -0600 Message-ID: X-Mailer: git-send-email 2.28.0 In-Reply-To: References: X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CH2PR03CA0025.namprd03.prod.outlook.com (2603:10b6:610:59::35) 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 CH2PR03CA0025.namprd03.prod.outlook.com (2603:10b6:610:59::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Tue, 15 Dec 2020 20:52:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a82a7ac7-118e-4e93-8f3e-08d8a13b6576 X-MS-TrafficTypeDiagnostic: DM6PR12MB4155: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qrkWPiNZnR4QcEQhlrBzYsJZQ/wRHbfEO4jfyLeA904m9mNwsI5ZNLQF003P5p25d8jGtT9zlBfeio6bOM1KIbI6x2y2d2060lZp2xoCE2Xt88w7Vl+v3GMVdUZNU+q7cG4UcyyjidWmtL5jFkTs5vDuVgyE6g6R7e2KoIo+EYkd9N8CtHolB937ke4Vhm3E+0f9cSmPCjJHmkJ7BMQ7+/+CfoQrvz/62DKptaQwU2hnQnNyaTe1/nXFs3O5IWndZsGJyoUI7KEFZuBBvmjW2sOFXOkTovGx1uytx5R+KyKpGKpaDcQomB8GQIJjvFXo6ZvQ0wfMymBKya0ziu4feq49aYEgPHQ5v/kE7eVOSRy3fqTLcRIlE7Y5DNc4jDGY/z6+nuiDw5ZWuoIXihb8KDyAoCGgPXwRNPNkSvdwb8t4bQ1Co+szH7Tat7PaqdWlxpIQmhaz5bEE9knu87cgJw== 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;SFS:(4636009)(376002)(366004)(136003)(346002)(66946007)(26005)(4326008)(16526019)(6916009)(8676002)(36756003)(508600001)(52116002)(6666004)(83380400001)(5660300002)(8936002)(966005)(186003)(54906003)(956004)(2616005)(66476007)(2906002)(86362001)(34490700003)(6486002)(66556008)(7696005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?wBy5xyGNAH5kd1kGq+7+brxooOnn0/HSE08EpGJf6HA3zvwOKmNpSBiqGHM5?= =?us-ascii?Q?X+2wj4aMHZuaggaz9z9tcNPI2aVJ4zimz1QCwoG9GGUFmr8V3U0wNDSolisU?= =?us-ascii?Q?1DB9TWeuNUKDzYjtEDzU1DpTAsXtim0bkIbqrZcHkX/k29Eftcz5J6dqR/iZ?= =?us-ascii?Q?ls8mmvHJLMVFWxl8XdxvwC58ZmXBn+SIKuZ5D+dIYDw7xc9Q0H1bfrC+FFIB?= =?us-ascii?Q?786JfPhsDvCdvi6QPcjNE+438wyHc+eefN8rDXGy8HYhiSZaQGTMIdKLc77E?= =?us-ascii?Q?Zu9hK3Z5L9wNzK8szAmbXWjxDoDRsPXRbWqWSgHSJL0eYfLLTtDffMVLtJ8L?= =?us-ascii?Q?Px28rw0Niht3JYyY0l8z9olR/A2Ecf7dZp3DqPJoW8xdefw3YAjoaL1TDLa4?= =?us-ascii?Q?EPhVeZ0TkTeDqZcdX5gcycVVEbd3fOuyKAe3FFCJRMCWj6ceRK5xK9gygNKW?= =?us-ascii?Q?dyAxlXu+meYS77IxzdyIBcfst7tFKj8Rt+vongVPobiK82BSDVC2XtLbwinN?= =?us-ascii?Q?6L09O+/YZhyAhIbEJ3n1GYT/x5cE1XqUm0R3P7VTHRWy5jas6kZc15OQkp7/?= =?us-ascii?Q?SsAvR9++1bj9jVGfiXLvmt1iqtN0pwkx6+PABgWpXqvPCfx6h8h2LHEMgUL3?= =?us-ascii?Q?SQOAe6BHwb6RRuNXWe7QEsLReylJz52jmlBHfZK8kfDzyTuIEg+YBn2zoX8w?= =?us-ascii?Q?/HqeOOCybh5Dxe1T3Pl80iBMWqEd6ILhH7z34M1eR5TmuGv7+1juyDtFZ9Hx?= =?us-ascii?Q?xiKzAXzDmjNl4cktdEqdlGGXnB/DaloWB1Cae7hLFf7/PV9wQKycCXIChvzG?= =?us-ascii?Q?NHxzPV9zo+G5wK0XVyR0El6Ri25j/+mDsQA+kwGyEnokVs+wcU6LfT28hLkg?= =?us-ascii?Q?E+4eus7BHSHSxhuKovT3EZIGED3z1K33Uhlo84c91yd0vqFRBlK1IktbdS+2?= =?us-ascii?Q?eQue+VKvKAQGuS8sKqXgwGlMLdeKaObqAHU0pfEu/rX6+oCVCXlV9u0UydS8?= =?us-ascii?Q?wzBn?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1355.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2020 20:52:54.8497 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-Network-Message-Id: a82a7ac7-118e-4e93-8f3e-08d8a13b6576 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Yf7lxWiZyRk75OmqV1MUpZ7xOAG4j2kI0F1rtQ+mOeeELy1u+jCASpKwclconMqmGNFho/xn1Oc7+i1ltfnxHA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4155 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable From: Tom Lendacky BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3108 Protect the GHCB backup pages used by an SEV-ES guest when S3 is supported. Regarding the lifecycle of the GHCB backup pages: PcdOvmfSecGhcbBackupBase (a) when and how it is initialized after first boot of the VM If SEV-ES is enabled, the GHCB backup pages when a nested #VC is received during the SEC phase [OvmfPkg/Library/VmgExitLib/SecVmgExitVcHandler.c]. (b) how it is protected from memory allocations during DXE If S3 and SEV-ES are enabled, then InitializeRamRegions() [OvmfPkg/PlatformPei/MemDetect.c] protects the ranges with an AcpiNVS memory allocation HOB, in PEI. If S3 is disabled, then these ranges are not protected. PEI switches to the GHCB backup pages in permanent PEI memory and DXE will use these PEI GHCB backup pages, so we don't have to preserve PcdOvmfSecGhcbBackupBase. (c) how it is protected from the OS If S3 is enabled, then (b) reserves it from the OS too. If S3 is disabled, then the range needs no protection. (d) how it is accessed on the S3 resume path It is rewritten same as in (a), which is fine because (b) reserved it. (e) how it is accessed on the warm reset path It is rewritten same as in (a). Cc: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel Cc: Anthony Perard Cc: Julien Grall Cc: Brijesh Singh Signed-off-by: Tom Lendacky --- OvmfPkg/PlatformPei/PlatformPei.inf | 2 ++ OvmfPkg/PlatformPei/MemDetect.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/Plat= formPei.inf index c53be2f4925c..6ef77ba7bb21 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf @@ -118,6 +118,8 @@ [FixedPcd] gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecGhcbBackupBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecGhcbBackupSize gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaBase gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaSize =20 diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetec= t.c index ffbbef891a11..c08aa2e45a53 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -888,6 +888,11 @@ InitializeRamRegions ( (UINT64)(UINTN) PcdGet32 (PcdOvmfSecGhcbSize), EfiACPIMemoryNVS ); + BuildMemoryAllocationHob ( + (EFI_PHYSICAL_ADDRESS)(UINTN) PcdGet32 (PcdOvmfSecGhcbBackupBase), + (UINT64)(UINTN) PcdGet32 (PcdOvmfSecGhcbBackupSize), + EfiACPIMemoryNVS + ); } #endif } --=20 2.28.0