From nobody Sun Feb 8 23:26:01 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+59891+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+59891+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1589925155348868.95624654887; Tue, 19 May 2020 14:52:35 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ClSCYY1788612xKV272Kukwa; Tue, 19 May 2020 14:52:35 -0700 X-Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.53]) by mx.groups.io with SMTP id smtpd.web11.983.1589925154464670122 for ; Tue, 19 May 2020 14:52:34 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QGSrsBhpKVzdHoPmt49i83wtxVgr7ff/4lz8b4aYEE/JK8TG4Q+ktFB/76ZPdGkL0fLO9F6hCsj6BKokOtWFyoRV+dnsQldqwPFzaLGtFqAee9vPwtB1+e7LHy+mSphLU34rMFlZxwhdkSJnw3xk1By+ic4y+RlUEHOAuFILDWB3QPxPiGmh3JYyjA4xe44+00ZwnueVE1HVjN5KbqmT1RRCbCDrmH7HIuc1VqOQxWBdvlzhrxtcqpvx/3+CxkVNnSKrghhLYsQzudRU4TiBN+15WTZz0BEw5rgz/un+ZEy8/+HrP5A4xrQ+vqd5g+4rM/RTZCw2U8dg1EbFz96hRw== 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=0b1LbnyzWL6MhHhbC6SyUam6dJ1XU7uVcJRYFhYCqSA=; b=MR5eP2doZq2+GpA14v1iHFzcl7QQgu5dly3ytmnKPAg8ZZ2MEqB9gNXoLyh3I9rnuxrc7F/zeZBnBm7jZpS3eOvDaN/rI9LLYM8n9OdgaWGNXEnee7655BgS8fW5Yig22qUe1rNXStTjrDcx4ij0moXTAke/cQ44P9kivTEFVs2vnELvGByr5q655VArYRReJrkb2LVe703OPVLd3essNG67Y0ZWESr0UHvv31sveg9Ytu4av/w8Yw4H7xx9BqqGU9Hwz+LVOyCH+lSQZ7/DFXyUd+rjSA5ceByIxFkGzRXHQqHpJ+PQTrfDtgFRXolBCm+B/+EBO/Al5B5MBg5pPA== 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 X-Received: from DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) by DM5PR12MB2504.namprd12.prod.outlook.com (2603:10b6:4:b5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.20; Tue, 19 May 2020 21:52:31 +0000 X-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; Tue, 19 May 2020 21:52:31 +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 , Ard Biesheuvel , Anthony Perard , Julien Grall Subject: [edk2-devel] [PATCH v8 35/46] OvmfPkg/PlatformPei: Reserve SEV-ES work area if S3 is supported Date: Tue, 19 May 2020 16:51:03 -0500 Message-Id: In-Reply-To: References: X-ClientProxiedBy: DM6PR11CA0048.namprd11.prod.outlook.com (2603:10b6:5:14c::25) To DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from tlendack-t1.amd.com (165.204.77.1) by DM6PR11CA0048.namprd11.prod.outlook.com (2603:10b6:5:14c::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.25 via Frontend Transport; Tue, 19 May 2020 21:52:03 +0000 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: faa9d040-0f44-4461-11cc-08d7fc3ede03 X-MS-TrafficTypeDiagnostic: DM5PR12MB2504: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: ZZmfqWyqVkZz8EpQ5vbo5tQnjCtmh/N2sVC9ZSUmG7d//+oKX9kMwGkE9bteXzFIUCe1d3udDMjRSyt55KUjymnu+IdO7EuHDzSxHSFhxC3RJcu8r+wpXAcPkcZIrlMss3pzsmfMF0FkAXkBp5uw/BH5rnqB88mcBbQLq8p7b0UzkPw3xp0iQBVaO7Z+ebAdvUCRcDPjHZApO5ewbNDPKWl4zLlmojN/f/ull1O0hmFMCz5I+G5tE6eu6yYhMuRfZy8z7hvGuj0BoVGMNlMtYUgqJFHYYdBB/qBdtsu+uVHIFZFIgTiW/4l6QlutMnuxkMUheff0tilYK24BRYGQgMxZOS6kAJ2yZ2MwUR+ejvmvkmY2Be7yDrpzfYlxpZCvcgIdEZZwrAGiKnbfeQm4xpWe5QqrY8iq48vN9SlfDJUY3xklJckgMEKksas+wcujTcDa1843x+xvr6uwnopOlYLodXoXv3eP7OiiVlIVFm1NuX/FXZHN8+n/Tfg1ZbqPdFSs5vzwSXdaScc5gHOEHdjbEQqXifEbNsSf8jAHF5ezkYfn5tL9DYMcFGDsfSV5VAWZP08C238XkV3I/3O3sw== X-MS-Exchange-AntiSpam-MessageData: vu7191C+K1SrqICoQ9cZgOWIr9jUnPKWKa5PM8fgFQ2kzajjJLTxEn7B8/YRvhry9/PD7TtszxiaoESe4Sr8AjK5tTMj8sT3xiNrUleuw2erpXnsV7lOsxxVtMdWPpFwO4Y67Iw0WpxbuqBhqQWiaMcROIxayoiycSvkzKtPsT9a4aMYl1qMfU+/CPnmOt7PLcDHpKU9UP9kxQFAdmQdK5FlEh5ERYavzTGz0hBixqBhxEy5by9N84ODEnuRSMiUVsOfo6TkZYUGomnuUJhn80fLbb5rJ0CfmHDN41F8qkuigBuWRzw10NKaLb/UpVklpDEFEdx/JYbicSPRiGkYQuhIMSsbxrQ5fz8thocxeGwfzy26AftlPmB+0GQwZScNHEA/fM8A4LnnqhRvfByu+8A01ARj9rTd6hlfgp913Ae+LDKil3VlAZqE3L8G0Q1cJjj6AkVO/MRR5nU6zvu+k0BNC5OpMhsoqRDDlZ3XffU= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: faa9d040-0f44-4461-11cc-08d7fc3ede03 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2020 21:52:04.0758 (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: o6DAh+YumBr/rxXsiY/x2gTHh+Z29+vPePIK/Va6hruNmYtuTR7e9bWvXCZUJxGOcZnoxXLE2mIpx8OPptEKCg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB2504 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,thomas.lendacky@amd.com X-Gm-Message-State: mLBKY5Uxn2Lxy7H1JUR4OXDOx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1589925155; bh=Q/3d3MyAMhVUVF57MpN+UiSh0v/bK2AzhSVAA4ZrlgU=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=OPlzpR4l7jqMYl798TnmgDj3kjtBLJQEV4EFkNPdlTazVNhJaxqAenb//LytoKY8MuX 9KBz5LODr5tLDvXKXXWh+rO/pHYWGzdjqJ8EA/WEQPL4fSgVsKL6aYS8NuxHYt1Hwdm8E GZ2262jOXqsn6oz1Dn7HSLBlZNCOXAYq17Q= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2198 Protect the SEV-ES work area memory used by an SEV-ES guest. Regarding the lifecycle of the SEV-ES memory area: PcdSevEsWorkArea (a) when and how it is initialized after first boot of the VM If SEV-ES is enabled, the SEV-ES area is initialized during the SEC phase [OvmfPkg/ResetVector/Ia32/PageTables64.asm]. (b) how it is protected from memory allocations during DXE If SEV-ES is enabled, then InitializeRamRegions() [OvmfPkg/PlatformPei/MemDetect.c] protects the ranges with either an AcpiNVS (S3 enabled) or BootServicesData (S3 disabled) memory allocation HOB, in PEI. (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 Signed-off-by: Tom Lendacky Reviewed-by: Laszlo Ersek --- OvmfPkg/PlatformPei/PlatformPei.inf | 2 ++ OvmfPkg/PlatformPei/MemDetect.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/Plat= formPei.inf index 4742e1bdf42b..c53be2f4925c 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf @@ -118,6 +118,8 @@ [FixedPcd] gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData + gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaBase + gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaSize =20 [FeaturePcd] gUefiOvmfPkgTokenSpaceGuid.PcdCsmEnable diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetec= t.c index 6b5fee166b5d..ffbbef891a11 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -940,5 +940,25 @@ InitializeRamRegions ( ); } } + +#ifdef MDE_CPU_X64 + if (MemEncryptSevEsIsEnabled ()) { + // + // If SEV-ES is enabled, reserve the SEV-ES work area. + // + // Since this memory range will be used by the Reset Vector on S3 + // resume, it must be reserved as ACPI NVS. + // + // If S3 is unsupported, then various drivers might still write to t= he + // work area. We ought to prevent DXE from serving allocation reques= ts + // such that they would overlap the work area. + // + BuildMemoryAllocationHob ( + (EFI_PHYSICAL_ADDRESS)(UINTN) FixedPcdGet32 (PcdSevEsWorkAreaBase), + (UINT64)(UINTN) FixedPcdGet32 (PcdSevEsWorkAreaSize), + mS3Supported ? EfiACPIMemoryNVS : EfiBootServicesData + ); + } +#endif } } --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#59891): https://edk2.groups.io/g/devel/message/59891 Mute This Topic: https://groups.io/mt/74336597/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-