From nobody Mon Sep 16 19:38:22 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+114630+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 1706307248923874.811448277984; Fri, 26 Jan 2024 14:14:08 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=v7wxiP+aj9rlyWSMOhkBimpbrkWd5FQToGajb7U6iKY=; 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=1706307248; v=1; b=wPQz/Qie17IRj9gg3qZhuG+hT/VzYkeo0B7zTip3u+yAkrZS7uAZSr8W/UaSKZBXuvayv/p1 ObCdu8mU2oORZzn5+LDMrTOI1lkzh5mYbGG3cifWJ9UjTcDkSiWWn4rN0E+THAo5R9Q22h8RB8S SJJgJp0iR8duZnTL5aMPKwo8= X-Received: by 127.0.0.2 with SMTP id KgLqYY1788612xwTaXBMauSo; Fri, 26 Jan 2024 14:14:08 -0800 X-Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.107.92.74]) by mx.groups.io with SMTP id smtpd.web11.2946.1706307247935322962 for ; Fri, 26 Jan 2024 14:14:08 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lgHyoy+WFWMJn45N1yflreoI8ElTbEw7Jrhpus+qNOtaAofrNjqN0jGM/QyQUFtSkGahowqpfNg6WqzUIod45yuhOuuzL/WFHgiG2E0N4FywS4nrp4NeaBsxuBoE+yNV/gxyaRIbz1PytLfzyaMApboDqaOl85wow3bLEbMFjnRrLmS9VhWQvZysJjQpKDVvTNJpDDjgVsPVX5lmdheqhAOghgNPgvdd97c+R4LEgcIImeieBu+KgtBI30UY8uFVrCBfEvU9kmg6jWUbNXgBrDo8DNFn+MKdY7kLZy80i2uvG28Rr0iOr55nm9B3LTBlzlJ4isz6RudHtXyp6kxG3w== 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=GbmIEjB0m2PtKHvftIjNjsuGOdnIrdtr5VZsgCY+f6k=; b=Whn7VvkJw26LEC220BJfl4cwI9VfnRoxUM0RdoK2DIsXZlV/1FNXJRJvcFBH7yprJvfHN82goWR4YEup04YXqmy3WQr08D5iWdB5dMhbBNQCjA2Q1LeLxxvvi4IvBy+QHc3qEYl1KmuEqwEE3uBSXla0mhDypIfk92kV0fa+Fr6xn79jKMocylCr1vMyF9F9gq5DPgYab4KbGcQLClXZS8/xDG1kQb2k6c//yv0YXdCJH0sXotG4remo/Ctns7rGlTFrofyLWmk8kFVP2ZG6ljJM++9vnINsWGwC7Z+Ttq8uJ9G5un2z7tokwRFyThbyeRfTCkrsEMKQYk1PVgJSkQ== 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 CY5PR04CA0016.namprd04.prod.outlook.com (2603:10b6:930:1e::13) by CH0PR12MB5386.namprd12.prod.outlook.com (2603:10b6:610:d5::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Fri, 26 Jan 2024 22:13:59 +0000 X-Received: from CY4PEPF0000E9D2.namprd03.prod.outlook.com (2603:10b6:930:1e:cafe::c8) by CY5PR04CA0016.outlook.office365.com (2603:10b6:930:1e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.27 via Frontend Transport; Fri, 26 Jan 2024 22:13:59 +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+114630+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 CY4PEPF0000E9D2.mail.protection.outlook.com (10.167.241.145) 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:13:59 +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:13:58 -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 04/16] UefiCpuPkg/CcExitLib: Extend the CcExitLib library to support an SVSM Date: Fri, 26 Jan 2024 16:13:03 -0600 Message-ID: <7061a9fb7a184fa0a2354842e834a260398aedc8.1706307195.git.thomas.lendacky@amd.com> 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: CY4PEPF0000E9D2:EE_|CH0PR12MB5386:EE_ X-MS-Office365-Filtering-Correlation-Id: a4133abd-3826-4319-53de-08dc1ebc18a4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: 3/IQnUm+wehrlcbjYEqLp6xEPS0qJEPsJAtoJdwPv/3Z4K3H0VsYFAUadtiF+DtFefU+s3daAZ3C5Xx1xGtFNVVSFwdAbvx/g8jXJTGB/pZO5qMXiVH7/BrFWbTyzGJ0ALnWMdp3thPkxHSzUf11243GkzIppqJ7oCNDpfNdw2OGI/B5TVL1Hm2Lgh8yO73lcGz3qV6hMhWI35AD5gP+i3C9AvG6+s4hlbCqHLiBRQNiG/NUTS6ugNkQSRoCCUDqxspzOIkqloaYjb4zoMURsFWtMnUB3MkX/igzmoIZm5fOzlo8qN4o4psYa90zYY3HZxLgv3QnJwUXUz1p+ybjWQFOGO56mcKqVuh1FnhNW5JGdFiZWYlTHbqyctBSD7WoCjIaSm39GpEOGzUUF/A2cPNPERJOqia+eJugThE4Bke2R6bembp97dlsoG8TUhaZynmvmPJSKPD2/otCeen8rEd08/R9LC+IRh2rbueLHJjCk64MfI0hlBCTG9dnYz2203eHl3YgsLSfHCPOn/93eA1Gfn3TpLlcUkVk0RDbFm0dp+5kn0coP5Oc7B60T2MlufKnCP/OlvmP+XXO0SMoQgaA9dTeK6/GmE6JLIOE7qEC8e+fW0sv2zhSWDnN2Jv5gPTqkhtmmrYaIETvNLA3Exr7aYLuZzn+LbqTMKySu9jcNze5UCGf3NQJVsLQwUby4aFk7l8OzHGO9RIrTdokCRMsQS1fsBMvKae2llT+OoQi7GOiE3uNwE4Xs9NwavpBmPaYqOap9TVcLKmhzNstlw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2024 22:13:59.4781 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a4133abd-3826-4319-53de-08dc1ebc18a4 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: CY4PEPF0000E9D2.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5386 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: twhmTSlD4Kap7xizCaawAxXAx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1706307249556100001 Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4654 In order to support an SEV-SNP guest running under an SVSM at VMPL1 or lower, the CcExitLib library must be extended with new intefaces. This includes an interface to detect if running under an SVSM, an interface to return the current VMPL, an interface to perform memory validation and an interface to set or clear the attribute that allows a page to be used as a VMSA. Signed-off-by: Tom Lendacky --- UefiCpuPkg/Include/Library/CcExitLib.h | 71 ++++++++++++++++- UefiCpuPkg/Library/CcExitLibNull/CcExitLibNull.c | 82 +++++++++++++++++++- 2 files changed, 151 insertions(+), 2 deletions(-) diff --git a/UefiCpuPkg/Include/Library/CcExitLib.h b/UefiCpuPkg/Include/Li= brary/CcExitLib.h index 3381d583691f..2a9de5d5e8e7 100644 --- a/UefiCpuPkg/Include/Library/CcExitLib.h +++ b/UefiCpuPkg/Include/Library/CcExitLib.h @@ -6,7 +6,7 @@ #VC exceptions. - Handle #VE exception in TDX. =20 - Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2020 - 2024, Advanced Micro Devices, Inc. All rights reser= ved.
Copyright (c) 2020 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -147,6 +147,75 @@ CcExitHandleVc ( IN OUT EFI_SYSTEM_CONTEXT SystemContext ); =20 +/** + 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 + ); + +/** + 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 + ); + +/** + 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 + ); + /** Handle a #VE exception. =20 diff --git a/UefiCpuPkg/Library/CcExitLibNull/CcExitLibNull.c b/UefiCpuPkg/= Library/CcExitLibNull/CcExitLibNull.c index 230e50705b4a..60b19c0433c7 100644 --- a/UefiCpuPkg/Library/CcExitLibNull/CcExitLibNull.c +++ b/UefiCpuPkg/Library/CcExitLibNull/CcExitLibNull.c @@ -1,7 +1,7 @@ /** @file CcExit Base Support Library. =20 - Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2020 - 2024, Advanced Micro Devices, Inc. All rights reser= ved.
Copyright (c) 2020 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -165,6 +165,86 @@ CcExitHandleVc ( return EFI_UNSUPPORTED; } =20 +/** + 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 + ) +{ + return FALSE; +} + +/** + 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 + ) +{ + return 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; +} + /** Handle a #VE exception. =20 --=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 (#114630): https://edk2.groups.io/g/devel/message/114630 Mute This Topic: https://groups.io/mt/103986445/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-