Changeset 108794 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
- Timestamp:
- Mar 31, 2025 11:31:09 AM (2 weeks ago)
- svn:sync-xref-src-repo-rev:
- 168237
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/FirmwareNew
-
Property svn:mergeinfo
changed from (toggle deleted branches)
to (toggle deleted branches)/vendor/edk2/current 103735-103757,103769-103776,129194-164365 /vendor/edk2/current 103735-103757,103769-103776,129194-168232
-
Property svn:mergeinfo
changed from (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/FirmwareNew/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
r101291 r108794 96 96 UINTN ProcessorNumber; 97 97 EFI_PROCESSOR_INFORMATION ProcessorInfoBuffer; 98 CPU_STATUS_INFORMATION CpuStatusBackupBuffer; 98 99 CPU_FEATURES_ENTRY *CpuFeature; 99 100 CPU_FEATURES_INIT_ORDER *InitOrder; … … 121 122 Thread = 0; 122 123 124 CpuFeaturesData = NULL; 125 CpuStatus = NULL; 126 FirstCore = NULL; 127 InitOrder = NULL; 128 Location = NULL; 129 ThreadCountPerCore = NULL; 130 ThreadCountPerPackage = NULL; 131 123 132 CpuFeaturesData = GetCpuFeaturesData (); 133 if (CpuFeaturesData == NULL) { 134 ASSERT (CpuFeaturesData != NULL); 135 return; 136 } 124 137 125 138 // … … 131 144 132 145 CpuFeaturesData->InitOrder = AllocatePages (EFI_SIZE_TO_PAGES (sizeof (CPU_FEATURES_INIT_ORDER) * NumberOfCpus)); 133 ASSERT (CpuFeaturesData->InitOrder != NULL); 146 if (CpuFeaturesData->InitOrder == NULL) { 147 ASSERT (CpuFeaturesData->InitOrder != NULL); 148 return; 149 } 150 134 151 ZeroMem (CpuFeaturesData->InitOrder, sizeof (CPU_FEATURES_INIT_ORDER) * NumberOfCpus); 135 152 … … 151 168 152 169 AcpiCpuData = GetAcpiCpuData (); 153 ASSERT (AcpiCpuData != NULL); 170 if (AcpiCpuData == NULL) { 171 ASSERT (AcpiCpuData != NULL); 172 goto ExitOnError; 173 } 174 154 175 CpuFeaturesData->AcpiCpuData = AcpiCpuData; 155 176 156 177 CpuStatus = &AcpiCpuData->CpuFeatureInitData.CpuStatus; 157 Location = AllocatePages (EFI_SIZE_TO_PAGES (sizeof (EFI_CPU_PHYSICAL_LOCATION) * NumberOfCpus)); 158 ASSERT (Location != NULL); 178 CopyMem (&CpuStatusBackupBuffer, CpuStatus, sizeof (CpuStatusBackupBuffer)); 179 Location = AllocatePages (EFI_SIZE_TO_PAGES (sizeof (EFI_CPU_PHYSICAL_LOCATION) * NumberOfCpus)); 180 if (Location == NULL) { 181 ASSERT (Location != NULL); 182 goto ExitOnError; 183 } 184 159 185 ZeroMem (Location, sizeof (EFI_CPU_PHYSICAL_LOCATION) * NumberOfCpus); 160 186 AcpiCpuData->CpuFeatureInitData.ApLocation = (EFI_PHYSICAL_ADDRESS)(UINTN)Location; … … 163 189 InitOrder = &CpuFeaturesData->InitOrder[ProcessorNumber]; 164 190 InitOrder->FeaturesSupportedMask = AllocateZeroPool (CpuFeaturesData->BitMaskSize); 165 ASSERT (InitOrder->FeaturesSupportedMask != NULL); 191 if (InitOrder->FeaturesSupportedMask == NULL) { 192 ASSERT (InitOrder->FeaturesSupportedMask != NULL); 193 goto ExitOnError; 194 } 195 166 196 InitializeListHead (&InitOrder->OrderList); 167 197 Status = GetProcessorInformation (ProcessorNumber, &ProcessorInfoBuffer); … … 215 245 // 216 246 ThreadCountPerPackage = AllocatePages (EFI_SIZE_TO_PAGES (sizeof (UINT32) * CpuStatus->PackageCount)); 217 ASSERT (ThreadCountPerPackage != NULL); 247 if (ThreadCountPerPackage == NULL) { 248 ASSERT (ThreadCountPerPackage != NULL); 249 goto ExitOnError; 250 } 251 218 252 ZeroMem (ThreadCountPerPackage, sizeof (UINT32) * CpuStatus->PackageCount); 219 253 CpuStatus->ThreadCountPerPackage = (EFI_PHYSICAL_ADDRESS)(UINTN)ThreadCountPerPackage; 220 254 221 255 ThreadCountPerCore = AllocatePages (EFI_SIZE_TO_PAGES (sizeof (UINT8) * CpuStatus->PackageCount * CpuStatus->MaxCoreCount)); 222 ASSERT (ThreadCountPerCore != NULL); 256 if (ThreadCountPerCore == NULL) { 257 ASSERT (ThreadCountPerCore != NULL); 258 goto ExitOnError; 259 } 260 223 261 ZeroMem (ThreadCountPerCore, sizeof (UINT8) * CpuStatus->PackageCount * CpuStatus->MaxCoreCount); 224 262 CpuStatus->ThreadCountPerCore = (EFI_PHYSICAL_ADDRESS)(UINTN)ThreadCountPerCore; … … 248 286 249 287 CpuFeaturesData->CpuFlags.CoreSemaphoreCount = AllocateZeroPool (sizeof (UINT32) * CpuStatus->PackageCount * CpuStatus->MaxCoreCount * CpuStatus->MaxThreadCount); 250 ASSERT (CpuFeaturesData->CpuFlags.CoreSemaphoreCount != NULL); 288 if (CpuFeaturesData->CpuFlags.CoreSemaphoreCount == NULL) { 289 ASSERT (CpuFeaturesData->CpuFlags.CoreSemaphoreCount != NULL); 290 goto ExitOnError; 291 } 292 251 293 CpuFeaturesData->CpuFlags.PackageSemaphoreCount = AllocateZeroPool (sizeof (UINT32) * CpuStatus->PackageCount * CpuStatus->MaxCoreCount * CpuStatus->MaxThreadCount); 252 ASSERT (CpuFeaturesData->CpuFlags.PackageSemaphoreCount != NULL); 294 if (CpuFeaturesData->CpuFlags.PackageSemaphoreCount == NULL) { 295 ASSERT (CpuFeaturesData->CpuFlags.PackageSemaphoreCount != NULL); 296 goto ExitOnError; 297 } 253 298 254 299 // … … 258 303 Pages = EFI_SIZE_TO_PAGES (CpuStatus->PackageCount * sizeof (UINT32) + CpuStatus->PackageCount * CpuStatus->MaxCoreCount * sizeof (UINT32)); 259 304 FirstCore = AllocatePages (Pages); 260 ASSERT (FirstCore != NULL); 305 if (FirstCore == NULL) { 306 ASSERT (FirstCore != NULL); 307 goto ExitOnError; 308 } 309 261 310 FirstThread = FirstCore + CpuStatus->PackageCount; 262 311 … … 318 367 319 368 FreePages (FirstCore, Pages); 369 370 return; 371 372 ExitOnError: 373 if (FirstCore != NULL) { 374 FreePages (FirstCore, Pages); 375 } 376 377 if ((CpuFeaturesData != NULL) && (CpuFeaturesData->CpuFlags.PackageSemaphoreCount != NULL)) { 378 FreePool ((VOID *)CpuFeaturesData->CpuFlags.PackageSemaphoreCount); 379 CpuFeaturesData->CpuFlags.PackageSemaphoreCount = NULL; 380 } 381 382 if ((CpuFeaturesData != NULL) && (CpuFeaturesData->CpuFlags.CoreSemaphoreCount != NULL)) { 383 FreePool ((VOID *)CpuFeaturesData->CpuFlags.CoreSemaphoreCount); 384 CpuFeaturesData->CpuFlags.CoreSemaphoreCount = NULL; 385 } 386 387 if ((ThreadCountPerCore != NULL) && (CpuStatus != NULL)) { 388 FreePages ( 389 ThreadCountPerCore, 390 EFI_SIZE_TO_PAGES (sizeof (UINT8) * CpuStatus->PackageCount * CpuStatus->MaxCoreCount) 391 ); 392 } 393 394 if ((ThreadCountPerPackage != NULL) && (CpuStatus != NULL)) { 395 FreePages ( 396 ThreadCountPerPackage, 397 EFI_SIZE_TO_PAGES (sizeof (UINT32) * CpuStatus->PackageCount) 398 ); 399 } 400 401 if (InitOrder != NULL) { 402 for (ProcessorNumber = 0; ProcessorNumber < NumberOfCpus; ProcessorNumber++) { 403 InitOrder = &CpuFeaturesData->InitOrder[ProcessorNumber]; 404 if (InitOrder->FeaturesSupportedMask != NULL) { 405 FreePool (InitOrder->FeaturesSupportedMask); 406 InitOrder->FeaturesSupportedMask = NULL; 407 } 408 } 409 } 410 411 if (Location != NULL) { 412 FreePages (Location, EFI_SIZE_TO_PAGES (sizeof (EFI_CPU_PHYSICAL_LOCATION) * NumberOfCpus)); 413 } 414 415 if (CpuFeaturesData->InitOrder != NULL) { 416 FreePages (CpuFeaturesData->InitOrder, EFI_SIZE_TO_PAGES (sizeof (CPU_FEATURES_INIT_ORDER) * NumberOfCpus)); 417 CpuFeaturesData->InitOrder = NULL; 418 } 419 420 if (CpuStatus != NULL) { 421 CopyMem (CpuStatus, &CpuStatusBackupBuffer, sizeof (*CpuStatus)); 422 } 320 423 } 321 424
Note:
See TracChangeset
for help on using the changeset viewer.