From f2d3607831b4bfddb5681570f52f7979fb7a8319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Date: Wed, 14 Feb 2018 16:49:25 -0500 Subject: [PATCH] target-i386: emulate CPUID level of real hardware W10 insider has a bug where it ignores CPUID level and interprets CPUID.(EAX=07H, ECX=0H) incorrectly, because CPUID in fact returned CPUID.(EAX=04H, ECX=0H); this resulted in execution of unsupported instructions. While it's a Windows bug, there is no reason to emulate incorrect level. I used http://instlatx64.atw.hu/ as a source of CPUID and checked that it matches Penryn Xeon X5472, Westmere Xeon W3520, SandyBridge i5-2540M, and Haswell i5-4670T. kvm64 and qemu64 were bumped to 0xD to allow all available features for them (and to avoid the same Windows bug). Backports commit 3046bb5debc8153a542acb1df93b2a1a85527a15 from qemu. --- qemu/target-i386/cpu.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/qemu/target-i386/cpu.c b/qemu/target-i386/cpu.c index 3e67f0c5..9905e2ed 100644 --- a/qemu/target-i386/cpu.c +++ b/qemu/target-i386/cpu.c @@ -668,7 +668,7 @@ struct X86CPUDefinition { static X86CPUDefinition builtin_x86_defs[] = { { "qemu64", - 4, 0x8000000A, 0, + 0xd, 0x8000000A, 0, CPUID_VENDOR_AMD, 6, 6, 3, { @@ -753,7 +753,7 @@ static X86CPUDefinition builtin_x86_defs[] = { }, { "kvm64", - 5, 0x80000008, 0, + 0xd, 0x80000008, 0, CPUID_VENDOR_INTEL, 15, 6, 1, { @@ -864,7 +864,7 @@ static X86CPUDefinition builtin_x86_defs[] = { }, { "pentium3", - 2, 0, 0, + 3, 0, 0, CPUID_VENDOR_INTEL, 6, 7, 3, { @@ -891,8 +891,7 @@ static X86CPUDefinition builtin_x86_defs[] = { }, { "n270", - /* original is on level 10 */ - 5, 0x8000000A, 0, + 10, 0x80000008, 0, CPUID_VENDOR_INTEL, 6, 28, 2, { @@ -918,7 +917,7 @@ static X86CPUDefinition builtin_x86_defs[] = { }, { "Conroe", - 4, 0x8000000A, 0, + 10, 0x80000008, 0, CPUID_VENDOR_INTEL, 6, 15, 3, { @@ -941,7 +940,7 @@ static X86CPUDefinition builtin_x86_defs[] = { }, { "Penryn", - 4, 0x8000000A, 0, + 10, 0x80000008, 0, CPUID_VENDOR_INTEL, 6, 23, 3, { @@ -965,7 +964,7 @@ static X86CPUDefinition builtin_x86_defs[] = { }, { "Nehalem", - 4, 0x8000000A, 0, + 11, 0x80000008, 0, CPUID_VENDOR_INTEL, 6, 26, 3, { @@ -989,7 +988,7 @@ static X86CPUDefinition builtin_x86_defs[] = { }, { "Westmere", - 11, 0x8000000A, 0, + 11, 0x80000008, 0, CPUID_VENDOR_INTEL, 6, 44, 1, { @@ -1026,7 +1025,7 @@ static X86CPUDefinition builtin_x86_defs[] = { }, { "SandyBridge", - 0xd, 0x8000000A, 0, + 0xd, 0x80000008, 0, CPUID_VENDOR_INTEL, 6, 42, 1, { @@ -1066,7 +1065,7 @@ static X86CPUDefinition builtin_x86_defs[] = { }, { "IvyBridge", - 0xd, 0x8000000A, 0, + 0xd, 0x80000008, 0, CPUID_VENDOR_INTEL, 6, 58, 9, { @@ -1107,7 +1106,7 @@ static X86CPUDefinition builtin_x86_defs[] = { }, { "Haswell-noTSX", - 0xd, 0x8000000A, 0, + 0xd, 0x80000008, 0, CPUID_VENDOR_INTEL, 6, 60, 1, { @@ -1150,7 +1149,7 @@ static X86CPUDefinition builtin_x86_defs[] = { }, { "Haswell", - 0xd, 0x8000000A, 0, + 0xd, 0x80000008, 0, CPUID_VENDOR_INTEL, 6, 60, 1, { @@ -1194,7 +1193,7 @@ static X86CPUDefinition builtin_x86_defs[] = { }, { "Broadwell-noTSX", - 0xd, 0x8000000A, 0, + 0xd, 0x80000008, 0, CPUID_VENDOR_INTEL, 6, 61, 2, { @@ -1239,7 +1238,7 @@ static X86CPUDefinition builtin_x86_defs[] = { }, { "Broadwell", - 0xd, 0x8000000A, 0, + 0xd, 0x80000008, 0, CPUID_VENDOR_INTEL, 6, 61, 2, {