From nobody Tue Feb 10 13:16:25 2026 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+83725+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=pass(p=none dis=none) header.from=groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1636738844067410.4306613531239; Fri, 12 Nov 2021 09:40:44 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id W1eeYY1788612x0nmKXxTckN; Fri, 12 Nov 2021 09:40:43 -0800 X-Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.49]) by mx.groups.io with SMTP id smtpd.web08.396.1636738841734854093 for ; Fri, 12 Nov 2021 09:40:41 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bQYvUp8PYYx66CUnj2lAaBw+t1MeLgXVqcsfKHaPRG817DytGnFWbilH9nDALAIH8F9MUQ794Evhv5Se9t5u3MxFIZFh0v5dZYbFZwnhmOKK74YpExS69DewCis5bdqJvj8bXGHtp3+q0ZSV+zgpQ8ZLmLfnYb2lvXgSNQ5hl94RCG+lkyaOvGY4CLSiw4aMxx6nWdH+2O70SRtLXDjWxF7XuP3ssgPDKzy9qN2yl+kxvGFg8cCNxoo0RQ/zEGiGlCPvF/9HeBDs2oYrfTs89VZOHo1TwwgCWUDlyP2uOpQwvRmiEFqEYuOACtQLBgKGaalGKy4HbtD1dnHNJntiEg== 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=EGKMOfstyLIrpsJe/EKx5CLbterS1FlHUOciwvJTk0M=; b=ghng5ljvoc35waumFSN9S54/PQCqhdmcYgJN8iCZzij5bXWmOP6HI4h32B8xD6sAtqJPSRNmVbZIv+QhXedzMMGspLpsXf65wxJNrUmN0yNnX5Ox4GT/rls90YZnrPCgBdw1Q2YjhlvXmS/rxizTHvrY/FQT/l7BgHp8PydRL//FNxtHGsEn+MbXx7VJfnpN7BqaGwzK8GQEXErazL/2i+no0aWkF3g8acmn5Ho/YxB/ixTimLF5AbZBQ6z4tzxxWLKq9szMspaSADbLYCG1Vqp4t7LoA5wC4rZShutK4Nd2FDwXh9d4k+vCmPFQJZNLf94MjrbE46VO5tXWsqSlRg== 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 X-Received: from BN6PR19CA0075.namprd19.prod.outlook.com (2603:10b6:404:133::13) by BYAPR12MB3286.namprd12.prod.outlook.com (2603:10b6:a03:139::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.15; Fri, 12 Nov 2021 17:40:38 +0000 X-Received: from BN8NAM11FT052.eop-nam11.prod.protection.outlook.com (2603:10b6:404:133:cafe::72) by BN6PR19CA0075.outlook.office365.com (2603:10b6:404:133::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.25 via Frontend Transport; Fri, 12 Nov 2021 17:40:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; 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+83725+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; X-Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT052.mail.protection.outlook.com (10.13.177.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4690.15 via Frontend Transport; Fri, 12 Nov 2021 17:40:38 +0000 X-Received: from sbrijesh-desktop.amd.com (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.2375.17; Fri, 12 Nov 2021 11:40:35 -0600 From: "Brijesh Singh via groups.io" To: CC: James Bottomley , Min Xu , "Jiewen Yao" , Tom Lendacky , "Jordan Justen" , Ard Biesheuvel , Erdem Aktas , "Michael Roth" , Gerd Hoffmann , "Michael D Kinney" , Liming Gao , Zhiguang Liu , Ray Ni , Rahul Kumar , Eric Dong , Brijesh Singh , Michael Roth , Jiewen Yao Subject: [edk2-devel] [PATCH v13 24/32] OvmfPkg/PlatformPei: set the Hypervisor Features PCD Date: Fri, 12 Nov 2021 11:39:51 -0600 Message-ID: <20211112173959.2505972-25-brijesh.singh@amd.com> In-Reply-To: <20211112173959.2505972-1-brijesh.singh@amd.com> References: <20211112173959.2505972-1-brijesh.singh@amd.com> 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-Office365-Filtering-Correlation-Id: c3b5edce-0064-4023-7366-08d9a6038a5e X-MS-TrafficTypeDiagnostic: BYAPR12MB3286: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: xxvxDtAV9V/otXDFP+Ee6+j1IcYVtYe7IOwbu6BpaXmX6axHTbo/gLbPxo23m1Dme7Yswi1xOj2h0Ej/qq3BRTOh9MtoN61CUzKYZeOtvjTAL2vz1TTADWDn9o6j4tLLsCL10YKJAD5pM+H2Ma8Poz8zkzc39XXq0c6UNmSK21+C7OiPqN5Oycp72jjLrLsbouaROmNXY22CoUzo1DaVrVy825pYiPUUkazDCtBrZd4XwWkZh8gtbvrUBE9N4XOLFXHw3kFFrV510nupy3a8cbr1yTXNt24ddj5J+wFYCK6uuitKsrjvlh6+SNNxustS27tlNBoxDVJAjQA237puayXgqgXS8JeivapnTz57a9Bd5BxkiC2Fb36et5gkVlV+3lTS2FEpPQ7JjZr6gm4TH36KhX3J9CJvQ9wXl6yhPP4KPb8ZkruefHidM2M5Mm3xtnjhEDIdTDSRQftNAEYLqpxNnuZ+AmoPfTPBpMYxi2u7zLUAuM1amiWmykkoi5YRECrmWHjCUcykESFQNBI/ihG1zZ6frvN1CEgy70PSwbFvb9Dj26kpp25Wt5qXMe8JhfAz2pqN68JUcbS5odDqtOQJ4toZmNoRteJJxEC1L7fxLoDmRwJy0Exxws+u1B4TXJyzv+207NaTYW0GL8KvbkYn7v0k9kohqo5m7ue7gzxpbNPsWX5cbsiky+NZYCqKinL9ma4f3Yde62npt6rsNpfGF43SO+o574xjkyzmabsSsm2Km+A1ApryVkbLclnNib95PTgmZKfMnqjUSk3CVu++MjEdLiyfUx2ZHxiNdHoh2uEvK3RVIAA2DAzUvjbb X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2021 17:40:38.5764 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c3b5edce-0064-4023-7366-08d9a6038a5e 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: BN8NAM11FT052.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3286 Precedence: Bulk List-Unsubscribe: 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,brijesh.singh@amd.com X-Gm-Message-State: YpvotW4Fh2vukOMCkBk0CSEix1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1636738843; bh=bTQHaCxr9j2FzjAy+dPfGSQpl5kJ+nwRbPslGIF+NWE=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=i5Lug1GCM0sxnP8ZBswhweMzu0aERJgwPyfV2n5QbjJcLPcxMcmVYx+R5VBNYB2ao1+ GEr1Z/GNKrgMaXcaWY9hNQ+DFxSdCSD81IR0yXNjQGtLjtDc26DzcgGjwa6L9QXMPAqhg rY5CNLuJ5yt/lM08Xofy38OKkMhT284R9pI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1636738846249100015 Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3275 Version 2 of the GHCB specification added the support to query the hypervisor feature bitmap. The feature bitmap provide information such as whether to use the AP create VmgExit or use the AP jump table approach to create the APs. The MpInitLib will use the PcdGhcbHypervisorFeatures to determine which method to use for creating the AP. Query the hypervisor feature and set the PCD accordingly. Cc: Michael Roth Cc: James Bottomley Cc: Min Xu Cc: Jiewen Yao Cc: Tom Lendacky Cc: Jordan Justen Cc: Ard Biesheuvel Cc: Erdem Aktas Cc: Gerd Hoffmann Acked-by: Jiewen Yao Acked-by: Gerd Hoffmann Signed-off-by: Brijesh Singh --- OvmfPkg/PlatformPei/PlatformPei.inf | 2 ++ OvmfPkg/PlatformPei/AmdSev.c | 56 +++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/Plat= formPei.inf index bada5ea14439..3c05b550e4bd 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf @@ -62,6 +62,7 @@ [LibraryClasses] MtrrLib MemEncryptSevLib PcdLib + VmgExitLib =20 [Pcd] gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase @@ -107,6 +108,7 @@ [Pcd] gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize gUefiCpuPkgTokenSpaceGuid.PcdSevEsIsEnabled gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr + gUefiCpuPkgTokenSpaceGuid.PcdGhcbHypervisorFeatures =20 [FixedPcd] gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress diff --git a/OvmfPkg/PlatformPei/AmdSev.c b/OvmfPkg/PlatformPei/AmdSev.c index c447753075b1..7da6370113f0 100644 --- a/OvmfPkg/PlatformPei/AmdSev.c +++ b/OvmfPkg/PlatformPei/AmdSev.c @@ -24,6 +24,12 @@ =20 #include "Platform.h" =20 +STATIC +UINT64 +GetHypervisorFeature ( + VOID + ); + /** Initialize SEV-SNP support if running as an SEV-SNP guest. =20 @@ -36,11 +42,22 @@ AmdSevSnpInitialize ( { EFI_PEI_HOB_POINTERS Hob; EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob; + UINT64 HvFeatures; + EFI_STATUS PcdStatus; =20 if (!MemEncryptSevSnpIsEnabled ()) { return; } =20 + // + // Query the hypervisor feature using the VmgExit and set the value in t= he + // hypervisor features PCD. + // + HvFeatures =3D GetHypervisorFeature (); + PcdStatus =3D PcdSet64S (PcdGhcbHypervisorFeatures, HvFeatures); + ASSERT_RETURN_ERROR (PcdStatus); + + // // Iterate through the system RAM and validate it. // @@ -91,6 +108,45 @@ SevEsProtocolFailure ( CpuDeadLoop (); } =20 +/** + Get the hypervisor features bitmap + +**/ +STATIC +UINT64 +GetHypervisorFeature ( + VOID + ) +{ + UINT64 Status; + GHCB *Ghcb; + MSR_SEV_ES_GHCB_REGISTER Msr; + BOOLEAN InterruptState; + UINT64 Features; + + Msr.GhcbPhysicalAddress =3D AsmReadMsr64 (MSR_SEV_ES_GHCB); + Ghcb =3D Msr.Ghcb; + + // + // Initialize the GHCB + // + VmgInit (Ghcb, &InterruptState); + + // + // Query the Hypervisor Features. + // + Status =3D VmgExit (Ghcb, SVM_EXIT_HYPERVISOR_FEATURES, 0, 0); + if ((Status !=3D 0)) { + SevEsProtocolFailure (GHCB_TERMINATE_GHCB_GENERAL); + } + + Features =3D Ghcb->SaveArea.SwExitInfo2; + + VmgDone (Ghcb, InterruptState); + + return Features; +} + /** =20 This function can be used to register the GHCB GPA. --=20 2.25.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 (#83725): https://edk2.groups.io/g/devel/message/83725 Mute This Topic: https://groups.io/mt/87011900/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-