From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: ray.ni@intel.com) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by groups.io with SMTP; Mon, 15 Jul 2019 00:20:17 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Jul 2019 00:20:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,493,1557212400"; d="scan'208";a="175019015" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by FMSMGA003.fm.intel.com with ESMTP; 15 Jul 2019 00:20:00 -0700 Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 15 Jul 2019 00:20:00 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx115.amr.corp.intel.com (10.18.116.19) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 15 Jul 2019 00:20:00 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.110]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.22]) with mapi id 14.03.0439.000; Mon, 15 Jul 2019 15:19:58 +0800 From: "Ni, Ray" To: "Dong, Eric" , "devel@edk2.groups.io" CC: Laszlo Ersek , "Kumar, Chandana C" , "Zeng, Star" Subject: Re: [Patch v2 2/2] UefiCpuPkg/RegisterCpuFeaturesLib: avoid use dynamic PCD. Thread-Topic: [Patch v2 2/2] UefiCpuPkg/RegisterCpuFeaturesLib: avoid use dynamic PCD. Thread-Index: AQHVOtsW7zs5p4lK6Uaxd4w2cwpmJKbLRWDQ Date: Mon, 15 Jul 2019 07:19:57 +0000 Deferred-Delivery: Mon, 15 Jul 2019 07:19:00 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5C22D7EC@SHSMSX104.ccr.corp.intel.com> References: <20190715070056.25916-1-eric.dong@intel.com> <20190715070056.25916-3-eric.dong@intel.com> In-Reply-To: <20190715070056.25916-3-eric.dong@intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYmI5MmRmZTMtYWE4Ni00ZjUwLWIwOWMtYWUxMGE4YTYxNDI0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiWEZ0aVwvRXJiMlVBS1luYzB4dks4WUU2ZDVIM2lQd1R6YmxzMFhYVEwzK2sxNjNBOGNmVGNVU1dYMXNiYTgwVFUifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.600.7 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: ray.ni@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ray Ni > -----Original Message----- > From: Dong, Eric > Sent: Monday, July 15, 2019 3:01 PM > To: devel@edk2.groups.io > Cc: Ni, Ray ; Laszlo Ersek ; Kumar, = Chandana C ; Zeng, > Star > Subject: [Patch v2 2/2] UefiCpuPkg/RegisterCpuFeaturesLib: avoid use dyna= mic PCD. >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1972 >=20 > Function in this library may be used by APs. Assert will be trig if AP > uses dynamic pcd. > This patch enhance the current code, remove the unnecessary usage of > dynamic PCD. This change try to avoid report this issue again later. >=20 > Cc: Ray Ni > Cc: Laszlo Ersek > Cc: Chandana Kumar > Cc: Star Zeng > Signed-off-by: Eric Dong > --- > .../CpuFeaturesInitialize.c | 64 +++++++-------- > .../RegisterCpuFeatures.h | 10 ++- > .../RegisterCpuFeaturesLib.c | 79 +++++++++---------- > 3 files changed, 76 insertions(+), 77 deletions(-) >=20 > diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitial= ize.c > b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c > index 1e25ba8b32..33752c1a9f 100644 > --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c > +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c > @@ -15,20 +15,16 @@ CHAR16 *mRegisterTypeStr[] =3D {L"MSR", L"CR", L"MMIO= ", L"CACHE", L"SEMAP", L"INVA > Worker function to save PcdCpuFeaturesCapability. >=20 > @param[in] SupportedFeatureMask The pointer to CPU feature bits mask= buffer > - @param[in] FeatureMaskSize CPU feature bits mask buffer size. > + @param[in] BitMaskSize CPU feature bits mask buffer size. >=20 > **/ > VOID > SetCapabilityPcd ( > IN UINT8 *SupportedFeatureMask, > - IN UINT32 FeatureMaskSize > + IN UINTN BitMaskSize > ) > { > EFI_STATUS Status; > - UINTN BitMaskSize; > - > - BitMaskSize =3D PcdGetSize (PcdCpuFeaturesCapability); > - ASSERT (FeatureMaskSize =3D=3D BitMaskSize); >=20 > Status =3D PcdSetPtrS (PcdCpuFeaturesCapability, &BitMaskSize, Support= edFeatureMask); > ASSERT_EFI_ERROR (Status); > @@ -38,16 +34,16 @@ SetCapabilityPcd ( > Worker function to save PcdCpuFeaturesSetting. >=20 > @param[in] SupportedFeatureMask The pointer to CPU feature bits mask= buffer > + @param[in] BitMaskSize CPU feature bits mask buffer size. > **/ > VOID > SetSettingPcd ( > - IN UINT8 *SupportedFeatureMask > + IN UINT8 *SupportedFeatureMask, > + IN UINTN BitMaskSize > ) > { > EFI_STATUS Status; > - UINTN BitMaskSize; >=20 > - BitMaskSize =3D PcdGetSize (PcdCpuFeaturesSetting); > Status =3D PcdSetPtrS (PcdCpuFeaturesSetting, &BitMaskSize, SupportedF= eatureMask); > ASSERT_EFI_ERROR (Status); > } > @@ -272,19 +268,20 @@ SupportedMaskOr ( >=20 > @param[in] SupportedFeatureMask The pointer to CPU feature bits mask= buffer > @param[in] AndFeatureBitMask The feature bit mask to do AND opera= tion > + @param[in] BitMaskSize CPU feature bits mask buffer size. > + > **/ > VOID > SupportedMaskAnd ( > IN UINT8 *SupportedFeatureMask, > - IN CONST UINT8 *AndFeatureBitMask > + IN CONST UINT8 *AndFeatureBitMask, > + IN UINT32 BitMaskSize > ) > { > UINTN Index; > - UINTN BitMaskSize; > UINT8 *Data1; > CONST UINT8 *Data2; >=20 > - BitMaskSize =3D PcdGetSize (PcdCpuFeaturesSetting); > Data1 =3D SupportedFeatureMask; > Data2 =3D AndFeatureBitMask; > for (Index =3D 0; Index < BitMaskSize; Index++) { > @@ -297,19 +294,19 @@ SupportedMaskAnd ( >=20 > @param[in] SupportedFeatureMask The pointer to CPU feature bits mask= buffer > @param[in] AndFeatureBitMask The feature bit mask to do XOR opera= tion > + @param[in] BitMaskSize CPU feature bits mask buffer size. > **/ > VOID > SupportedMaskCleanBit ( > IN UINT8 *SupportedFeatureMask, > - IN UINT8 *AndFeatureBitMask > + IN UINT8 *AndFeatureBitMask, > + IN UINT32 BitMaskSize > ) > { > UINTN Index; > - UINTN BitMaskSize; > UINT8 *Data1; > UINT8 *Data2; >=20 > - BitMaskSize =3D PcdGetSize (PcdCpuFeaturesSetting); > Data1 =3D SupportedFeatureMask; > Data2 =3D AndFeatureBitMask; > for (Index =3D 0; Index < BitMaskSize; Index++) { > @@ -323,6 +320,7 @@ SupportedMaskCleanBit ( >=20 > @param[in] SupportedFeatureMask The pointer to CPU feature bits mas= k buffer > @param[in] ComparedFeatureBitMask The feature bit mask to be compared > + @param[in] BitMaskSize CPU feature bits mask buffer size. >=20 > @retval TRUE The ComparedFeatureBitMask is set in CPU feature suppor= ted bits > mask buffer. > @@ -332,16 +330,14 @@ SupportedMaskCleanBit ( > BOOLEAN > IsBitMaskMatch ( > IN UINT8 *SupportedFeatureMask, > - IN UINT8 *ComparedFeatureBitMask > + IN UINT8 *ComparedFeatureBitMask, > + IN UINT32 BitMaskSize > ) > { > UINTN Index; > - UINTN BitMaskSize; > UINT8 *Data1; > UINT8 *Data2; >=20 > - BitMaskSize =3D PcdGetSize (PcdCpuFeaturesSetting); > - > Data1 =3D SupportedFeatureMask; > Data2 =3D ComparedFeatureBitMask; > for (Index =3D 0; Index < BitMaskSize; Index++) { > @@ -557,14 +553,14 @@ AnalysisProcessorFeatures ( > // > // Calculate the last capability on all processors > // > - SupportedMaskAnd (CpuFeaturesData->CapabilityPcd, CpuInitOrder->Feat= uresSupportedMask); > + SupportedMaskAnd (CpuFeaturesData->CapabilityPcd, CpuInitOrder->Feat= uresSupportedMask, CpuFeaturesData- > >BitMaskSize); > } > // > // Calculate the last setting > // > CpuFeaturesData->SettingPcd =3D AllocateCopyPool (CpuFeaturesData->Bit= MaskSize, CpuFeaturesData->CapabilityPcd); > ASSERT (CpuFeaturesData->SettingPcd !=3D NULL); > - SupportedMaskAnd (CpuFeaturesData->SettingPcd, PcdGetPtr (PcdCpuFeatur= esSetting)); > + SupportedMaskAnd (CpuFeaturesData->SettingPcd, PcdGetPtr (PcdCpuFeatur= esSetting), CpuFeaturesData->BitMaskSize); >=20 > // > // Dump the last CPU feature list > @@ -574,8 +570,8 @@ AnalysisProcessorFeatures ( > Entry =3D GetFirstNode (&CpuFeaturesData->FeatureList); > while (!IsNull (&CpuFeaturesData->FeatureList, Entry)) { > CpuFeature =3D CPU_FEATURE_ENTRY_FROM_LINK (Entry); > - if (IsBitMaskMatch (CpuFeature->FeatureMask, CpuFeaturesData->Capa= bilityPcd)) { > - if (IsBitMaskMatch (CpuFeature->FeatureMask, CpuFeaturesData->Se= ttingPcd)) { > + if (IsBitMaskMatch (CpuFeature->FeatureMask, CpuFeaturesData->Capa= bilityPcd, CpuFeaturesData->BitMaskSize)) { > + if (IsBitMaskMatch (CpuFeature->FeatureMask, CpuFeaturesData->Se= ttingPcd, CpuFeaturesData->BitMaskSize)) { > DEBUG ((DEBUG_INFO, "[Enable ] ")); > } else { > DEBUG ((DEBUG_INFO, "[Disable ] ")); > @@ -583,22 +579,22 @@ AnalysisProcessorFeatures ( > } else { > DEBUG ((DEBUG_INFO, "[Unsupport] ")); > } > - DumpCpuFeature (CpuFeature); > + DumpCpuFeature (CpuFeature, CpuFeaturesData->BitMaskSize); > Entry =3D Entry->ForwardLink; > } > DEBUG ((DEBUG_INFO, "PcdCpuFeaturesCapability:\n")); > - DumpCpuFeatureMask (CpuFeaturesData->CapabilityPcd); > + DumpCpuFeatureMask (CpuFeaturesData->CapabilityPcd, CpuFeaturesData-= >BitMaskSize); > DEBUG ((DEBUG_INFO, "Origin PcdCpuFeaturesSetting:\n")); > - DumpCpuFeatureMask (PcdGetPtr (PcdCpuFeaturesSetting)); > + DumpCpuFeatureMask (PcdGetPtr (PcdCpuFeaturesSetting), CpuFeaturesDa= ta->BitMaskSize); > DEBUG ((DEBUG_INFO, "Final PcdCpuFeaturesSetting:\n")); > - DumpCpuFeatureMask (CpuFeaturesData->SettingPcd); > + DumpCpuFeatureMask (CpuFeaturesData->SettingPcd, CpuFeaturesData->Bi= tMaskSize); > ); >=20 > // > // Save PCDs and display CPU PCDs > // > SetCapabilityPcd (CpuFeaturesData->CapabilityPcd, CpuFeaturesData->Bit= MaskSize); > - SetSettingPcd (CpuFeaturesData->SettingPcd); > + SetSettingPcd (CpuFeaturesData->SettingPcd, CpuFeaturesData->BitMaskSi= ze); >=20 > for (ProcessorNumber =3D 0; ProcessorNumber < NumberOfCpus; ProcessorN= umber++) { > CpuInitOrder =3D &CpuFeaturesData->InitOrder[ProcessorNumber]; > @@ -608,7 +604,7 @@ AnalysisProcessorFeatures ( > // Insert each feature into processor's order list > // > CpuFeature =3D CPU_FEATURE_ENTRY_FROM_LINK (Entry); > - if (IsBitMaskMatch (CpuFeature->FeatureMask, CpuFeaturesData->Capa= bilityPcd)) { > + if (IsBitMaskMatch (CpuFeature->FeatureMask, CpuFeaturesData->Capa= bilityPcd, CpuFeaturesData->BitMaskSize)) { > CpuFeatureInOrder =3D AllocateCopyPool (sizeof (CPU_FEATURES_ENT= RY), CpuFeature); > ASSERT (CpuFeatureInOrder !=3D NULL); > InsertTailList (&CpuInitOrder->OrderList, &CpuFeatureInOrder->Li= nk); > @@ -624,18 +620,18 @@ AnalysisProcessorFeatures ( > CpuFeatureInOrder =3D CPU_FEATURE_ENTRY_FROM_LINK (Entry); >=20 > Success =3D FALSE; > - if (IsBitMaskMatch (CpuFeatureInOrder->FeatureMask, CpuFeaturesDat= a->SettingPcd)) { > + if (IsBitMaskMatch (CpuFeatureInOrder->FeatureMask, CpuFeaturesDat= a->SettingPcd, CpuFeaturesData->BitMaskSize)) { > Status =3D CpuFeatureInOrder->InitializeFunc (ProcessorNumber, C= puInfo, CpuFeatureInOrder->ConfigData, TRUE); > if (EFI_ERROR (Status)) { > // > // Clean the CpuFeatureInOrder->FeatureMask in setting PCD. > // > - SupportedMaskCleanBit (CpuFeaturesData->SettingPcd, CpuFeature= InOrder->FeatureMask); > + SupportedMaskCleanBit (CpuFeaturesData->SettingPcd, CpuFeature= InOrder->FeatureMask, CpuFeaturesData- > >BitMaskSize); > if (CpuFeatureInOrder->FeatureName !=3D NULL) { > DEBUG ((DEBUG_WARN, "Warning :: Failed to enable Feature: Na= me =3D %a.\n", CpuFeatureInOrder->FeatureName)); > } else { > DEBUG ((DEBUG_WARN, "Warning :: Failed to enable Feature: Ma= sk =3D ")); > - DumpCpuFeatureMask (CpuFeatureInOrder->FeatureMask); > + DumpCpuFeatureMask (CpuFeatureInOrder->FeatureMask, CpuFeatu= resData->BitMaskSize); > } > } else { > Success =3D TRUE; > @@ -647,7 +643,7 @@ AnalysisProcessorFeatures ( > DEBUG ((DEBUG_WARN, "Warning :: Failed to disable Feature: N= ame =3D %a.\n", CpuFeatureInOrder->FeatureName)); > } else { > DEBUG ((DEBUG_WARN, "Warning :: Failed to disable Feature: M= ask =3D ")); > - DumpCpuFeatureMask (CpuFeatureInOrder->FeatureMask); > + DumpCpuFeatureMask (CpuFeatureInOrder->FeatureMask, CpuFeatu= resData->BitMaskSize); > } > } else { > Success =3D TRUE; > @@ -699,7 +695,7 @@ AnalysisProcessorFeatures ( > // again during initialize the features. > // > DEBUG ((DEBUG_INFO, "Dump final value for PcdCpuFeaturesSetting:\n")= ); > - DumpCpuFeatureMask (CpuFeaturesData->SettingPcd); > + DumpCpuFeatureMask (CpuFeaturesData->SettingPcd, CpuFeaturesData->Bi= tMaskSize); >=20 > // > // Dump the RegisterTable > diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeature= s.h > b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h > index 5c546ee153..a18f926641 100644 > --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h > +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h > @@ -180,20 +180,26 @@ SwitchNewBsp ( > Function that uses DEBUG() macros to display the contents of a a CPU f= eature bit mask. >=20 > @param[in] FeatureMask A pointer to the CPU feature bit mask. > + @param[in] BitMaskSize CPU feature bits mask buffer size. > + > **/ > VOID > DumpCpuFeatureMask ( > - IN UINT8 *FeatureMask > + IN UINT8 *FeatureMask, > + IN UINT32 BitMaskSize > ); >=20 > /** > Dump CPU feature name or CPU feature bit mask. >=20 > @param[in] CpuFeature Pointer to CPU_FEATURES_ENTRY > + @param[in] BitMaskSize CPU feature bits mask buffer size. > + > **/ > VOID > DumpCpuFeature ( > - IN CPU_FEATURES_ENTRY *CpuFeature > + IN CPU_FEATURES_ENTRY *CpuFeature, > + IN UINT32 BitMaskSize > ); >=20 > /** > diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeature= sLib.c > b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c > index 36aabd7267..796d722498 100644 > --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c > +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c > @@ -23,31 +23,29 @@ IsCpuFeatureMatch ( > IN UINT8 *SecondFeatureMask > ) > { > - UINTN BitMaskSize; > + CPU_FEATURES_DATA *CpuFeaturesData; >=20 > - BitMaskSize =3D PcdGetSize (PcdCpuFeaturesSetting); > - if (CompareMem (FirstFeatureMask, SecondFeatureMask, BitMaskSize) =3D= =3D 0) { > - return TRUE; > - } else { > - return FALSE; > - } > + CpuFeaturesData =3D GetCpuFeaturesData (); > + > + return (CompareMem (FirstFeatureMask, SecondFeatureMask, CpuFeaturesDa= ta->BitMaskSize) =3D=3D 0); > } >=20 > /** > Function that uses DEBUG() macros to display the contents of a a CPU f= eature bit mask. >=20 > @param[in] FeatureMask A pointer to the CPU feature bit mask. > + @param[in] BitMaskSize CPU feature bits mask buffer size. > + > **/ > VOID > DumpCpuFeatureMask ( > - IN UINT8 *FeatureMask > + IN UINT8 *FeatureMask, > + IN UINT32 BitMaskSize > ) > { > UINTN Index; > UINT8 *Data8; > - UINTN BitMaskSize; >=20 > - BitMaskSize =3D PcdGetSize (PcdCpuFeaturesSetting); > Data8 =3D (UINT8 *) FeatureMask; > for (Index =3D 0; Index < BitMaskSize; Index++) { > DEBUG ((DEBUG_INFO, " %02x ", *Data8++)); > @@ -59,10 +57,13 @@ DumpCpuFeatureMask ( > Dump CPU feature name or CPU feature bit mask. >=20 > @param[in] CpuFeature Pointer to CPU_FEATURES_ENTRY > + @param[in] BitMaskSize CPU feature bits mask buffer size. > + > **/ > VOID > DumpCpuFeature ( > - IN CPU_FEATURES_ENTRY *CpuFeature > + IN CPU_FEATURES_ENTRY *CpuFeature, > + IN UINT32 BitMaskSize > ) > { >=20 > @@ -70,7 +71,7 @@ DumpCpuFeature ( > DEBUG ((DEBUG_INFO, "FeatureName: %a\n", CpuFeature->FeatureName)); > } else { > DEBUG ((DEBUG_INFO, "FeatureMask =3D ")); > - DumpCpuFeatureMask (CpuFeature->FeatureMask); > + DumpCpuFeatureMask (CpuFeature->FeatureMask, BitMaskSize); > } > } >=20 > @@ -631,6 +632,7 @@ CheckCpuFeaturesDependency ( > /** > Worker function to register CPU Feature. >=20 > + @param[in] CpuFeaturesData Pointer to CPU feature data structur= e. > @param[in] CpuFeature Pointer to CPU feature entry >=20 > @retval RETURN_SUCCESS The CPU feature was successfully reg= istered. > @@ -642,31 +644,15 @@ CheckCpuFeaturesDependency ( > **/ > RETURN_STATUS > RegisterCpuFeatureWorker ( > + IN CPU_FEATURES_DATA *CpuFeaturesData, > IN CPU_FEATURES_ENTRY *CpuFeature > ) > { > EFI_STATUS Status; > - CPU_FEATURES_DATA *CpuFeaturesData; > CPU_FEATURES_ENTRY *CpuFeatureEntry; > LIST_ENTRY *Entry; > - UINTN BitMaskSize; > BOOLEAN FeatureExist; >=20 > - BitMaskSize =3D PcdGetSize (PcdCpuFeaturesSetting); > - CpuFeaturesData =3D GetCpuFeaturesData (); > - if (CpuFeaturesData->FeaturesCount =3D=3D 0) { > - 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) =3D=3D PcdGetSize (PcdCpu= FeaturesCapability)); > - ASSERT (PcdGetSize (PcdCpuFeaturesSetting) =3D=3D PcdGetSize (PcdCpu= FeaturesSupport)); > - CpuFeaturesData->BitMaskSize =3D (UINT32) BitMaskSize; > - } > - ASSERT (CpuFeaturesData->BitMaskSize =3D=3D BitMaskSize); > - > FeatureExist =3D FALSE; > CpuFeatureEntry =3D NULL; > Entry =3D GetFirstNode (&CpuFeaturesData->FeatureList); > @@ -684,12 +670,12 @@ RegisterCpuFeatureWorker ( >=20 > if (!FeatureExist) { > DEBUG ((DEBUG_INFO, "[NEW] ")); > - DumpCpuFeature (CpuFeature); > + DumpCpuFeature (CpuFeature, CpuFeaturesData->BitMaskSize); > InsertTailList (&CpuFeaturesData->FeatureList, &CpuFeature->Link); > CpuFeaturesData->FeaturesCount++; > } else { > DEBUG ((DEBUG_INFO, "[OVERRIDE] ")); > - DumpCpuFeature (CpuFeature); > + DumpCpuFeature (CpuFeature, CpuFeaturesData->BitMaskSize); > ASSERT (CpuFeatureEntry !=3D NULL); > // > // Overwrite original parameters of CPU feature > @@ -849,7 +835,6 @@ RegisterCpuFeature ( > EFI_STATUS Status; > VA_LIST Marker; > UINT32 Feature; > - UINTN BitMaskSize; > CPU_FEATURES_ENTRY *CpuFeature; > UINT8 *FeatureMask; > UINT8 *BeforeFeatureBitMask; > @@ -860,6 +845,7 @@ RegisterCpuFeature ( > UINT8 *PackageAfterFeatureBitMask; > BOOLEAN BeforeAll; > BOOLEAN AfterAll; > + CPU_FEATURES_DATA *CpuFeaturesData; >=20 > FeatureMask =3D NULL; > BeforeFeatureBitMask =3D NULL; > @@ -871,7 +857,18 @@ RegisterCpuFeature ( > BeforeAll =3D FALSE; > AfterAll =3D FALSE; >=20 > - BitMaskSize =3D PcdGetSize (PcdCpuFeaturesSetting); > + CpuFeaturesData =3D GetCpuFeaturesData (); > + if (CpuFeaturesData->FeaturesCount =3D=3D 0) { > + InitializeListHead (&CpuFeaturesData->FeatureList); > + InitializeSpinLock (&CpuFeaturesData->CpuFlags.MemoryMappedLock); > + InitializeSpinLock (&CpuFeaturesData->CpuFlags.ConsoleLogLock); > + // > + // Code assumes below three PCDs have PCD same buffer size. > + // > + ASSERT (PcdGetSize (PcdCpuFeaturesSetting) =3D=3D PcdGetSize (PcdCpu= FeaturesCapability)); > + ASSERT (PcdGetSize (PcdCpuFeaturesSetting) =3D=3D PcdGetSize (PcdCpu= FeaturesSupport)); > + CpuFeaturesData->BitMaskSize =3D (UINT32) PcdGetSize (PcdCpuFeatures= Setting); > + } >=20 > VA_START (Marker, InitializeFunc); > Feature =3D VA_ARG (Marker, UINT32); > @@ -889,19 +886,19 @@ RegisterCpuFeature ( > AfterAll =3D ((Feature & CPU_FEATURE_AFTER_ALL) !=3D 0) ? TRUE : = FALSE; > Feature &=3D ~(CPU_FEATURE_BEFORE_ALL | CPU_FEATURE_AFTER_ALL); > ASSERT (FeatureMask =3D=3D NULL); > - SetCpuFeaturesBitMask (&FeatureMask, Feature, BitMaskSize); > + SetCpuFeaturesBitMask (&FeatureMask, Feature, CpuFeaturesData->Bit= MaskSize); > } else if ((Feature & CPU_FEATURE_BEFORE) !=3D 0) { > - SetCpuFeaturesBitMask (&BeforeFeatureBitMask, Feature & ~CPU_FEATU= RE_BEFORE, BitMaskSize); > + SetCpuFeaturesBitMask (&BeforeFeatureBitMask, Feature & ~CPU_FEATU= RE_BEFORE, CpuFeaturesData->BitMaskSize); > } else if ((Feature & CPU_FEATURE_AFTER) !=3D 0) { > - SetCpuFeaturesBitMask (&AfterFeatureBitMask, Feature & ~CPU_FEATUR= E_AFTER, BitMaskSize); > + SetCpuFeaturesBitMask (&AfterFeatureBitMask, Feature & ~CPU_FEATUR= E_AFTER, CpuFeaturesData->BitMaskSize); > } else if ((Feature & CPU_FEATURE_CORE_BEFORE) !=3D 0) { > - SetCpuFeaturesBitMask (&CoreBeforeFeatureBitMask, Feature & ~CPU_F= EATURE_CORE_BEFORE, BitMaskSize); > + SetCpuFeaturesBitMask (&CoreBeforeFeatureBitMask, Feature & ~CPU_F= EATURE_CORE_BEFORE, CpuFeaturesData- > >BitMaskSize); > } else if ((Feature & CPU_FEATURE_CORE_AFTER) !=3D 0) { > - SetCpuFeaturesBitMask (&CoreAfterFeatureBitMask, Feature & ~CPU_FE= ATURE_CORE_AFTER, BitMaskSize); > + SetCpuFeaturesBitMask (&CoreAfterFeatureBitMask, Feature & ~CPU_FE= ATURE_CORE_AFTER, CpuFeaturesData- > >BitMaskSize); > } else if ((Feature & CPU_FEATURE_PACKAGE_BEFORE) !=3D 0) { > - SetCpuFeaturesBitMask (&PackageBeforeFeatureBitMask, Feature & ~CP= U_FEATURE_PACKAGE_BEFORE, BitMaskSize); > + SetCpuFeaturesBitMask (&PackageBeforeFeatureBitMask, Feature & ~CP= U_FEATURE_PACKAGE_BEFORE, > CpuFeaturesData->BitMaskSize); > } else if ((Feature & CPU_FEATURE_PACKAGE_AFTER) !=3D 0) { > - SetCpuFeaturesBitMask (&PackageAfterFeatureBitMask, Feature & ~CPU= _FEATURE_PACKAGE_AFTER, BitMaskSize); > + SetCpuFeaturesBitMask (&PackageAfterFeatureBitMask, Feature & ~CPU= _FEATURE_PACKAGE_AFTER, CpuFeaturesData- > >BitMaskSize); > } > Feature =3D VA_ARG (Marker, UINT32); > } > @@ -929,7 +926,7 @@ RegisterCpuFeature ( > ASSERT_EFI_ERROR (Status); > } >=20 > - Status =3D RegisterCpuFeatureWorker (CpuFeature); > + Status =3D RegisterCpuFeatureWorker (CpuFeaturesData, CpuFeature); > ASSERT_EFI_ERROR (Status); >=20 > return RETURN_SUCCESS; > -- > 2.21.0.windows.1