]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/CpuMpPei/CpuMpPei.c
UefiCpuPkg/CpuMpPei: Set X2APIC flag if one x2APIC ID larger than 254
[mirror_edk2.git] / UefiCpuPkg / CpuMpPei / CpuMpPei.c
index 8e35f288fe3c64fd235a84658a851671f6317029..8ed52436c98ff8a3ea5fd19fdd71539606cbcf4e 100644 (file)
@@ -146,11 +146,20 @@ ApCFunction (
   PeiCpuMpData = ExchangeInfo->PeiCpuMpData;\r
   if (PeiCpuMpData->InitFlag) {\r
     //\r
-    // This is first time AP wakeup, get BIST inforamtion from AP stack\r
+    // This is first time AP wakeup, get BIST information from AP stack\r
     //\r
     BistData = *(UINTN *) (PeiCpuMpData->Buffer + NumApsExecuting * PeiCpuMpData->CpuApStackSize - sizeof (UINTN));\r
-    PeiCpuMpData->CpuData[NumApsExecuting].ApicId        = GetInitialApicId ();\r
     PeiCpuMpData->CpuData[NumApsExecuting].Health.Uint32 = (UINT32) BistData;\r
+    PeiCpuMpData->CpuData[NumApsExecuting].ApicId = GetInitialApicId ();\r
+    if (PeiCpuMpData->CpuData[NumApsExecuting].ApicId >= 0xFF) {\r
+      //\r
+      // Set x2APIC mode if there are any logical processor reporting\r
+      // an APIC ID of 255 or greater.\r
+      //\r
+      AcquireSpinLock(&PeiCpuMpData->MpLock);\r
+      PeiCpuMpData->X2ApicEnable = TRUE;\r
+      ReleaseSpinLock(&PeiCpuMpData->MpLock);\r
+    }\r
     //\r
     // Sync BSP's Mtrr table to all wakeup APs and load microcode on APs.\r
     //\r
@@ -363,15 +372,16 @@ CountProcessorNumber (
   //\r
   if (PcdGet32 (PcdCpuMaxLogicalProcessorNumber) > 1) {\r
     //\r
-    // Send broadcast IPI to APs to wakeup APs\r
+    // Send 1st broadcast IPI to APs to wakeup APs\r
     //\r
-    PeiCpuMpData->InitFlag = 1;\r
+    PeiCpuMpData->InitFlag     = TRUE;\r
+    PeiCpuMpData->X2ApicEnable = FALSE;\r
     WakeUpAP (PeiCpuMpData, TRUE, 0, NULL, NULL);\r
     //\r
     // Wait for AP task to complete and then exit.\r
     //\r
     MicroSecondDelay (PcdGet32 (PcdCpuApInitTimeOutInMicroSeconds));\r
-    PeiCpuMpData->InitFlag = 0;\r
+    PeiCpuMpData->InitFlag  = FALSE;\r
     PeiCpuMpData->CpuCount += (UINT32)PeiCpuMpData->MpCpuExchangeInfo->NumApsExecuting;\r
     ASSERT (PeiCpuMpData->CpuCount <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber));\r
     //\r
@@ -439,6 +449,7 @@ PrepareAPStartupVector (
   PeiCpuMpData->CpuData[0].ApicId        = GetInitialApicId ();\r
   PeiCpuMpData->CpuData[0].Health.Uint32 = 0;\r
   PeiCpuMpData->EndOfPeiFlag             = FALSE;\r
+  InitializeSpinLock(&PeiCpuMpData->MpLock);\r
   CopyMem (&PeiCpuMpData->AddressMap, &AddressMap, sizeof (MP_ASSEMBLY_ADDRESS_MAP));\r
 \r
   //\r