]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/CpuHotplugSmm/CpuHotplug.c
OvmfPkg/CpuHotplugSmm: fix CPU hotplug race just before SMI broadcast
[mirror_edk2.git] / OvmfPkg / CpuHotplugSmm / CpuHotplug.c
index 20e6bec04f41981fc8af311eececc28559fb8a77..cfe698ed2b5e1a555dc38f41654204d35da48254 100644 (file)
@@ -193,9 +193,28 @@ CpuHotplugMmi (
   NewSlot = 0;\r
   while (PluggedIdx < PluggedCount) {\r
     APIC_ID NewApicId;\r
+    UINT32  CheckSlot;\r
     UINTN   NewProcessorNumberByProtocol;\r
 \r
     NewApicId = mPluggedApicIds[PluggedIdx];\r
+\r
+    //\r
+    // Check if the supposedly hot-added CPU is already known to us.\r
+    //\r
+    for (CheckSlot = 0;\r
+         CheckSlot < mCpuHotPlugData->ArrayLength;\r
+         CheckSlot++) {\r
+      if (mCpuHotPlugData->ApicId[CheckSlot] == NewApicId) {\r
+        break;\r
+      }\r
+    }\r
+    if (CheckSlot < mCpuHotPlugData->ArrayLength) {\r
+      DEBUG ((DEBUG_VERBOSE, "%a: APIC ID " FMT_APIC_ID " was hot-plugged "\r
+        "before; ignoring it\n", __FUNCTION__, NewApicId));\r
+      PluggedIdx++;\r
+      continue;\r
+    }\r
+\r
     //\r
     // Find the first empty slot in CPU_HOT_PLUG_DATA.\r
     //\r