From nobody Sat Feb 7 06:55:23 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+82587+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 1634962483619233.4462459415936; Fri, 22 Oct 2021 21:14:43 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id bt7nYY1788612xJ5vgwzP8f9; Fri, 22 Oct 2021 21:14:43 -0700 X-Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.41]) by mx.groups.io with SMTP id smtpd.web12.2855.1634962482678019156 for ; Fri, 22 Oct 2021 21:14:42 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AevPTesPCi6TbVlX0ZmaZ3M1uxPY2otyDg5FNSj51rGnXA/WZzqlAy91zalIuu+DTV++nztNdYtsy/eTTKCDwxP2PDDddFxiwrnckIeiuoeD2kij/iY3sasRKMQk7b3AXoMzAjV7nQYwTVQoA0Bx23prXpIkqQo0fLaKYXEgFhbOxo+b8hSekVrhnSInsAd6m0bSCkEV6jWNk4TtOqirI/AYXxYtJ90odfB0yd98Z7x5Xj0PZCA8smrHhGbGI5BeTwIK4ZPZKRx0V8iT4Vcgco+xyO6Lf8LErlU4/BSnpwP7+5gQhEVY9vdSUH7o+XkAk4d+cfJENztq9G1IpK/9TQ== 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=YM3/Q2dFAnxvBFnt7++FB7KW3xynh04OXlWGPcmmYz4QY7wX8i7RhguYjH+jfmwHnKOiKA1yidv7TpUQV6yYQwR3BFiquPxyj9naONBcJ+0mnqnJLoD1je94WZXplZDDOOxFrCR0Elsz55c3b2GqdRlvBeIHi+syHRjeRGFPNBW1LqidIyGaQsrBNjCWNnLHRjVv+hAIuUfXO4VeoHJY33pQ3DpKPjNNs4Upfih+etUV/sTkfBg2wdDJT1cb9IphBsaxRBV9XhnTGucLnYg7iBCiglpgUxEqax6cYQURU/TRqQCWwKv9H2wfZvQyP2cKLhbtVrqCYvG0DpHZiWbaKA== 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 BN9PR03CA0633.namprd03.prod.outlook.com (2603:10b6:408:13b::8) by DM5PR1201MB0154.namprd12.prod.outlook.com (2603:10b6:4:58::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18; Sat, 23 Oct 2021 04:14:40 +0000 X-Received: from BN8NAM11FT037.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13b:cafe::ac) by BN9PR03CA0633.outlook.office365.com (2603:10b6:408:13b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18 via Frontend Transport; Sat, 23 Oct 2021 04:14:40 +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+82587+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 BN8NAM11FT037.mail.protection.outlook.com (10.13.177.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4628.16 via Frontend Transport; Sat, 23 Oct 2021 04:14:39 +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.2308.15; Fri, 22 Oct 2021 23:14:37 -0500 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 , Brijesh Singh , Michael Roth , Jiewen Yao Subject: [edk2-devel] [PATCH v11 24/32] OvmfPkg/PlatformPei: set the Hypervisor Features PCD Date: Fri, 22 Oct 2021 23:13:41 -0500 Message-ID: <20211023041349.1263726-25-brijesh.singh@amd.com> In-Reply-To: <20211023041349.1263726-1-brijesh.singh@amd.com> References: <20211023041349.1263726-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: 85fda7f1-d772-4635-7d96-08d995dba20f X-MS-TrafficTypeDiagnostic: DM5PR1201MB0154: 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: e1bHdTjnfqVGhe3CtB4gXKUA/lrXSJgQsVuSuha/3Hh9UZAnGy8jBTMrIa8C7tfsD/CPLqkKWEGHd195a8JygCCmvXh5JvesRNgisQIsMMA1wWwk8s2BipA632Ik23atkcPGC2RNKd/Y6lHntg770vmVRbG/E+TXLnT2njPFfejPinXeV7xdtybRN8gND13z5NlO8NxsIm2uqYp6lhEyR6RfiJmPJ3CxlrN9QFGmcZhpU1nwdlweAJqnmPMMqTalGeuKkMJirvlO5fo6j303FbVI41KUSzz2ECACKCWiS+dSmiEuJCG6jwoy0bSaYdnRGV5hkoJrS3EjM2diQUUekcBxiYH66sNPD+yTMWRArj9R9PC2qc1seqm/u1LlQBhD/h8tujZ3lxuNxI1ztDgASnAkGceaZYMWtquOo/awGkIp508g8x7xiEkU12P6obVIP77webRTaqRhyb2GsQe28zwapAEJcMNQlMc08CmUskn5fZjPj3nKeXBkgg71HmIbfAhEgX+PQihfzKpOAfu9+M2t3Cy6AuxeKfl45a8MaFkvhbzAxSNGTDhEbJYNZ8dmNGa5CRNtd34OAc3t8SNJbVuT3x+J6eyONOz/rgs/jdTEayBq8F1/mUDhPBCQHKRqTvWFUa/5F9qy1rUEsOQO9AeX3HVU3xL4j92PKEYlsPYP7n+6xTnZNGvf8Xbk5/FiyFwHQXR109B/pKy0hSc4PFl0YQPjWeL+RyznaO+C2FTkRmHsZSHj1iwdBhSxYs+Nmz4ctCRh/FddqtP0FUsrZDkKADv3udNX6/65gLfsA7usIaC3rMuc5ZYV2CsO1DoD X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2021 04:14:39.8506 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 85fda7f1-d772-4635-7d96-08d995dba20f 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: BN8NAM11FT037.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB0154 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: nDMd0swuFco7caFhAqpOcgmcx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634962483; bh=pEa1jszGVZDgtsrvmUOMheNuVIESrr53Y/tmzEe6CUg=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=fYA9uWbwVdiRP6p/Da29lR6KtfK/NgwXUDlsZujRY5q69Oib9NoFIxOBgDgPqLjRPeV M5m/Ikh84Af2j8scuovbjCKCL8Cc5vpe/INzzmcHZwnc12WTJTPmCP4/mfIFizWLzS0Ta Kk+IIaVRtZQaP5IqKH05r+1C7cjpUSc7N3g= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634962485295100089 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 (#82587): https://edk2.groups.io/g/devel/message/82587 Mute This Topic: https://groups.io/mt/86530736/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-