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.
This commit is contained in:
Radim Krčmář 2018-02-14 16:49:25 -05:00 committed by Lioncash
parent 5d96fdb151
commit f2d3607831
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -668,7 +668,7 @@ struct X86CPUDefinition {
static X86CPUDefinition builtin_x86_defs[] = { static X86CPUDefinition builtin_x86_defs[] = {
{ {
"qemu64", "qemu64",
4, 0x8000000A, 0, 0xd, 0x8000000A, 0,
CPUID_VENDOR_AMD, CPUID_VENDOR_AMD,
6, 6, 3, 6, 6, 3,
{ {
@ -753,7 +753,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
}, },
{ {
"kvm64", "kvm64",
5, 0x80000008, 0, 0xd, 0x80000008, 0,
CPUID_VENDOR_INTEL, CPUID_VENDOR_INTEL,
15, 6, 1, 15, 6, 1,
{ {
@ -864,7 +864,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
}, },
{ {
"pentium3", "pentium3",
2, 0, 0, 3, 0, 0,
CPUID_VENDOR_INTEL, CPUID_VENDOR_INTEL,
6, 7, 3, 6, 7, 3,
{ {
@ -891,8 +891,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
}, },
{ {
"n270", "n270",
/* original is on level 10 */ 10, 0x80000008, 0,
5, 0x8000000A, 0,
CPUID_VENDOR_INTEL, CPUID_VENDOR_INTEL,
6, 28, 2, 6, 28, 2,
{ {
@ -918,7 +917,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
}, },
{ {
"Conroe", "Conroe",
4, 0x8000000A, 0, 10, 0x80000008, 0,
CPUID_VENDOR_INTEL, CPUID_VENDOR_INTEL,
6, 15, 3, 6, 15, 3,
{ {
@ -941,7 +940,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
}, },
{ {
"Penryn", "Penryn",
4, 0x8000000A, 0, 10, 0x80000008, 0,
CPUID_VENDOR_INTEL, CPUID_VENDOR_INTEL,
6, 23, 3, 6, 23, 3,
{ {
@ -965,7 +964,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
}, },
{ {
"Nehalem", "Nehalem",
4, 0x8000000A, 0, 11, 0x80000008, 0,
CPUID_VENDOR_INTEL, CPUID_VENDOR_INTEL,
6, 26, 3, 6, 26, 3,
{ {
@ -989,7 +988,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
}, },
{ {
"Westmere", "Westmere",
11, 0x8000000A, 0, 11, 0x80000008, 0,
CPUID_VENDOR_INTEL, CPUID_VENDOR_INTEL,
6, 44, 1, 6, 44, 1,
{ {
@ -1026,7 +1025,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
}, },
{ {
"SandyBridge", "SandyBridge",
0xd, 0x8000000A, 0, 0xd, 0x80000008, 0,
CPUID_VENDOR_INTEL, CPUID_VENDOR_INTEL,
6, 42, 1, 6, 42, 1,
{ {
@ -1066,7 +1065,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
}, },
{ {
"IvyBridge", "IvyBridge",
0xd, 0x8000000A, 0, 0xd, 0x80000008, 0,
CPUID_VENDOR_INTEL, CPUID_VENDOR_INTEL,
6, 58, 9, 6, 58, 9,
{ {
@ -1107,7 +1106,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
}, },
{ {
"Haswell-noTSX", "Haswell-noTSX",
0xd, 0x8000000A, 0, 0xd, 0x80000008, 0,
CPUID_VENDOR_INTEL, CPUID_VENDOR_INTEL,
6, 60, 1, 6, 60, 1,
{ {
@ -1150,7 +1149,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
}, },
{ {
"Haswell", "Haswell",
0xd, 0x8000000A, 0, 0xd, 0x80000008, 0,
CPUID_VENDOR_INTEL, CPUID_VENDOR_INTEL,
6, 60, 1, 6, 60, 1,
{ {
@ -1194,7 +1193,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
}, },
{ {
"Broadwell-noTSX", "Broadwell-noTSX",
0xd, 0x8000000A, 0, 0xd, 0x80000008, 0,
CPUID_VENDOR_INTEL, CPUID_VENDOR_INTEL,
6, 61, 2, 6, 61, 2,
{ {
@ -1239,7 +1238,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
}, },
{ {
"Broadwell", "Broadwell",
0xd, 0x8000000A, 0, 0xd, 0x80000008, 0,
CPUID_VENDOR_INTEL, CPUID_VENDOR_INTEL,
6, 61, 2, 6, 61, 2,
{ {