UefiCpuPkg/RegisterCpuFeaturesLib: Avoid AP calls PeiServices table.

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 <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Chandana Kumar <chandana.c.kumar@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
This commit is contained in:
Eric Dong 2019-07-11 19:56:25 +08:00
parent 04dd0cb972
commit bbd357ae57
2 changed files with 13 additions and 5 deletions

View File

@ -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;

View File

@ -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);