target-i386: fix W10 bug and bring CPUID levels closer to reality
cover target-i386: fix W10 bug and bring CPUID levels closer to reality
The first patch uses CPUID levels from the internet, which has a nice side effect of making W10 insider preview bootable.
The second patch is a traditional buggy bug fix.
Radim Krčmář (2):
target-i386: emulate CPUID level of real hardware
target-i386: automatically raise cpuid level to 0xd
target-i386/cpu.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-)
Signature · 1 line
2.4.4
PATCH 1/2 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; and amend xlevel while at it.
I have 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 avoid similar problems.
--- target-i386/cpu.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-)
target-i386/cpu.c +18 -19
@@ -677,7 +677,7 @@ struct X86CPUDefinition {static X86CPUDefinition builtin_x86_defs[] = { { .name ="qemu64" , - .level =4 , + .level =0xd , .vendor =CPUID_VENDOR_AMD , .family =6 , .model =6 ,
@@ -753,7 +753,7 @@ static X86CPUDefinition builtin_x86_defs[] = { }, { .name = "kvm64", - .level = 5, + .level = 0xd, .vendor = CPUID_VENDOR_INTEL, .family = 15, .model = 6,
@@ -864,7 +864,7 @@ static X86CPUDefinition builtin_x86_defs[] = { }, { .name = "pentium3", - .level = 2, + .level = 3, .vendor = CPUID_VENDOR_INTEL, .family = 6, .model = 7,
@@ -889,8 +889,7 @@ static X86CPUDefinition builtin_x86_defs[] = { }, { .name = "n270", -/* original is on level 10 */ - .level = 5, + .level = 10, .vendor = CPUID_VENDOR_INTEL, .family = 6, .model = 28,
@@ -910,12 +909,12 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT2_NX, .features[FEAT_8000_0001_ECX ] = CPUID_EXT3_LAHF_LM, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel(R) Atom(TM) CPU N270 @ 1.60GHz", }, { .name = "Conroe", - .level = 4, + .level = 10, .vendor = CPUID_VENDOR_INTEL, .family = 6, .model = 15,
@@ -932,12 +931,12 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT2_LM | CPUID_EXT2_NX | CPUID_EXT2_SYSCALL, .features[FEAT_8000_0001_ECX ] = CPUID_EXT3_LAHF_LM, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Celeron_4x0 (Conroe/Merom Class Core 2)", }, { .name = "Penryn", - .level = 4, + .level = 10, .vendor = CPUID_VENDOR_INTEL, .family = 6, .model = 23,
@@ -955,12 +954,12 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT2_LM | CPUID_EXT2_NX | CPUID_EXT2_SYSCALL, .features[FEAT_8000_0001_ECX ] = CPUID_EXT3_LAHF_LM, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Core 2 Duo P9xxx (Penryn Class Core 2)", }, { .name = "Nehalem", - .level = 4, + .level = 11, .vendor = CPUID_VENDOR_INTEL, .family = 6, .model = 26,
@@ -978,7 +977,7 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT2_LM | CPUID_EXT2_SYSCALL | CPUID_EXT2_NX, .features[FEAT_8000_0001_ECX ] = CPUID_EXT3_LAHF_LM, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Core i7 9xx (Nehalem Class Core i7)", }, {
@@ -1002,7 +1001,7 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT2_LM | CPUID_EXT2_SYSCALL | CPUID_EXT2_NX, .features[FEAT_8000_0001_ECX ] = CPUID_EXT3_LAHF_LM, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Westmere E56xx/L56xx/X56xx (Nehalem-C)", }, {
@@ -1031,7 +1030,7 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT3_LAHF_LM, .features[FEAT_XSAVE ] = CPUID_XSAVE_XSAVEOPT, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Xeon E312xx (Sandy Bridge)", }, {
@@ -1063,7 +1062,7 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT3_LAHF_LM, .features[FEAT_XSAVE ] = CPUID_XSAVE_XSAVEOPT, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Xeon E3-12xx v2 (Ivy Bridge)", }, {
@@ -1097,7 +1096,7 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_ERMS | CPUID_7_0_EBX_INVPCID, .features[FEAT_XSAVE ] = CPUID_XSAVE_XSAVEOPT, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Core Processor (Haswell, no TSX)", }, { .name = "Haswell",
@@ -1131,7 +1130,7 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_7_0_EBX_RTM, .features[FEAT_XSAVE ] = CPUID_XSAVE_XSAVEOPT, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Core Processor (Haswell)", }, {
@@ -1167,7 +1166,7 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_7_0_EBX_SMAP, .features[FEAT_XSAVE ] = CPUID_XSAVE_XSAVEOPT, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Core Processor (Broadwell, no TSX)", }, {
@@ -1203,7 +1202,7 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_7_0_EBX_SMAP, .features[FEAT_XSAVE ] = CPUID_XSAVE_XSAVEOPT, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Core Processor (Broadwell)", }, {
Signature · 1 line
2.4.4
Re: [Qemu-devel] [PATCH 1/2] target-i386: emulate CPUID level of real hardware
Quoted 5 lines · Radim Krčmář
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.
Quoted 8 lines
While it's a Windows bug, there is no reason to emulate incorrect level; and amend xlevel while at it.
I have 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
0xDto avoid similar problems.
This unfortunately has to be done only for new machine types. Old types will remain buggy forever.
Paolo
Quoted 164 lines
Signed-off-by Radim Krčmář <[email protected]>--- target-i386/cpu.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-)target-i386/cpu.c +18
-19@@ -677,7 +677,7 @@ struct X86CPUDefinition {static X86CPUDefinition builtin_x86_defs[] = { { .name ="qemu64" , - .level =4 , + .level =0xd , .vendor =CPUID_VENDOR_AMD , .family =6 , .model =6 ,@@ -753,7 +753,7 @@ static X86CPUDefinition builtin_x86_defs[] = { }, { .name = "kvm64", - .level = 5, + .level = 0xd, .vendor = CPUID_VENDOR_INTEL, .family = 15, .model = 6,@@ -864,7 +864,7 @@ static X86CPUDefinition builtin_x86_defs[] = { }, { .name = "pentium3", - .level = 2, + .level = 3, .vendor = CPUID_VENDOR_INTEL, .family = 6, .model = 7,@@ -889,8 +889,7 @@ static X86CPUDefinition builtin_x86_defs[] = { }, { .name = "n270", -/* original is on level 10 */ - .level = 5, + .level = 10, .vendor = CPUID_VENDOR_INTEL, .family = 6, .model = 28,@@ -910,12 +909,12 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT2_NX, .features[FEAT_8000_0001_ECX ] = CPUID_EXT3_LAHF_LM, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel(R) Atom(TM) CPU N270 @ 1.60GHz", }, { .name = "Conroe", - .level = 4, + .level = 10, .vendor = CPUID_VENDOR_INTEL, .family = 6, .model = 15,@@ -932,12 +931,12 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT2_LM | CPUID_EXT2_NX | CPUID_EXT2_SYSCALL, .features[FEAT_8000_0001_ECX ] = CPUID_EXT3_LAHF_LM, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Celeron_4x0 (Conroe/Merom Class Core 2)", }, { .name = "Penryn", - .level = 4, + .level = 10, .vendor = CPUID_VENDOR_INTEL, .family = 6, .model = 23,@@ -955,12 +954,12 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT2_LM | CPUID_EXT2_NX | CPUID_EXT2_SYSCALL, .features[FEAT_8000_0001_ECX ] = CPUID_EXT3_LAHF_LM, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Core 2 Duo P9xxx (Penryn Class Core 2)", }, { .name = "Nehalem", - .level = 4, + .level = 11, .vendor = CPUID_VENDOR_INTEL, .family = 6, .model = 26,@@ -978,7 +977,7 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT2_LM | CPUID_EXT2_SYSCALL | CPUID_EXT2_NX, .features[FEAT_8000_0001_ECX ] = CPUID_EXT3_LAHF_LM, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Core i7 9xx (Nehalem Class Core i7)", }, {@@ -1002,7 +1001,7 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT2_LM | CPUID_EXT2_SYSCALL | CPUID_EXT2_NX, .features[FEAT_8000_0001_ECX ] = CPUID_EXT3_LAHF_LM, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Westmere E56xx/L56xx/X56xx (Nehalem-C)", }, {@@ -1031,7 +1030,7 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT3_LAHF_LM, .features[FEAT_XSAVE ] = CPUID_XSAVE_XSAVEOPT, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Xeon E312xx (Sandy Bridge)", }, {@@ -1063,7 +1062,7 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT3_LAHF_LM, .features[FEAT_XSAVE ] = CPUID_XSAVE_XSAVEOPT, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Xeon E3-12xx v2 (Ivy Bridge)", }, {@@ -1097,7 +1096,7 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_ERMS | CPUID_7_0_EBX_INVPCID, .features[FEAT_XSAVE ] = CPUID_XSAVE_XSAVEOPT, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Core Processor (Haswell, no TSX)", }, { .name = "Haswell",@@ -1131,7 +1130,7 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_7_0_EBX_RTM, .features[FEAT_XSAVE ] = CPUID_XSAVE_XSAVEOPT, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Core Processor (Haswell)", }, {@@ -1167,7 +1166,7 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_7_0_EBX_SMAP, .features[FEAT_XSAVE ] = CPUID_XSAVE_XSAVEOPT, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Core Processor (Broadwell, no TSX)", }, {@@ -1203,7 +1202,7 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_7_0_EBX_SMAP, .features[FEAT_XSAVE ] = CPUID_XSAVE_XSAVEOPT, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Core Processor (Broadwell)", }, {
Re: [Qemu-devel] [PATCH 1/2] target-i386: emulate CPUID level of real hardware
2015-06-18 17:29+0200, Paolo Bonzini:
Quoted 9 lines · Radim Krčmář
Quoted 8 lines
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; and amend xlevel while at it.
Quoted 8 lines
Quoted 5 lines
I have 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
0xDto avoid similar problems.This unfortunately has to be done only for new machine types. Old types will remain buggy forever.
Ah, ok, which machine type should I target, 2.4?
And is patch 2 is only supposed to work with new machine types?
Thanks.
Re: [Qemu-devel] [PATCH 1/2] target-i386: emulate CPUID level of real hardware
Quoted 4 lines · Radim Krčmář
Quoted 2 lines
This unfortunately has to be done only for new machine types. Old types will remain buggy forever.
Ah, ok, which machine type should I target, 2.4?
Yes.
Quoted 1 line
And is patch 2 is only supposed to work with new machine types?
I'm a bit undecided there, since it only triggers with explicitly specified CPU flags and the old code would basically never work (it's a known bug, triggered by libvirt's "host-model" code in some cases).
Paolo
Re: [Qemu-devel] [PATCH 1/2] target-i386: emulate CPUID level of real hardware
In reply to Paolo BonziniQuoted 9 lines · Paolo Bonzini
Quoted 8 lines · Radim Krčmář
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; and amend xlevel while at it.
Quoted 8 lines
Quoted 5 lines
I have 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
0xDto avoid similar problems.This unfortunately has to be done only for new machine types. Old types will remain buggy forever.
When is it recommended to add a new machine type ? And conventionally, new changes are to be made default and compat code takes care of the older machine types right ?
Bandan
Quoted 166 lines
Paolo
Quoted 164 lines
Signed-off-by Radim Krčmář <[email protected]>--- target-i386/cpu.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-)target-i386/cpu.c +18
-19@@ -677,7 +677,7 @@ struct X86CPUDefinition {static X86CPUDefinition builtin_x86_defs[] = { { .name ="qemu64" , - .level =4 , + .level =0xd , .vendor =CPUID_VENDOR_AMD , .family =6 , .model =6 ,@@ -753,7 +753,7 @@ static X86CPUDefinition builtin_x86_defs[] = { }, { .name = "kvm64", - .level = 5, + .level = 0xd, .vendor = CPUID_VENDOR_INTEL, .family = 15, .model = 6,@@ -864,7 +864,7 @@ static X86CPUDefinition builtin_x86_defs[] = { }, { .name = "pentium3", - .level = 2, + .level = 3, .vendor = CPUID_VENDOR_INTEL, .family = 6, .model = 7,@@ -889,8 +889,7 @@ static X86CPUDefinition builtin_x86_defs[] = { }, { .name = "n270", -/* original is on level 10 */ - .level = 5, + .level = 10, .vendor = CPUID_VENDOR_INTEL, .family = 6, .model = 28,@@ -910,12 +909,12 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT2_NX, .features[FEAT_8000_0001_ECX ] = CPUID_EXT3_LAHF_LM, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel(R) Atom(TM) CPU N270 @ 1.60GHz", }, { .name = "Conroe", - .level = 4, + .level = 10, .vendor = CPUID_VENDOR_INTEL, .family = 6, .model = 15,@@ -932,12 +931,12 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT2_LM | CPUID_EXT2_NX | CPUID_EXT2_SYSCALL, .features[FEAT_8000_0001_ECX ] = CPUID_EXT3_LAHF_LM, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Celeron_4x0 (Conroe/Merom Class Core 2)", }, { .name = "Penryn", - .level = 4, + .level = 10, .vendor = CPUID_VENDOR_INTEL, .family = 6, .model = 23,@@ -955,12 +954,12 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT2_LM | CPUID_EXT2_NX | CPUID_EXT2_SYSCALL, .features[FEAT_8000_0001_ECX ] = CPUID_EXT3_LAHF_LM, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Core 2 Duo P9xxx (Penryn Class Core 2)", }, { .name = "Nehalem", - .level = 4, + .level = 11, .vendor = CPUID_VENDOR_INTEL, .family = 6, .model = 26,@@ -978,7 +977,7 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT2_LM | CPUID_EXT2_SYSCALL | CPUID_EXT2_NX, .features[FEAT_8000_0001_ECX ] = CPUID_EXT3_LAHF_LM, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Core i7 9xx (Nehalem Class Core i7)", }, {@@ -1002,7 +1001,7 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT2_LM | CPUID_EXT2_SYSCALL | CPUID_EXT2_NX, .features[FEAT_8000_0001_ECX ] = CPUID_EXT3_LAHF_LM, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Westmere E56xx/L56xx/X56xx (Nehalem-C)", }, {@@ -1031,7 +1030,7 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT3_LAHF_LM, .features[FEAT_XSAVE ] = CPUID_XSAVE_XSAVEOPT, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Xeon E312xx (Sandy Bridge)", }, {@@ -1063,7 +1062,7 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT3_LAHF_LM, .features[FEAT_XSAVE ] = CPUID_XSAVE_XSAVEOPT, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Xeon E3-12xx v2 (Ivy Bridge)", }, {@@ -1097,7 +1096,7 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_ERMS | CPUID_7_0_EBX_INVPCID, .features[FEAT_XSAVE ] = CPUID_XSAVE_XSAVEOPT, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Core Processor (Haswell, no TSX)", }, { .name = "Haswell",@@ -1131,7 +1130,7 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_7_0_EBX_RTM, .features[FEAT_XSAVE ] = CPUID_XSAVE_XSAVEOPT, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Core Processor (Haswell)", }, {@@ -1167,7 +1166,7 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_7_0_EBX_SMAP, .features[FEAT_XSAVE ] = CPUID_XSAVE_XSAVEOPT, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Core Processor (Broadwell, no TSX)", }, {@@ -1203,7 +1202,7 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_7_0_EBX_SMAP, .features[FEAT_XSAVE ] = CPUID_XSAVE_XSAVEOPT, - .xlevel = 0x8000000A, + .xlevel = 0x80000008, .model_id = "Intel Core Processor (Broadwell)", }, {
PATCH 2/2 target-i386: automatically raise cpuid level to 0xd
In reply to Radim KrčmářWe already bump to level 7 if features there are requested, so do the same for 0xD.
---
If we want this behavior, we should not do it by writing a case for every level.
target-i386/cpu.c | 4 ++++ 1 file changed, 4 insertions(+)
target-i386/cpu.c +4 -0
@@ -2796,6 +2796,10 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) env->cpuid_level =7 ; } +if (env->features[FEAT_XSAVE ] && env->cpuid_level <0xd ) { + env->cpuid_level =0xd ; + } +/* On AMD CPUs, some CPUID[8000_0001].EDX bits must match the bits on * CPUID[1].EDX. */
Signature · 1 line
2.4.4
Re: [Qemu-devel] [PATCH 2/2] target-i386: automatically raise cpuid level to 0xd
Quoted 4 lines · Radim Krčmář
We already bump to level 7 if features there are requested, so do the same for
0xD.Signed-off-by Radim Krčmář <[email protected]>
This breaks guest ABI and live-migration, as CPUID data is not part of the migration stream (although we have considered including it in the future).
If we are going to add more special cases like this, we must provide a way to make QEMU honour an explicit "level" option from the config file or command-line.
I have considered introducing "min-[x]level" and "max-{x]level" properties to control automatic increasing of level/xlevel. The existing X86CPUDefinition.level field could just control min_level, while explicit "level=" on the command-line or config file would explicitly force a specific value. Probably setting "max-level" on machine-type compat code would be enough to restore the previous behavior.
Quoted 25 lines
---
If we want this behavior, we should not do it by writing a case for every level.target-i386/cpu.c | 4 ++++ 1 file changed, 4 insertions(+)target-i386/cpu.c +4
-0@@ -2796,6 +2796,10 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) env->cpuid_level =7 ; } +if (env->features[FEAT_XSAVE ] && env->cpuid_level <0xd ) { + env->cpuid_level =0xd ; + } +/* On AMD CPUs, some CPUID[8000_0001].EDX bits must match the bits on * CPUID[1].EDX. */ Signature · 1 line
2.4.4
Signature · 1 line
Eduardo
Re: [Qemu-devel] [PATCH 2/2] target-i386: automatically raise cpuid level to 0xd
Quoted 3 lines · Eduardo Habkost
Quoted 2 lines · Radim Krčmář
We already bump to level 7 if features there are requested, so do the same for
0xD.
But doesn't bumping to 7 for feat[ebx] have the potential to break ABI too ?
Quoted 10 lines
Quoted 1 line
Signed-off-by Radim Krčmář <[email protected]>This breaks guest ABI and live-migration, as CPUID data is not part of the migration stream (although we have considered including it in the future).
If we are going to add more special cases like this, we must provide a way to make QEMU honour an explicit "level" option from the config file or command-line.
Quoted 11 lines
I have considered introducing "min-[x]level" and "max-{x]level" properties to control automatic increasing of level/xlevel. The existing X86CPUDefinition.level field could just control
min_level, while explicit "level=" on the command-line or config file would explicitly force a specific value. Probably setting "max-level" on machine-type compat code would be enough to restore the previous behavior.Quoted 3 lines
---
If we want this behavior, we should not do it by writing a case for every level.
Agreed, we should really have a more generic way of doing this.
Bandan
Quoted 21 lines
Quoted 21 lines
target-i386/cpu.c | 4 ++++ 1 file changed, 4 insertions(+)target-i386/cpu.c +4
-0@@ -2796,6 +2796,10 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) env->cpuid_level =7 ; } +if (env->features[FEAT_XSAVE ] && env->cpuid_level <0xd ) { + env->cpuid_level =0xd ; + } +/* On AMD CPUs, some CPUID[8000_0001].EDX bits must match the bits on * CPUID[1].EDX. */ Signature · 1 line
2.4.4
Re: [Qemu-devel] [PATCH 2/2] target-i386: automatically raise cpuid level to 0xd
Quoted 8 lines · Bandan Das
Quoted 3 lines · Eduardo Habkost
Quoted 2 lines · Radim Krčmář
We already bump to level 7 if features there are requested, so do the same for
0xD.But doesn't bumping to 7 for feat[ebx] have the potential to break ABI too ?
It's not the auto-bumping that breaks ABI, but having older machine-types now exposing different CPUID data to guests after applying the patch.
The auto-bump to 7 was introduced at the same time we introduced the first CPUID[7] features, so you couldn't have any running machines that would break.
Signature · 1 line
Eduardo
Re: [Qemu-devel] [PATCH 2/2] target-i386: automatically raise cpuid level to 0xd
In reply to Eduardo Habkost2015-06-18 12:50-0300, Eduardo Habkost:
Quoted 6 lines · Radim Krčmář
Quoted 4 lines
We already bump to level 7 if features there are requested, so do the same for
0xD.Signed-off-by Radim Krčmář <[email protected]>
Quoted 7 lines
This breaks guest ABI and live-migration, as CPUID data is not part of the migration stream (although we have considered including it in the future).
If we are going to add more special cases like this, we must provide a way to make QEMU honour an explicit "level" option from the config file or command-line.
Thanks, I'll drop this patch.
Quoted 6 lines
I have considered introducing "min-[x]level" and "max-{x]level" properties to control automatic increasing of level/xlevel. The existing X86CPUDefinition.level field could just control
min_level, while explicit "level=" on the command-line or config file would explicitly force a specific value. Probably setting "max-level" on machine-type compat code would be enough to restore the previous behavior.
We'd need to set min-level at least to 7, to capture the raising we do now, but a feature in level between default and 7 would result in a different behavior, so we need to make it much uglier :/
We can add 'compat-level' bit for old machine types and raise to highest habited function otherwise, optionally with controls you described.
Re: [Qemu-devel] [PATCH 2/2] target-i386: automatically raise cpuid level to 0xd
2015-06-19 11:47+0200, Radim Krčmář:
Quoted 9 lines
2015-06-18 12:50-0300, Eduardo Habkost:
Quoted 6 lines
I have considered introducing "min-[x]level" and "max-{x]level" properties to control automatic increasing of level/xlevel. The existing X86CPUDefinition.level field could just control
min_level, while explicit "level=" on the command-line or config file would explicitly force a specific value. Probably setting "max-level" on machine-type compat code would be enough to restore the previous behavior.We'd need to set min-level at least to 7, to capture the raising we do
^^^^^^^^^
Should have been max-level.
(The alcohol level doesn't drop fast enough.)
Quoted 4 lines
now, but a feature in level between default and 7 would result in a different behavior, so we need to make it much uglier :/
We can add 'compat-level' bit for old machine types and raise to highest habited function otherwise, optionally with controls you described.
Re: [Qemu-devel] [PATCH 2/2] target-i386: automatically raise cpuid level to 0xd
In reply to Radim Krčmář2015-06-19 11:47+0200, Radim Krčmář:
Quoted 8 lines
2015-06-18 12:50-0300, Eduardo Habkost:
Quoted 6 lines
I have considered introducing "min-[x]level" and "max-{x]level" properties to control automatic increasing of level/xlevel. The existing X86CPUDefinition.level field could just control
min_level, while explicit "level=" on the command-line or config file would explicitly force a specific value. Probably setting "max-level" on machine-type compat code would be enough to restore the previous behavior.
Quoted 5 lines
We'd need to set min-level at least to 7, to capture the raising we do now, but a feature in level between default and 7 would result in a different behavior, so we need to make it much uglier :/
We can add 'compat-level' bit for old machine types and raise to highest habited function otherwise, optionally with controls you described.
No, features are only in 0x7 and 0xd, so the original solution is good.
(We should also be bumping the CPUID level when adding specific
features, e.g. to at least 0xB when x2apic is selected.)