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