From nobody Sun Feb 8 21:32:16 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+63026+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+63026+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 1595366675599865.2938395601414; Tue, 21 Jul 2020 14:24:35 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id RrJgYY1788612xvXIe7Nwr2Q; Tue, 21 Jul 2020 14:24:35 -0700 X-Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.86]) by mx.groups.io with SMTP id smtpd.web11.5574.1595366674495006884 for ; Tue, 21 Jul 2020 14:24:34 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eSHMa3QoniZnbP2CiNzNDKOlPV9lKnAVGY6fUxVU8QXrHRS0xj3QvGn+Z/HoJktoB9elj6UknYZ2LDcCQvd6ouRcx2jcPQj2NGWzVGpzqIhMlzOTRybR9m93g5dxAleYV60MkyFbnNYddNV9EQKUNpqHgdmsU4jBU5broxWs13tkB+/0SIY8dzwbEMkesBKh+w+moKQEMPmTvM1PNCk+3ownku2Xd5kkBJpMugsK2k2JfCBd+Fs2MfnTJK8MM0kE/Csr/AV4V7ncon+aDh2hK6lXqhFTUkFW0lKYAvTesQEC9Clm136VGGLGitUrF10Wbq9NJtj2FRc6I+yQnBkILQ== 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=JkyhLOofvIbow8VdM+XsfKiaUSck6a3v3S8jdpNjfQo=; b=ZGRaNLIr8V3IyulV52Hv4vy7P+QNy4vWFmC/BcMhKYkZ64SMPkOcqePM7T9zkv6/3ywmGoe/ii50FhODAm39vBJ36JHf6TcwmuU42oG+sKuKpF9lFl4N4CiefnDgcsHvuTmFOt4BmCdao1gviEHHhRweGV7EU6GSAtsYHE4pDZ+JvCpEit/rp0+4+dm6djcpfaexzELIPAkTdmuWutCaT3KBnBMuLb60+DV1hwD43NmxAmwhDNK9wnzZsteldQ1jzZH21lFLxzCY6tY3AnpYi6W8oTb5dZdstoNlEYB1Xxu/5QS661eWk0zKDt4C7BRTOo31h3uhJ9ibPahuM0fwzA== 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 CY4PR12MB1352.namprd12.prod.outlook.com (2603:10b6:903:3a::13) by CY4PR12MB1143.namprd12.prod.outlook.com (2603:10b6:903:38::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.25; Tue, 21 Jul 2020 21:24:31 +0000 X-Received: from CY4PR12MB1352.namprd12.prod.outlook.com ([fe80::9181:78bf:bf0:702b]) by CY4PR12MB1352.namprd12.prod.outlook.com ([fe80::9181:78bf:bf0:702b%5]) with mapi id 15.20.3216.020; Tue, 21 Jul 2020 21:24:31 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io CC: Brijesh Singh , Ard Biesheuvel , Eric Dong , Jordan Justen , Laszlo Ersek , Liming Gao , Michael D Kinney , Ray Ni , Anthony Perard , Julien Grall Subject: [edk2-devel] [PATCH v11 35/46] OvmfPkg/PlatformPei: Reserve SEV-ES work area if S3 is supported Date: Tue, 21 Jul 2020 16:19:12 -0500 Message-ID: In-Reply-To: References: X-ClientProxiedBy: DM5PR18CA0084.namprd18.prod.outlook.com (2603:10b6:3:3::22) To CY4PR12MB1352.namprd12.prod.outlook.com (2603:10b6:903:3a::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from tlendack-t1.amd.com (165.204.77.1) by DM5PR18CA0084.namprd18.prod.outlook.com (2603:10b6:3:3::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.19 via Frontend Transport; Tue, 21 Jul 2020 21:24:30 +0000 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 0d949c5e-2d5a-40a1-93da-08d82dbc7503 X-MS-TrafficTypeDiagnostic: CY4PR12MB1143: 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: MntlnjeYPDjZ8uj9Zol63ZkH2RSIBuCjktBsP/6yiIfWnjd34HhW23eP2vFnqWzXG48pd2yO6u5fMt7pp6f+Ak62KMULoNACkovrcM1KHVIFCS91ASI1LV5iDPX9jRNv290vb820VXvxqkXxfio36TCTcWkIWmGiiolY0xGnpbMk9RJ60EC6Kw85YEkICqcqhiANC/mO7xM1A2jPlU7Z2OxNj1Y5QD335Cn2m86DN7YKG2hwrsm8PzfdvsUXR1D3xHbAa21VeYaePKNj6itRPmQ6GqKZH5XLeYYlep3Hoc9yE5koo7ZOIhttAOLXOnq9mMBDdyYpJ5zrXgt8aj8pTFOIEMTjVqRAP6DkC/7vqDcMHl/NFtQgLPbpA1vKspGGUzXBWr2ylwnR3zzH5j7sknqGMMK8KHc60uFaY3msThczdsUTR68F29pqJy7KDND5qSNF0eGuiXjtO9nJTL5dww== X-MS-Exchange-AntiSpam-MessageData: AbvpX0mEZCDMzVrU2F5zYxvVbltPW6EaBYqwNZhoWyPQQcU+qFONB5B9jyD/nZ0/ZQ2zCmMCVwgdg9ykkRVlO/tVhSPr0BStRklKxAbKSnPl20hR50ss1NI1QOGd3KTPAaGsqFAaOdSTkV4LMlhtagPpF/sZSgMO5BgxlEPEYLTox7AVhj6YTuJczSpXFF+hBTvod0C6T9Wutk5lQeALyqEOdlDypsdtexMCA33dDi9imH9HhmjxXg/wMiSySAFAAZmpZPmm3D7eHI840KBxMYYP+mr1a2/TpaNrf2CeMZzZiFdziIcvlpzCX5vpMRtEaYT9V6BV5dxX9B2s/8XkUNiA/KJlFOJtXVAsCLdKLdP6vqZOaNMMA3reUALHVI13YRQEn537KQ1AzhpQGvJgmEo8aiAItHcl5D7o3+Iv+TKPtFQ7E/crZXg9niRnfY00n91Kjzh0/7u1W8UHzKDd1BO1xZcWNzQZcyeADojtvss= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d949c5e-2d5a-40a1-93da-08d82dbc7503 X-MS-Exchange-CrossTenant-AuthSource: CY4PR12MB1352.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2020 21:24:31.5124 (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: d4KncCYig1gQlz6DwvdCWcXSqrJbFHFePLx+PW3Yh4IwAOd9FNEjDv58ldv7sfKjaFeB+j6iMCS3lehqBhdDpA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1143 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: v7CHZhb4M8bLtQAL5EDzcXySx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1595366675; bh=JOsGw2S4L9QAPhDyzMWOXPwuEzLI7xQOF2QOCn0RMoE=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=tuP7nGze1B39IbDnQRO2tpXGPR3BWXygxv6LBUJSl4bxBtRPLY5jrb3WxUFqr6NUzBx BlQb9K+v5zOyJl2ovZqiVKxyc7pKxV5hjwpJBKwOWrEq9+XUQUpMFCYA6wEZUw9OAog8j 6mIytQFnmJmoFdQsWRlpiV1RIQbimbc6qOA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Tom Lendacky 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 Reviewed-by: Laszlo Ersek Signed-off-by: Tom Lendacky --- 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.27.0 -=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 (#63026): https://edk2.groups.io/g/devel/message/63026 Mute This Topic: https://groups.io/mt/75713162/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-