From nobody Thu May 9 01:11:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1508918327344802.3290938936543; Wed, 25 Oct 2017 00:58:47 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id ADCE92034A7DE; Wed, 25 Oct 2017 00:55:00 -0700 (PDT) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5118A202E6186 for ; Wed, 25 Oct 2017 00:54:58 -0700 (PDT) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP; 25 Oct 2017 00:58:43 -0700 Received: from ydong10-win10.ccr.corp.intel.com ([10.239.158.64]) by orsmga005.jf.intel.com with ESMTP; 25 Oct 2017 00:58:42 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=eric.dong@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,431,1503385200"; d="scan'208";a="164674445" From: Eric Dong To: edk2-devel@lists.01.org Date: Wed, 25 Oct 2017 15:58:39 +0800 Message-Id: <1508918319-10232-1-git-send-email-eric.dong@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 Subject: [edk2] [Patch] UefiCpuPkg/CpuFeatures: Export HOB if CPU initialized in PEI. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ruiyu Ni , Laszlo Ersek MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In current implementation, CPU initialized can be done in PEI or DXE phase. PEI uses CpuFeaturesPie and Dxe uses CpuFeaturesDxe. If CPU initialized in PEI phase, CpuFeaturesDxe driver will not be used. This driver will install gEdkiiCpuFeaturesInitDoneGuid protocol after it initializes the CPU. Some drivers depend on this protocol to dispatch themselves. If CpuFeaturesDxe not been used, these drivers will not be dispatched. This patch fix the above issue. If Cpu initialized in PEI phase, it also report a guid HOB for CpuFeaturesDxe. CpuFeaturesDxe will check this HOB first. If it found this HOB, it just install gEdkiiCpuFeaturesInitDoneGuid protocol, else it will also do the CPU initialization. Cc: Ruiyu Ni Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Eric Dong Reviewed-by: Laszlo Ersek Reviewed-by: Ruiyu Ni --- UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c | 19 +++++++++++++++++++ UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf | 1 + UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c | 6 ++++++ UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf | 1 + 4 files changed, 27 insertions(+) diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c b/UefiCpuPkg/CpuFeatur= es/CpuFeaturesDxe.c index b0b186d..6c0ae9d 100644 --- a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c +++ b/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c @@ -19,6 +19,7 @@ #include #include #include +#include =20 #include #include @@ -101,6 +102,24 @@ CpuFeaturesDxeInitialize ( ) { VOID *Registration; + EFI_STATUS Status; + EFI_HANDLE Handle; + + if (GetFirstGuidHob (&gEdkiiCpuFeaturesInitDoneGuid) !=3D NULL) { + // + // Try to find HOB first. This HOB exist means CPU features have=20 + // been initialized by CpuFeaturesPei driver, just install gEdkiiCpuFe= aturesInitDoneGuid. + // + Handle =3D NULL; + Status =3D gBS->InstallProtocolInterface ( + &Handle, + &gEdkiiCpuFeaturesInitDoneGuid, + EFI_NATIVE_INTERFACE, + NULL + ); + ASSERT_EFI_ERROR (Status); + return EFI_SUCCESS; + } =20 if (PcdGetBool (PcdCpuFeaturesInitAfterSmmRelocation)) { // diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf b/UefiCpuPkg/CpuFeat= ures/CpuFeaturesDxe.inf index 175e8a9..b1733be 100644 --- a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf +++ b/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf @@ -33,6 +33,7 @@ UefiDriverEntryPoint UefiBootServicesTableLib RegisterCpuFeaturesLib + HobLib =20 [Sources] CpuFeaturesDxe.c diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c b/UefiCpuPkg/CpuFeatur= es/CpuFeaturesPei.c index b052d55..72ee19b 100644 --- a/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c +++ b/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c @@ -18,6 +18,7 @@ #include #include #include +#include =20 #include =20 @@ -70,6 +71,11 @@ CpuFeaturesPeimInitialize ( Status =3D PeiServicesInstallPpi(&mPeiCpuFeaturesInitDonePpiDesc); ASSERT_EFI_ERROR (Status); =20 + // + // Build HOB to let CpuFeatureDxe driver skip the initialization process. + // + BuildGuidHob (&gEdkiiCpuFeaturesInitDoneGuid, 0); + return EFI_SUCCESS; } =20 diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf b/UefiCpuPkg/CpuFeat= ures/CpuFeaturesPei.inf index dd4b388..e617c5b 100644 --- a/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf +++ b/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf @@ -32,6 +32,7 @@ PeimEntryPoint PeiServicesLib RegisterCpuFeaturesLib + HobLib =20 [Sources] CpuFeaturesPei.c --=20 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel