]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/CpuDxe/CpuMp.c
UefiCpuPkg/MpService: avoid reset AP still hold a lock
[mirror_edk2.git] / UefiCpuPkg / CpuDxe / CpuMp.c
index 10065762a243b00c03bfcae41baaf0401da6b81d..e03c7f1e4916b54ea46b3df3ffbbf01815a0226d 100644 (file)
@@ -52,6 +52,7 @@ GetMpSpinLock (
   while (!AcquireSpinLockOrFail (&CpuData->CpuDataLock)) {\r
     CpuPause ();\r
   }\r
+  CpuData->LockSelf = GetApicId ();\r
 }\r
 \r
 /**\r
@@ -1144,6 +1145,13 @@ ProcessorToIdleState (
   WhoAmI (&mMpServicesTemplate, &ProcessorNumber);\r
   CpuData = &mMpSystemData.CpuDatas[ProcessorNumber];\r
 \r
+  //\r
+  // Avoid forcibly reset AP caused the AP got lock not release.\r
+  //\r
+  if (CpuData->LockSelf == (INTN) GetApicId ()) {\r
+    ReleaseSpinLock (&CpuData->CpuDataLock);\r
+  }\r
+\r
   //\r
   // Avoid forcibly reset AP caused the AP State is not updated.\r
   //\r
@@ -1395,6 +1403,7 @@ FillInProcessorInformation (
   CpuData->Procedure        = NULL;\r
   CpuData->Parameter        = NULL;\r
   InitializeSpinLock (&CpuData->CpuDataLock);\r
+  CpuData->LockSelf         = -1;\r
 \r
   return EFI_SUCCESS;\r
 }\r