Skip to content

Commit e8a2aed

Browse files
authored
Support QEMU cpu calling itself 64bit AMD Athlon as well
Some QEMU instances pretend to be "AuthenticAMD" with the same family 6/model 6 even when running on an Intel host (could be related to qemu or libvirt version and/or kvm availability). Also fix the define to depend on __x86_64__ set by the compiler, the defines using __64BIT__ will only work for getarch_2nd.
1 parent f262031 commit e8a2aed

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

cpuid_x86.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,11 +1197,7 @@ int get_cpuname(void){
11971197
case 3:
11981198
case 5:
11991199
case 6:
1200-
#ifdef __64BIT__
1201-
return CPUTYPE_CORE2;
1202-
#else
12031200
return CPUTYPE_PENTIUM2;
1204-
#endif
12051201
case 7:
12061202
case 8:
12071203
case 10:
@@ -1383,8 +1379,6 @@ int get_cpuname(void){
13831379
break;
13841380
case 7: // family 6 exmodel 7
13851381
switch (model) {
1386-
case 10: // Goldmont Plus
1387-
return CPUTYPE_NEHALEM;
13881382
case 14: // Ice Lake
13891383
if(support_avx512())
13901384
return CPUTYPE_SKYLAKEX;
@@ -1431,7 +1425,11 @@ int get_cpuname(void){
14311425
case 0x5:
14321426
return CPUTYPE_AMDK6;
14331427
case 0x6:
1428+
#if defined(__x86_64__) || defined(__amd64__)
1429+
return CPUTYPE_BARCELONA;
1430+
#else
14341431
return CPUTYPE_ATHLON;
1432+
#endif
14351433
case 0xf:
14361434
switch (exfamily) {
14371435
case 0:
@@ -1814,7 +1812,11 @@ int get_coretype(void){
18141812
case 4:
18151813
case 5:
18161814
case 6:
1815+
#if defined(__x86_64__) || defined(__amd64__)
1816+
return CORE_CORE2;
1817+
#else
18171818
return CORE_P6;
1819+
#endif
18181820
case 7:
18191821
return CORE_KATMAI;
18201822
case 8:
@@ -2021,7 +2023,11 @@ int get_coretype(void){
20212023

20222024
if (vendor == VENDOR_AMD){
20232025
if (family <= 0x5) return CORE_80486;
2026+
#if defined(__x86_64__) || defined(__amd64__)
2027+
if (family <= 0xe) return CORE_BARCELONA;
2028+
#else
20242029
if (family <= 0xe) return CORE_ATHLON;
2030+
#endif
20252031
if (family == 0xf){
20262032
if ((exfamily == 0) || (exfamily == 2)) return CORE_OPTERON;
20272033
else if (exfamily == 5) return CORE_BOBCAT;

0 commit comments

Comments
 (0)