From e8a2aed2b9ccf4dbc78e622df408e1f77f837ab0 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Wed, 9 Oct 2019 18:24:13 +0200 Subject: [PATCH] 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. --- cpuid_x86.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/cpuid_x86.c b/cpuid_x86.c index 2181db4db..92c8e1b67 100644 --- a/cpuid_x86.c +++ b/cpuid_x86.c @@ -1197,11 +1197,7 @@ int get_cpuname(void){ case 3: case 5: case 6: -#ifdef __64BIT__ - return CPUTYPE_CORE2; -#else return CPUTYPE_PENTIUM2; -#endif case 7: case 8: case 10: @@ -1383,8 +1379,6 @@ int get_cpuname(void){ break; case 7: // family 6 exmodel 7 switch (model) { - case 10: // Goldmont Plus - return CPUTYPE_NEHALEM; case 14: // Ice Lake if(support_avx512()) return CPUTYPE_SKYLAKEX; @@ -1431,7 +1425,11 @@ int get_cpuname(void){ case 0x5: return CPUTYPE_AMDK6; case 0x6: +#if defined(__x86_64__) || defined(__amd64__) + return CPUTYPE_BARCELONA; +#else return CPUTYPE_ATHLON; +#endif case 0xf: switch (exfamily) { case 0: @@ -1814,7 +1812,11 @@ int get_coretype(void){ case 4: case 5: case 6: +#if defined(__x86_64__) || defined(__amd64__) + return CORE_CORE2; +#else return CORE_P6; +#endif case 7: return CORE_KATMAI; case 8: @@ -2021,7 +2023,11 @@ int get_coretype(void){ if (vendor == VENDOR_AMD){ if (family <= 0x5) return CORE_80486; +#if defined(__x86_64__) || defined(__amd64__) + if (family <= 0xe) return CORE_BARCELONA; +#else if (family <= 0xe) return CORE_ATHLON; +#endif if (family == 0xf){ if ((exfamily == 0) || (exfamily == 2)) return CORE_OPTERON; else if (exfamily == 5) return CORE_BOBCAT;