From nobody Mon Feb 9 20:10:47 2026 Delivered-To: importer@patchew.org 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+96909+1787277+3901457@groups.io; helo=mail02.groups.io; 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+96909+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1669986638; cv=none; d=zohomail.com; s=zohoarc; b=MQb67Nto76s/e/PtZzskmSnoGHjlbLGTtPBMVmaFtTe9spdcnu4CV8QF8YhctpEOanQ8I4CUEexWBrptVjUrJBNl6Ce165hmhw3JyWFsso0eXwFL9P9ROiOHQSmbI9yaMyMbfY5ilfe0jjIdoCnY6T55Bfo0qkdZ2XmkEvTdGUk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669986638; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=Fv3TQC71GfwD7kA1isNcRV8bGCzoVUaFMXp72ShV1BA=; b=lK3psQMwzfLX/Ixe5nmE053kJX7P00azCb/sfZ3QDPuTzy3AvjnCUBLTbkq4nfok2UOAoKub33bJsx6Lxd1QVQUpdKkuMEwBeEIRhbKGWlslFkuebmh1McdXD6Ey7RqJSy0Em49FFduH9ACXHHFrpjkl1hJh4eYIhCVI0OID3vw= ARC-Authentication-Results: i=1; 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+96909+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1669986638824154.78801265166715; Fri, 2 Dec 2022 05:10:38 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 7802YY1788612xiJd8iPENFl; Fri, 02 Dec 2022 05:10:38 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web10.74425.1669986637790697739 for ; Fri, 02 Dec 2022 05:10:37 -0800 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-470-O3GrG7DxMS-Ll723i-Qk_g-1; Fri, 02 Dec 2022 08:10:33 -0500 X-MC-Unique: O3GrG7DxMS-Ll723i-Qk_g-1 X-Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4C1A4185A794; Fri, 2 Dec 2022 13:10:32 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.192.79]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E7A9A1402BDC; Fri, 2 Dec 2022 13:10:31 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 00EE81801561; Fri, 2 Dec 2022 14:10:10 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Bob Feng , Yuwei Chen , Erdem Aktas , Jordan Justen , Peter Grehan , Rebecca Cran , Liming Gao , Ard Biesheuvel , Gerd Hoffmann , Jiewen Yao , Min Xu , Brijesh Singh , Oliver Steffen , Pawel Polawski , Tom Lendacky , James Bottomley Subject: [edk2-devel] [PATCH 11/14] OvmfPkg/PlatformPei: remove mFeatureControlValue Date: Fri, 2 Dec 2022 14:10:06 +0100 Message-Id: <20221202131009.3190040-12-kraxel@redhat.com> In-Reply-To: <20221202131009.3190040-1-kraxel@redhat.com> References: <20221202131009.3190040-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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,kraxel@redhat.com X-Gm-Message-State: zDmush4v0DvKbjDImUK2Z1aKx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1669986638; bh=KKyT/VEQAziMuCmrSJUGN6SpDCQj1C5LHU8yBHYtb2I=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=VmH71LZALiIiM9e0nY+f6V0/TB8Z00yH7JE8FyjrGlchUdzE/7/F0iMZfMXZnNi7zT/ uEk3UDByEdfapr/DXjWt/LSc/gJM3sRbEO2K2M4a75K2U4M5q13xroscJZQv1i3T8MkUZ rsB/pyHmM5ACfR/D/sdyVslLfiwoImQlFds= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1669986639408100002 Content-Type: text/plain; charset="utf-8"; x-default="true" Use PlatformInfoHob->FeatureControlValue instead. OnMpServicesAvailable() will find PlatformInfoHob using GetFirstGuidHob() and pass a pointer to the WriteFeatureControl callback. Signed-off-by: Gerd Hoffmann --- OvmfPkg/Include/Library/PlatformInitLib.h | 2 ++ OvmfPkg/PlatformPei/Platform.h | 2 +- OvmfPkg/PlatformPei/FeatureControl.c | 44 ++++++++++++++++------- OvmfPkg/PlatformPei/Platform.c | 2 +- 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/OvmfPkg/Include/Library/PlatformInitLib.h b/OvmfPkg/Include/Li= brary/PlatformInitLib.h index c5234bf26d45..da7ed76041d2 100644 --- a/OvmfPkg/Include/Library/PlatformInitLib.h +++ b/OvmfPkg/Include/Library/PlatformInitLib.h @@ -48,6 +48,8 @@ typedef struct { =20 UINT32 S3AcpiReservedMemoryBase; UINT32 S3AcpiReservedMemorySize; + + UINT64 FeatureControlValue; } EFI_HOB_PLATFORM_INFO; #pragma pack() =20 diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h index 86f603ff649c..1cf44844a781 100644 --- a/OvmfPkg/PlatformPei/Platform.h +++ b/OvmfPkg/PlatformPei/Platform.h @@ -70,7 +70,7 @@ MemTypeInfoInitialization ( =20 VOID InstallFeatureControlCallback ( - VOID + IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob ); =20 VOID diff --git a/OvmfPkg/PlatformPei/FeatureControl.c b/OvmfPkg/PlatformPei/Fea= tureControl.c index 5864ee0c214d..d8a398cd5565 100644 --- a/OvmfPkg/PlatformPei/FeatureControl.c +++ b/OvmfPkg/PlatformPei/FeatureControl.c @@ -8,6 +8,7 @@ **/ =20 #include +#include #include #include #include @@ -16,11 +17,6 @@ =20 #include "Platform.h" =20 -// -// The value to be written to the Feature Control MSR, retrieved from fw_c= fg. -// -STATIC UINT64 mFeatureControlValue; - /** Write the Feature Control MSR on an Application Processor or the Boot Processor. @@ -38,10 +34,22 @@ WriteFeatureControl ( IN OUT VOID *WorkSpace ) { + EFI_HOB_PLATFORM_INFO *PlatformInfoHob =3D WorkSpace; + if (TdIsEnabled ()) { - TdVmCall (TDVMCALL_WRMSR, (UINT64)MSR_IA32_FEATURE_CONTROL, mFeatureCo= ntrolValue, 0, 0, 0); + TdVmCall ( + TDVMCALL_WRMSR, + (UINT64)MSR_IA32_FEATURE_CONTROL, + PlatformInfoHob->FeatureControlValue, + 0, + 0, + 0 + ); } else { - AsmWriteMsr64 (MSR_IA32_FEATURE_CONTROL, mFeatureControlValue); + AsmWriteMsr64 ( + MSR_IA32_FEATURE_CONTROL, + PlatformInfoHob->FeatureControlValue + ); } } =20 @@ -67,6 +75,15 @@ OnMpServicesAvailable ( { EFI_PEI_MP_SERVICES_PPI *MpServices; EFI_STATUS Status; + EFI_HOB_PLATFORM_INFO *PlatformInfoHob; + EFI_HOB_GUID_TYPE *GuidHob; + + GuidHob =3D GetFirstGuidHob (&gUefiOvmfPkgPlatformInfoGuid); + if (GuidHob =3D=3D NULL) { + return EFI_UNSUPPORTED; + } + + PlatformInfoHob =3D (EFI_HOB_PLATFORM_INFO *)GET_GUID_HOB_DATA (GuidHob); =20 DEBUG ((DEBUG_VERBOSE, "%a: %a\n", gEfiCallerBaseName, __FUNCTION__)); =20 @@ -80,7 +97,7 @@ OnMpServicesAvailable ( WriteFeatureControl, // Procedure FALSE, // SingleThread 0, // TimeoutInMicroSeconds= : inf. - NULL // ProcedureArgument + PlatformInfoHob // ProcedureArgument ); if (EFI_ERROR (Status) && (Status !=3D EFI_NOT_STARTED)) { DEBUG ((DEBUG_ERROR, "%a: StartupAllAps(): %r\n", __FUNCTION__, Status= )); @@ -90,7 +107,7 @@ OnMpServicesAvailable ( // // Now write the MSR on the BSP too. // - WriteFeatureControl (NULL); + WriteFeatureControl (PlatformInfoHob); return EFI_SUCCESS; } =20 @@ -107,7 +124,7 @@ STATIC CONST EFI_PEI_NOTIFY_DESCRIPTOR mMpServicesNoti= fy =3D { =20 VOID InstallFeatureControlCallback ( - VOID + IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob ) { EFI_STATUS Status; @@ -119,7 +136,7 @@ InstallFeatureControlCallback ( &FwCfgItem, &FwCfgSize ); - if (EFI_ERROR (Status) || (FwCfgSize !=3D sizeof mFeatureControlValue)) { + if (EFI_ERROR (Status) || (FwCfgSize !=3D sizeof (PlatformInfoHob->Featu= reControlValue))) { // // Nothing to do. // @@ -127,7 +144,10 @@ InstallFeatureControlCallback ( } =20 QemuFwCfgSelectItem (FwCfgItem); - QemuFwCfgReadBytes (sizeof mFeatureControlValue, &mFeatureControlValue); + QemuFwCfgReadBytes ( + sizeof (PlatformInfoHob->FeatureControlValue), + &(PlatformInfoHob->FeatureControlValue) + ); =20 Status =3D PeiServicesNotifyPpi (&mMpServicesNotify); if (EFI_ERROR (Status)) { diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c index ebce2ba1290e..148240342b4b 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -396,7 +396,7 @@ InitializePlatform ( } =20 IntelTdxInitialize (); - InstallFeatureControlCallback (); + InstallFeatureControlCallback (PlatformInfoHob); =20 return EFI_SUCCESS; } --=20 2.38.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 (#96909): https://edk2.groups.io/g/devel/message/96909 Mute This Topic: https://groups.io/mt/95405214/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-