From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 76566740040 for ; Thu, 22 Feb 2024 17:32:27 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=nw2xlR8tOizDFcsfDC8+/28ma3mrurmpgIKwMV5yIYI=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1708623146; v=1; b=rimtm/Ne9kjtxuezscLsEQKrBjvCbC4TkOny+yWcZaGlrly/SuMM2i2d7W8DmF6arR8PZSMh B7COPRUjkNj5PPN5nng10KLDLjeoPg0AgtXywFvFxRNIIwRL8NsUHbL8OwP9fnp9sWcbDXxkiL0 kZsIYerOj+Q9+iWXAfvGiY8c= X-Received: by 127.0.0.2 with SMTP id Ng6LYY7687511x0INuOj7X8q; Thu, 22 Feb 2024 09:32:26 -0800 X-Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.107.92.64]) by mx.groups.io with SMTP id smtpd.web10.19145.1708623145377025110 for ; Thu, 22 Feb 2024 09:32:25 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ytz7um914lw7EPZnNU56eX1N0DR16OlukKniRJMMzyqdrCnLWkXSdPKZ1SoC+ynrr6THwqyezb7PuT0y7+Qlfv6wrg0HJ/oWiA62fGwtT4jRhEZwh8L/PGFTT40dZe+mY321bMeLKETLQbEIdiB9GAavAGTqA2lG64iRImxo3V8MtDVNawDoMktE079fQ6fefQBo5rwGbqa20Rs8UEtkka/MgjwrO/5RNOTwxCWsXbIFjrmKtkzH2H7hvtKkx7r7PxFL3JM4iYi+FCwncZR42EbEvO2ceZqcvFZNYMV6W+ITK8reyCI8iKR6YdWRrhzHTGkDhCG4Cdw6BjTZmafLfw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BrhwoI2EyWfZdU88JyWDvE9QV5rtnBVfZLRTY7lWF/E=; b=CVX5exr8WY5mJ9K4bg0dKnDIUAHZNNRjvAZBcHnQ2ha/+Wm8mGERQy/uUF8QPn1paX8u91hTkqdr9vV0uAe1UcczatT7stoYOs4EDyI1J+Sozvnjo2bzN7LeKDsX4haCoNlCo0HMqCRs/09Zcv/ps2ZZrA4Nv/0UC35z06VFhvGTlLmh6pL6JWGgT6YPVepZt0dxY8FXXFlhfUkWz425vYOOIQlig+HYCMQyzXCcT4QX1VS8Q2ecWuCw25IXhqtxRS+8wDSlshMQ/txPw5iMBI3AILaEyxsMLIYzooTrN+Zmpl9ATv2vVLCPAEeejRhCb3UJ0ywrevSKRjiBBp4Ocg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) X-Received: from BN9PR03CA0044.namprd03.prod.outlook.com (2603:10b6:408:fb::19) by PH0PR12MB7864.namprd12.prod.outlook.com (2603:10b6:510:26c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.24; Thu, 22 Feb 2024 17:32:14 +0000 X-Received: from BN2PEPF000044AC.namprd04.prod.outlook.com (2603:10b6:408:fb:cafe::cf) by BN9PR03CA0044.outlook.office365.com (2603:10b6:408:fb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.43 via Frontend Transport; Thu, 22 Feb 2024 17:32:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C X-Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF000044AC.mail.protection.outlook.com (10.167.243.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7292.25 via Frontend Transport; Thu, 22 Feb 2024 17:32:14 +0000 X-Received: from tlendack-t1.amdoffice.net (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 22 Feb 2024 11:32:13 -0600 From: "Lendacky, Thomas via groups.io" To: CC: Ard Biesheuvel , Erdem Aktas , Gerd Hoffmann , Jiewen Yao , Laszlo Ersek , Liming Gao , Michael D Kinney , Min Xu , Zhiguang Liu , "Rahul Kumar" , Ray Ni , Michael Roth Subject: [edk2-devel] [PATCH v2 17/23] OvmfPkg: Create a calling area used to communicate with the SVSM Date: Thu, 22 Feb 2024 11:29:56 -0600 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044AC:EE_|PH0PR12MB7864:EE_ X-MS-Office365-Filtering-Correlation-Id: f77fcaeb-8a93-440a-1c79-08dc33cc3562 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: Eg/k2P8kH9irY377fW7jFPiRBavX6dICvwJxHVqVx95yNIGGRsLK/NnUCB0/pxkB+9Nm9tjb7eTrlnbHY3oS/Mcs35g07oe/FAPeFZleQw4nWlF9xmTCmnrwvyTUJh/sXIptsTn5WKokq9DIL4f4n0S8V6z+862Jvb/I7uUIhYwvmM1B8xOwceoKejV4CmJx+ZkWWcds0afAXqk71ixwhDZY7eY3+DeOdIuqDy53apUgcKB+AEjWEFTbt+JtF9g7q6kmXSe8sBqCE7J2RzRUMF84qaJi+KSZ2eGWCqtd+4nRPctTzzOYl5w5C2hGgK95DgzNLl3YjiedifQy0RtBa02l0/9OTDpMtpTS7zGsUCPyE2fq4HpYdcV1BS97zblLzmDyYy3Za8OReRx+ocZvOf2XpcWRmDeJP6oOG2qiEXQBrcUBRLTegDTDepVQzSpAerTPIgZ3TioFii7bylMhym6huATf6set9KUn8kLKYfd+1Y5Z9e1qAgYB+Vze0mxY7UbrtIfGiKxvia30qStYwCdnbOcz4ZjaWRriE4H5UfIiqciF8ePkc7q7mOgKDq9NJBLf8r/UMEh9go8PMwg6GpUDpgQ88xP+CmqZL9+68vTw92uAcLW9QiS7LDE5ewL5ao0niD8dUPgUPoOuH/cr6Q== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2024 17:32:14.0641 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f77fcaeb-8a93-440a-1c79-08dc33cc3562 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000044AC.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7864 Precedence: Bulk List-Subscribe: List-Help: 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 List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: PLmBjYp9sdDQfV1ETB0cNiLix7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b="rimtm/Ne"; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4654 An SVSM requires a calling area page whose address (CAA) is used by the SVSM to communicate and process the SVSM request. Add a pre-defined page area to the OvmfPkg and AmdSev packages and define corresponding PCDs used to communicate the location and size of the area. Keep the AmdSev package in sync with the OvmfPkg and adjust the AmdSev launch and hash area memory locations. Signed-off-by: Tom Lendacky --- OvmfPkg/OvmfPkg.dec | 4 ++++ OvmfPkg/AmdSev/AmdSevX64.fdf | 9 ++++++--- OvmfPkg/OvmfPkgX64.fdf | 3 +++ OvmfPkg/PlatformPei/PlatformPei.inf | 2 ++ OvmfPkg/ResetVector/ResetVector.inf | 2 ++ OvmfPkg/PlatformPei/AmdSev.c | 11 +++++++++++ OvmfPkg/ResetVector/ResetVector.nasmb | 6 ++++-- OvmfPkg/ResetVector/X64/OvmfSevMetadata.asm | 11 ++++++++++- 8 files changed, 42 insertions(+), 6 deletions(-) diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index fbc81e4c8070..2f7bded9260b 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -338,6 +338,10 @@ [PcdsFixedAtBuild] ## Restrict boot to EFI applications in firmware volumes. gUefiOvmfPkgTokenSpaceGuid.PcdBootRestrictToFirmware|FALSE|BOOLEAN|0x6c =20 + ## The base address and size of the initial SVSM Calling Area. + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecSvsmCaaBase|0|UINT32|0x70 + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecSvsmCaaSize|0|UINT32|0x71 + [PcdsDynamic, PcdsDynamicEx] gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable|FALSE|BOOLEAN|0x1= 0 diff --git a/OvmfPkg/AmdSev/AmdSevX64.fdf b/OvmfPkg/AmdSev/AmdSevX64.fdf index 9dd409596780..dafa5ebacbaf 100644 --- a/OvmfPkg/AmdSev/AmdSevX64.fdf +++ b/OvmfPkg/AmdSev/AmdSevX64.fdf @@ -68,13 +68,16 @@ [FD.MEMFD] 0x00E000|0x001000 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfCpuidBase|gUefiOvmfPkgTokenSpaceGuid.Pcd= OvmfCpuidSize =20 -0x00F000|0x000C00 +0x00F000|0x001000 +gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecSvsmCaaBase|gUefiOvmfPkgTokenSpaceGui= d.PcdOvmfSecSvsmCaaSize + +0x010000|0x000C00 gUefiOvmfPkgTokenSpaceGuid.PcdSevLaunchSecretBase|gUefiOvmfPkgTokenSpaceGu= id.PcdSevLaunchSecretSize =20 -0x00FC00|0x000400 +0x010C00|0x000400 gUefiOvmfPkgTokenSpaceGuid.PcdQemuHashTableBase|gUefiOvmfPkgTokenSpaceGuid= .PcdQemuHashTableSize =20 -0x010000|0x010000 +0x011000|0x00F000 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpace= Guid.PcdOvmfSecPeiTempRamSize =20 0x020000|0x0E0000 diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf index f47ab1727e4c..f12844f674e7 100644 --- a/OvmfPkg/OvmfPkgX64.fdf +++ b/OvmfPkg/OvmfPkgX64.fdf @@ -94,6 +94,9 @@ [FD.MEMFD] 0x00E000|0x001000 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfCpuidBase|gUefiOvmfPkgTokenSpaceGuid.Pcd= OvmfCpuidSize =20 +0x00F000|0x001000 +gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecSvsmCaaBase|gUefiOvmfPkgTokenSpaceGui= d.PcdOvmfSecSvsmCaaSize + 0x010000|0x010000 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpace= Guid.PcdOvmfSecPeiTempRamSize =20 diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/Plat= formPei.inf index 7de3b4341c2c..126085db0204 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf @@ -128,6 +128,8 @@ [FixedPcd] gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecGhcbBackupBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecGhcbBackupSize + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecSvsmCaaBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecSvsmCaaSize gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaSize gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsBase diff --git a/OvmfPkg/ResetVector/ResetVector.inf b/OvmfPkg/ResetVector/Rese= tVector.inf index a4154ca90c28..0f5f8fec0b77 100644 --- a/OvmfPkg/ResetVector/ResetVector.inf +++ b/OvmfPkg/ResetVector/ResetVector.inf @@ -62,5 +62,7 @@ [FixedPcd] gUefiOvmfPkgTokenSpaceGuid.PcdSevLaunchSecretSize gUefiOvmfPkgTokenSpaceGuid.PcdQemuHashTableBase gUefiOvmfPkgTokenSpaceGuid.PcdQemuHashTableSize + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecSvsmCaaBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecSvsmCaaSize gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsSize diff --git a/OvmfPkg/PlatformPei/AmdSev.c b/OvmfPkg/PlatformPei/AmdSev.c index 472cf13f0faa..66f480ee1c5d 100644 --- a/OvmfPkg/PlatformPei/AmdSev.c +++ b/OvmfPkg/PlatformPei/AmdSev.c @@ -554,5 +554,16 @@ SevInitializeRam ( (UINT64)(UINTN)PcdGet32 (PcdOvmfCpuidSize), EfiReservedMemoryType ); + + // + // The calling area memory needs to be protected until the OS can crea= te + // its own calling area. Mark it as EfiReservedMemoryType so that the + // guest firmware and OS do not use it as a system memory. + // + BuildMemoryAllocationHob ( + (EFI_PHYSICAL_ADDRESS)(UINTN)PcdGet32 (PcdOvmfSecSvsmCaaBase), + (UINT64)(UINTN)PcdGet32 (PcdOvmfSecSvsmCaaSize), + EfiReservedMemoryType + ); } } diff --git a/OvmfPkg/ResetVector/ResetVector.nasmb b/OvmfPkg/ResetVector/Re= setVector.nasmb index 366a70fb9992..22bd34721a8b 100644 --- a/OvmfPkg/ResetVector/ResetVector.nasmb +++ b/OvmfPkg/ResetVector/ResetVector.nasmb @@ -3,7 +3,7 @@ ; This file includes all other code files to assemble the reset vector cod= e ; ; Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.
-; Copyright (c) 2020, Advanced Micro Devices, Inc. All rights reserved. +; Copyright (c) 2020 - 2024, Advanced Micro Devices, Inc. All rights reser= ved.
; SPDX-License-Identifier: BSD-2-Clause-Patent ; ;-------------------------------------------------------------------------= ----- @@ -68,6 +68,8 @@ %define SEV_SNP_SECRETS_SIZE (FixedPcdGet32 (PcdOvmfSnpSecretsSiz= e)) %define CPUID_BASE (FixedPcdGet32 (PcdOvmfCpuidBase)) %define CPUID_SIZE (FixedPcdGet32 (PcdOvmfCpuidSize)) +%define SVSM_CAA_BASE (FixedPcdGet32 (PcdOvmfSecSvsmCaaBas= e)) +%define SVSM_CAA_SIZE (FixedPcdGet32 (PcdOvmfSecSvsmCaaSiz= e)) %if (FixedPcdGet32 (PcdSevLaunchSecretBase) > 0) ; There's a reserved page for SEV secrets and hashes; the VMM will fill = and ; validate the page, or mark it as a zero page. @@ -88,7 +90,7 @@ ; %define SNP_SEC_MEM_BASE_DESC_2 (GHCB_BASE + 0x1000) %define SNP_SEC_MEM_SIZE_DESC_2 (SEV_SNP_SECRETS_BASE - SNP_SEC_MEM_= BASE_DESC_2) -%define SNP_SEC_MEM_BASE_DESC_3 (CPUID_BASE + CPUID_SIZE + SEV_SNP_K= ERNEL_HASHES_SIZE) +%define SNP_SEC_MEM_BASE_DESC_3 (SVSM_CAA_BASE + SVSM_CAA_SIZE + SEV= _SNP_KERNEL_HASHES_SIZE) %define SNP_SEC_MEM_SIZE_DESC_3 (FixedPcdGet32 (PcdOvmfPeiMemFvBase)= - SNP_SEC_MEM_BASE_DESC_3) =20 %ifdef ARCH_X64 diff --git a/OvmfPkg/ResetVector/X64/OvmfSevMetadata.asm b/OvmfPkg/ResetVec= tor/X64/OvmfSevMetadata.asm index 8aa77d870123..2511073a466f 100644 --- a/OvmfPkg/ResetVector/X64/OvmfSevMetadata.asm +++ b/OvmfPkg/ResetVector/X64/OvmfSevMetadata.asm @@ -2,7 +2,7 @@ ; @file ; OVMF metadata for the AMD SEV confidential computing guests ; -; Copyright (c) 2021, AMD Inc. All rights reserved.
+; Copyright (c) 2021 - 2024, AMD Inc. All rights reserved.
; ; SPDX-License-Identifier: BSD-2-Clause-Patent ;-------------------------------------------------------------------------= ---- @@ -26,6 +26,9 @@ BITS 64 ; %define OVMF_SECTION_TYPE_CPUID 0x3 =20 +; The SVSM Calling Area Address (CAA) +%define OVMF_SECTION_TYPE_SVSM_CAA 0x4 + ; Kernel hashes section for measured direct boot %define OVMF_SECTION_TYPE_KERNEL_HASHES 0x10 =20 @@ -67,6 +70,12 @@ CpuidSec: DD CPUID_SIZE DD OVMF_SECTION_TYPE_CPUID =20 +; SVSM CAA page +SvsmCaa: + DD SVSM_CAA_BASE + DD SVSM_CAA_SIZE + DD OVMF_SECTION_TYPE_SVSM_CAA + %if (SEV_SNP_KERNEL_HASHES_BASE > 0) ; Kernel hashes for measured direct boot, or zero page if ; there are no kernel hashes / SEV secrets --=20 2.42.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 (#115852): https://edk2.groups.io/g/devel/message/115852 Mute This Topic: https://groups.io/mt/104512971/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-