]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
UefiCpuPkg/LocalApicLib: fix feature test for Extended Topology CPUID leaf
[mirror_edk2.git] / UefiCpuPkg / Library / BaseXApicX2ApicLib / BaseXApicX2ApicLib.c
index 9720d26e60e2044951c01bcb5cfe8e2ca2118a94..e690d2aa144524e703a4002c1145703f1918b87b 100644 (file)
@@ -411,12 +411,15 @@ GetInitialApicId (
     AsmCpuid (CPUID_SIGNATURE, &MaxCpuIdIndex, NULL, NULL, NULL);\r
     //\r
     // If CPUID Leaf B is supported, \r
+    // And CPUID.0BH:EBX[15:0] reports a non-zero value,\r
     // Then the initial 32-bit APIC ID = CPUID.0BH:EDX\r
     // Else the initial 8-bit APIC ID = CPUID.1:EBX[31:24]\r
     //\r
     if (MaxCpuIdIndex >= CPUID_EXTENDED_TOPOLOGY) {\r
-      AsmCpuidEx (CPUID_EXTENDED_TOPOLOGY, 0, NULL, NULL, NULL, &ApicId);\r
-      return ApicId;\r
+      AsmCpuidEx (CPUID_EXTENDED_TOPOLOGY, 0, NULL, &RegEbx, NULL, &ApicId);\r
+      if ((RegEbx & (BIT16 - 1)) != 0) {\r
+        return ApicId;\r
+      }\r
     }\r
     AsmCpuid (CPUID_VERSION_INFO, NULL, &RegEbx, NULL, NULL);\r
     return RegEbx >> 24;\r