From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: eric.dong@intel.com) Received: from mga11.intel.com (mga11.intel.com []) by groups.io with SMTP; Tue, 16 Jul 2019 18:59:04 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jul 2019 18:59:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,272,1559545200"; d="scan'208";a="172719442" Received: from ydong10-win10.ccr.corp.intel.com ([10.239.158.133]) by orsmga006.jf.intel.com with ESMTP; 16 Jul 2019 18:59:02 -0700 From: "Dong, Eric" To: devel@edk2.groups.io Cc: Ray Ni , Laszlo Ersek , Chandana Kumar , Star Zeng Subject: [Patch v3 1/2] UefiCpuPkg/RegisterCpuFeaturesLib: Avoid AP calls PeiServices table. Date: Wed, 17 Jul 2019 09:58:59 +0800 Message-Id: <20190717015900.29224-2-eric.dong@intel.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20190717015900.29224-1-eric.dong@intel.com> References: <20190717015900.29224-1-eric.dong@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1972 AP calls CollectProcessorData() to collect processor info. CollectProcessorData function finally calls PcdGetSize function to get DynamicPCD PcdCpuFeaturesSetting value. PcdGetSize will use PeiServices table which caused below assert info: Processor Info: Package: 1, MaxCore : 4, MaxThread: 1 Package: 0, Valid Core : 4 ASSERT [CpuFeaturesPei] c:\projects\jsl\jsl_v1193\Edk2\MdePkg\Library \PeiServicesTablePointerLibIdt\PeiServicesTablePointer.c(48): PeiServices != ((void *) 0) This change uses saved global pcd size instead of calls PcdGetSize to fix this issue. Cc: Ray Ni Cc: Laszlo Ersek Cc: Chandana Kumar Cc: Star Zeng Signed-off-by: Eric Dong Reviewed-by: Ray Ni Reviewed-by: Star Zeng --- .../RegisterCpuFeaturesLib/CpuFeaturesInitialize.c | 13 ++++++++----- .../RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c | 5 +++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c index 1746f4f07f..1e25ba8b32 100644 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c @@ -246,19 +246,20 @@ CpuInitDataInitialize ( @param[in] SupportedFeatureMask The pointer to CPU feature bits mask buffer @param[in] OrFeatureBitMask The feature bit mask to do OR operation + @param[in] BitMaskSize The CPU feature bits mask buffer size. + **/ VOID SupportedMaskOr ( IN UINT8 *SupportedFeatureMask, - IN UINT8 *OrFeatureBitMask + IN UINT8 *OrFeatureBitMask, + IN UINT32 BitMaskSize ) { UINTN Index; - UINTN BitMaskSize; UINT8 *Data1; UINT8 *Data2; - BitMaskSize = PcdGetSize (PcdCpuFeaturesSetting); Data1 = SupportedFeatureMask; Data2 = OrFeatureBitMask; for (Index = 0; Index < BitMaskSize; Index++) { @@ -384,12 +385,14 @@ CollectProcessorData ( // SupportedMaskOr ( CpuFeaturesData->InitOrder[ProcessorNumber].FeaturesSupportedMask, - CpuFeature->FeatureMask + CpuFeature->FeatureMask, + CpuFeaturesData->BitMaskSize ); } else if (CpuFeature->SupportFunc (ProcessorNumber, CpuInfo, CpuFeature->ConfigData)) { SupportedMaskOr ( CpuFeaturesData->InitOrder[ProcessorNumber].FeaturesSupportedMask, - CpuFeature->FeatureMask + CpuFeature->FeatureMask, + CpuFeaturesData->BitMaskSize ); } Entry = Entry->ForwardLink; diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c index fa0f0b41e2..36aabd7267 100644 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c @@ -658,6 +658,11 @@ RegisterCpuFeatureWorker ( InitializeListHead (&CpuFeaturesData->FeatureList); InitializeSpinLock (&CpuFeaturesData->CpuFlags.MemoryMappedLock); InitializeSpinLock (&CpuFeaturesData->CpuFlags.ConsoleLogLock); + // + // Driver has assumption that these three PCD should has same buffer size. + // + ASSERT (PcdGetSize (PcdCpuFeaturesSetting) == PcdGetSize (PcdCpuFeaturesCapability)); + ASSERT (PcdGetSize (PcdCpuFeaturesSetting) == PcdGetSize (PcdCpuFeaturesSupport)); CpuFeaturesData->BitMaskSize = (UINT32) BitMaskSize; } ASSERT (CpuFeaturesData->BitMaskSize == BitMaskSize); -- 2.21.0.windows.1