Skip to content

Commit 20c7945

Browse files
committed
x86: update the loop break when reading topology cpuid leaves 0x1f/0x0b
AMD supports 0x0b but they don't specify the same break condition. Things worked fine in practice but a new AMD variant is coming, so don't assume any implicit compatibility with Intel anymore. Signed-off-by: Brice Goglin <[email protected]>
1 parent 1623f38 commit 20c7945

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

hwloc/topology-x86.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,11 @@ static void read_intel_cores_exttopoenum(struct hwloc_x86_backend_data_s *data,
542542
ecx = level;
543543
eax = leaf;
544544
cpuid_or_from_dump(&eax, &ebx, &ecx, &edx, src_cpuiddump);
545-
if (!eax && !ebx)
545+
/* Intel specifies that 0x0b/0x1f return 0 in ecx[8:15] and 0 in eax/ebx for invalid subleaves
546+
* however AMD only says that 0x0b returns 0 in ebx[0:15].
547+
* So use the common condition: 0 in ebx[0:15].
548+
*/
549+
if (!(ebx & 0xffff))
546550
break;
547551
apic_packageshift = eax & 0x1f;
548552
}
@@ -555,7 +559,7 @@ static void read_intel_cores_exttopoenum(struct hwloc_x86_backend_data_s *data,
555559
ecx = level;
556560
eax = leaf;
557561
cpuid_or_from_dump(&eax, &ebx, &ecx, &edx, src_cpuiddump);
558-
if (!eax && !ebx)
562+
if (!(ebx & 0xffff))
559563
break;
560564
apic_nextshift = eax & 0x1f;
561565
apic_type = (ecx & 0xff00) >> 8;

0 commit comments

Comments
 (0)