From nobody Mon Sep 16 19:28:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+114631+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1706307251226557.8642606972577; Fri, 26 Jan 2024 14:14:11 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=1N4ampMuwFV5oQyZ1AQKgRWENsfsyFX1mkgpQZpBIQI=; 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=1706307250; v=1; b=eGCU+pbVSN0aGDvojFpI/+e/Iq8ywhzA5+OzxgSMTVeC/6xAYcRu5XYEZ9y4lJKLYy/yruQ+ 3sidbtD7tAEy/S1D6B/nPjmZxm5Bfh35iZ9Eqw8ayicidr8vAc6rFsDu8A/2uc+EfK7DGGF5+fw JQsgqs25X8NI1inq9d8j+X3w= X-Received: by 127.0.0.2 with SMTP id 37Y0YY1788612xCZjbLbeoRV; Fri, 26 Jan 2024 14:14:10 -0800 X-Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.107.93.73]) by mx.groups.io with SMTP id smtpd.web10.2866.1706307250168752703 for ; Fri, 26 Jan 2024 14:14:10 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fuPU51tqtPdYOah9zobYXikP1UyCb6B9PT19bu86flIa2vtjZDwBGGdm18WN1ljPB/tQDwsb5JCOnLkcjv3Jj67LhbUS7ytvkwH8ITQISOHEQ1EIvSA40mkCrzqgoqM0f1APYPYia1LJ5tM9vw4zDfG3Ul+i4BLVW0zu7/8DvHwj11H8GW5JC1nRySZ0YRlPsVikiaMWlP78z4l5lfTAyPE/ckGpy89mftPBQg8eee0NuXkA4N2gKrR+hrDpX25YoLVNDZjjCntDRbuP3CAy63iD4XV70pa1FHmKoMBfNwH6TYRihOZO41/t58fDP2kQNXa59vqX/j3dgBMNp/0Nbw== 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=COLwbD/6jo+4NAeq+AFqmO3ShREq52neo5i21JLhtlY=; b=eja9Sysp8qk9L11SCi/w4XMr6U2JGBgTdFbiumMUjcYaPpMN5YQf+ukiTWp6ivNHOPUN9nelVcj1OqfAJS1BnhetAYZbdJgJtJt7MfJwFBU4qBxlCIQarqjYYvCbhFIaGW4mlZATXP+CpaimdfR6332djqir1VWH5OLKbTc4Kg7bRu8FnKwHE0//V7wZAEwNDQisg+ayDb8T14h0L9MN8tN3Vh1jub0wpy31hQNxG7dxkQR7zVGcXC8xQJ3l+xDBAYOAAGn7qPsx/elCBm25CxQsU/NDTC+rYPQMb3d5RX9qLJP+B8/Q0tYK/k1LNPXLE6ElKO+O2Hr6RCAqbgS1OA== 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 DM6PR02CA0092.namprd02.prod.outlook.com (2603:10b6:5:1f4::33) by BY5PR12MB4147.namprd12.prod.outlook.com (2603:10b6:a03:205::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.27; Fri, 26 Jan 2024 22:14:07 +0000 X-Received: from DS2PEPF0000343A.namprd02.prod.outlook.com (2603:10b6:5:1f4:cafe::76) by DM6PR02CA0092.outlook.office365.com (2603:10b6:5:1f4::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.26 via Frontend Transport; Fri, 26 Jan 2024 22:14:07 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+114631+1787277+3901457@groups.io; helo=mail02.groups.io; 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 DS2PEPF0000343A.mail.protection.outlook.com (10.167.18.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7228.16 via Frontend Transport; Fri, 26 Jan 2024 22:14:07 +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.34; Fri, 26 Jan 2024 16:14:05 -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 05/16] Ovmfpkg/CcExitLib: Extend CcExitLib to handle SVSM related services Date: Fri, 26 Jan 2024 16:13:04 -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: DS2PEPF0000343A:EE_|BY5PR12MB4147:EE_ X-MS-Office365-Filtering-Correlation-Id: 5dfd3a95-d2cf-4888-2d9e-08dc1ebc1d42 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: G8wYyMaGV9H9P9RxdhoLj4/0MKnqm9TMyChv+7WWxxvcC2uBbHTvWw2GemSQ6OaUO6UaL9R65mtQhwOkT+p61WfxdufzlOA+08nSfMob0denqk1M4Y9VJ/3B3XAvYIua3G2bV+y74i4nd4jbmW7423awY/pr54RA1wnxrcIeWrAVKoFj4r5lZhgRlBUWXS5S02TaNHDVbzXAETkwZRUtbl4YWxkHSW+G0plRMsYAe1XOgg7vl91ilf+oK5fv2s0B8j6q+69CKD4BYANm2rNgeHQHr4R0Uvz6CuENMI9/gTCwRG9u5oc66K60MazD1ApweKH975OS+2XFSQaAjI4AZ64gEd4ybUKOIFF4wxa7+SViEsZ20Bgg7TX1KVuqqlO0auCyk7p5+Apswx0x6nRDNvhmekK8tt5yLuON7bbCFXKEngcAiU09RGUN7opegw4lAvDUK8eDRbKFTC0DS9f40WKfg52uIQ5mLfeBmAbnzgFKkgiFoeP8Kk1KAA9+UQ9wYvAxXAeJCIEsl5U4+oUX9PIl0DU0enASDw2MXzmXBeUzrb0I9s+euzCx+mnvI1nPLoZ2jbSyEERI+2dhdAduwwduYZSaZpEqi4onxxq4tqVkPt4dh0222901TGyoll7umIPBELwzqwi8/vlmju0C7jZOzzKUikMHyKKCo7MCR5iqDQuYs9KLieSKv9emdVUpX8py2y6woSvSVp3kYim6JweHAUHDbmrzMd6xZqsed4cobXD6CYbBCpyn9g9dzvJR X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2024 22:14:07.1766 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5dfd3a95-d2cf-4888-2d9e-08dc1ebc1d42 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: DS2PEPF0000343A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4147 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: apitc10nlp7gh5YM8VnhKQdKx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1706307251548100005 Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4654 Add initial support for the new CcExitLib interfaces to the OvmfPkg version of the library. The initial implementation will fully implement the SVSM presence check API and the SVSM VMPL API, with later patches fully implementing the other interfaces. The SVSM presence check, CcExitSnpSvsmPresent(), determines the presence of an SVSM by checking if an SVSM has been advertised in the SEV-SNP Secrets Page. The SVSM VMPL API, CcExitSnpGetVmpl(), returns the VMPL level at which the OVMF is currently running. Signed-off-by: Tom Lendacky --- OvmfPkg/Library/CcExitLib/CcExitLib.inf | 5 +- OvmfPkg/Library/CcExitLib/SecCcExitLib.inf | 5 +- OvmfPkg/Library/CcExitLib/CcExitSvsm.c | 102 ++++++++++++++++++++ 3 files changed, 110 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/Library/CcExitLib/CcExitLib.inf b/OvmfPkg/Library/CcEx= itLib/CcExitLib.inf index bc75cd5f5a04..2e68b12bb4e2 100644 --- a/OvmfPkg/Library/CcExitLib/CcExitLib.inf +++ b/OvmfPkg/Library/CcExitLib/CcExitLib.inf @@ -1,7 +1,7 @@ ## @file # CcExitLib Library. # -# Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved. +# Copyright (C) 2020 - 2024, Advanced Micro Devices, Inc. All rights rese= rved.
# Copyright (C) 2020 - 2022, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -23,6 +23,7 @@ [Defines] =20 [Sources.common] CcExitLib.c + CcExitSvsm.c CcExitVcHandler.c CcExitVcHandler.h CcInstruction.c @@ -45,3 +46,5 @@ [LibraryClasses] [Pcd] gUefiOvmfPkgTokenSpaceGuid.PcdOvmfCpuidBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfCpuidSize + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsSize diff --git a/OvmfPkg/Library/CcExitLib/SecCcExitLib.inf b/OvmfPkg/Library/C= cExitLib/SecCcExitLib.inf index 811269dd2c06..7b81900a11d4 100644 --- a/OvmfPkg/Library/CcExitLib/SecCcExitLib.inf +++ b/OvmfPkg/Library/CcExitLib/SecCcExitLib.inf @@ -1,7 +1,7 @@ ## @file # VMGEXIT Support Library. # -# Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved. +# Copyright (C) 2020 - 2024, Advanced Micro Devices, Inc. All rights rese= rved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -22,6 +22,7 @@ [Defines] =20 [Sources.common] CcExitLib.c + CcExitSvsm.c CcExitVcHandler.c CcExitVcHandler.h CcInstruction.c @@ -45,5 +46,7 @@ [LibraryClasses] [FixedPcd] gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecGhcbBackupBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecGhcbBackupSize + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsSize gUefiOvmfPkgTokenSpaceGuid.PcdOvmfCpuidBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfCpuidSize diff --git a/OvmfPkg/Library/CcExitLib/CcExitSvsm.c b/OvmfPkg/Library/CcExi= tLib/CcExitSvsm.c new file mode 100644 index 000000000000..fb8b762caadc --- /dev/null +++ b/OvmfPkg/Library/CcExitLib/CcExitSvsm.c @@ -0,0 +1,102 @@ +/** @file + SVSM Support Library. + + Copyright (C) 2024, Advanced Micro Devices, Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include + +/** + Report the presence of an Secure Virtual Services Module (SVSM). + + Determines the presence of an SVSM. + + @retval TRUE An SVSM is present + @retval FALSE An SVSM is not present + +**/ +BOOLEAN +EFIAPI +CcExitSnpSvsmPresent ( + VOID + ) +{ + SVSM_INFORMATION *SvsmInfo; + + SvsmInfo =3D (SVSM_INFORMATION *)(UINTN)PcdGet32 (PcdOvmfSnpSecretsBase); + + return (SvsmInfo !=3D NULL && SvsmInfo->SvsmSize !=3D 0); +} + +/** + Report the VMPL level at which the SEV-SNP guest is running. + + Determines the VMPL level at which the guest is running. If an SVSM is + not present, then it must be VMPL0, otherwise return what is reported + by the SVSM. + + @return The VMPL level + +**/ +UINT8 +EFIAPI +CcExitSnpGetVmpl ( + VOID + ) +{ + SVSM_INFORMATION *SvsmInfo; + + SvsmInfo =3D (SVSM_INFORMATION *)(UINTN)PcdGet32 (PcdOvmfSnpSecretsBase); + + return CcExitSnpSvsmPresent () ? SvsmInfo->SvsmGuestVmpl : 0; +} + +/** + Perform a PVALIDATE operation for the page ranges specified. + + Validate or rescind the validation of the specified pages. + + @param[in] Info Pointer to a page state change structure + +**/ +VOID +EFIAPI +CcExitSnpPvalidate ( + IN SNP_PAGE_STATE_CHANGE_INFO *Info + ) +{ +} + +/** + Perform an RMPADJUST operation to alter the VMSA setting of a page. + + Add or remove the VMSA attribute for a page. + + @param[in] Vmsa Pointer to an SEV-ES save area page + @param[in] ApicId APIC ID associated with the VMSA + @param[in] SetVmsa Boolean indicator as to whether to set or + or clear the VMSA setting for the page + + @retval EFI_SUCCESS RMPADJUST operation successful + @retval EFI_UNSUPPORTED Operation is not supported + @retval EFI_INVALID_PARAMETER RMPADJUST operation failed, an invalid + parameter was supplied + +**/ +EFI_STATUS +EFIAPI +CcExitSnpVmsaRmpAdjust ( + IN SEV_ES_SAVE_AREA *Vmsa, + IN UINT32 ApicId, + IN BOOLEAN SetVmsa + ) +{ + return EFI_UNSUPPORTED; +} --=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 (#114631): https://edk2.groups.io/g/devel/message/114631 Mute This Topic: https://groups.io/mt/103986446/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-