Skip to contentSkip to conversation

target-i386: set model=6 on qemu64 & qemu32 CPU models

PATCH In review Eduardo Habkost 3 participants 6 messages Sep 10, 2013 – Sep 12, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-i386: set model=6 on qemu64 & qemu32 CPU models

There's no Intel CPU with family=6,model=2, and Linux and Windows guests disable SEP when seeing that combination due to Pentium Pro erratum #82.

In addition to just having SEP ignored by guests, Skype (and maybe other applications) runs sysenter directly without passing through ntdll on Windows, and crashes because Windows ignored the SEP CPUID bit.

So, having model > 2 is a better default on qemu64 and qemu32 for two
reasons: making SEP really available for guests, and avoiding crashing applications that work on bare metal.

model=3 would fix the problem, but it causes CPU enumeration problems for Windows guests[1]. So this patch sets model=6, that matches "Athlon (PM core)" on AMD and "P2 with on-die L2 cache" on Intel and it allows Windows to use all CPUs as well as fixing sysenter.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=508623

Cc Andrea Arcangeli <[email protected]>
---
 include/hw/i386/pc.h | 8 ++++++++
 target-i386/cpu.c    | 4 ++--
 2 files changed, 10 insertions(+), 2 deletions(-)
include/hw/i386/pc.h +8 -0
index 7fb04d8..195e962 100644
@@ -258,6 +258,14 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
             .driver = TYPE_X86_CPU,\
             .property = "pmu",\
             .value = "on",\
+        },{\
+            .driver   = "qemu64-" TYPE_X86_CPU,\
+            .property = "model",\
+            .value    = stringify(2),\
+        },{\
+            .driver   = "qemu32-" TYPE_X86_CPU,\
+            .property = "model",\
+            .value    = stringify(3),\
         }
 
 #define PC_COMPAT_1_4 \
target-i386/cpu.c +2 -2
index c36345e..36cfbce 100644
@@ -544,7 +544,7 @@ static x86_def_t builtin_x86_defs[] = {
         .level = 4,
         .vendor = CPUID_VENDOR_AMD,
         .family = 6,
-        .model = 2,
+        .model = 6,
         .stepping = 3,
         .features[FEAT_1_EDX] =
             PPRO_FEATURES |
@@ -647,7 +647,7 @@ static x86_def_t builtin_x86_defs[] = {
         .level = 4,
         .vendor = CPUID_VENDOR_INTEL,
         .family = 6,
-        .model = 3,
+        .model = 6,
         .stepping = 3,
         .features[FEAT_1_EDX] =
             PPRO_FEATURES,
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 58 lines · On Tue, 10 Sep 2013 17:48:59 -0300 Eduardo Habkost <[email protected]> wrote:

There's no Intel CPU with family=6,model=2, and Linux and Windows guests disable SEP when seeing that combination due to Pentium Pro erratum #82.

In addition to just having SEP ignored by guests, Skype (and maybe other applications) runs sysenter directly without passing through ntdll on Windows, and crashes because Windows ignored the SEP CPUID bit.

So, having model > 2 is a better default on qemu64 and qemu32 for two
reasons: making SEP really available for guests, and avoiding crashing applications that work on bare metal.

model=3 would fix the problem, but it causes CPU enumeration problems for Windows guests[1]. So this patch sets model=6, that matches "Athlon (PM core)" on AMD and "P2 with on-die L2 cache" on Intel and it allows Windows to use all CPUs as well as fixing sysenter.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=508623

Cc Andrea Arcangeli <[email protected]>
---
 include/hw/i386/pc.h | 8 ++++++++
 target-i386/cpu.c    | 4 ++--
 2 files changed, 10 insertions(+), 2 deletions(-)
include/hw/i386/pc.h +8 -0
index 7fb04d8..195e962 100644
@@ -258,6 +258,14 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
             .driver = TYPE_X86_CPU,\
             .property = "pmu",\
             .value = "on",\
+        },{\
+            .driver   = "qemu64-" TYPE_X86_CPU,\
+            .property = "model",\
+            .value    = stringify(2),\
+        },{\
+            .driver   = "qemu32-" TYPE_X86_CPU,\
+            .property = "model",\
+            .value    = stringify(3),\
         }
 
 #define PC_COMPAT_1_4 \
target-i386/cpu.c +1 -1
index c36345e..36cfbce 100644
@@ -544,7 +544,7 @@ static x86_def_t builtin_x86_defs[] = {
         .level = 4,
         .vendor = CPUID_VENDOR_AMD,
         .family = 6,
-        .model = 2,
+        .model = 6,
         .stepping = 3,
         .features[FEAT_1_EDX] =
             PPRO_FEATURES |

target-i386/cpu.c static x86_def_t builtin_x86_defs[] = { · line 653

Quoted 8 lines
target-i386/cpu.c +1 -1
@@ -647,7 +647,7 @@ static x86_def_t builtin_x86_defs[] = {
         .level = 4,
         .vendor = CPUID_VENDOR_INTEL,
         .family = 6,
-        .model = 3,
+        .model = 6,
         .stepping = 3,
         .features[FEAT_1_EDX] =
             PPRO_FEATURES,
#2 lore raw

Am 11.09.2013 10:22, schrieb Igor Mammedov:

Quoted 46 lines
Quoted 43 lines · On Tue, 10 Sep 2013 17:48:59 -0300 Eduardo Habkost <[email protected]> wrote:

There's no Intel CPU with family=6,model=2, and Linux and Windows guests disable SEP when seeing that combination due to Pentium Pro erratum #82.

In addition to just having SEP ignored by guests, Skype (and maybe other applications) runs sysenter directly without passing through ntdll on Windows, and crashes because Windows ignored the SEP CPUID bit.

So, having model > 2 is a better default on qemu64 and qemu32 for two
reasons: making SEP really available for guests, and avoiding crashing applications that work on bare metal.

model=3 would fix the problem, but it causes CPU enumeration problems for Windows guests[1]. So this patch sets model=6, that matches "Athlon (PM core)" on AMD and "P2 with on-die L2 cache" on Intel and it allows Windows to use all CPUs as well as fixing sysenter.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=508623

Cc Andrea Arcangeli <[email protected]>
---
 include/hw/i386/pc.h | 8 ++++++++
 target-i386/cpu.c    | 4 ++--
 2 files changed, 10 insertions(+), 2 deletions(-)
include/hw/i386/pc.h +8 -0
index 7fb04d8..195e962 100644
@@ -258,6 +258,14 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
             .driver = TYPE_X86_CPU,\
             .property = "pmu",\
             .value = "on",\
+        },{\
+            .driver   = "qemu64-" TYPE_X86_CPU,\
+            .property = "model",\
+            .value    = stringify(2),\
+        },{\
+            .driver   = "qemu32-" TYPE_X86_CPU,\
+            .property = "model",\
+            .value    = stringify(3),\
         }
 
Quoted 1 line

include/hw/i386/pc.h int e820_add_entry(uint64_t, uint64_t, uint32_t); · line 271

Quoted 1 line
include/hw/i386/pc.h +0 -0
 #define PC_COMPAT_1_4 \

Shouldn't this hunk be in PC_COMPAT_1_6 rather than alongside PMU, which I believe was for 1_5?

Andreas

Quoted 25 lines
Quoted 14 lines
target-i386/cpu.c +1 -1
index c36345e..36cfbce 100644
@@ -544,7 +544,7 @@ static x86_def_t builtin_x86_defs[] = {
         .level = 4,
         .vendor = CPUID_VENDOR_AMD,
         .family = 6,
-        .model = 2,
+        .model = 6,
         .stepping = 3,
         .features[FEAT_1_EDX] =
             PPRO_FEATURES |

target-i386/cpu.c static x86_def_t builtin_x86_defs[] = { · line 653

Quoted 8 lines
target-i386/cpu.c +1 -1
@@ -647,7 +647,7 @@ static x86_def_t builtin_x86_defs[] = {
         .level = 4,
         .vendor = CPUID_VENDOR_INTEL,
         .family = 6,
-        .model = 3,
+        .model = 6,
         .stepping = 3,
         .features[FEAT_1_EDX] =
             PPRO_FEATURES,
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#3 lore raw
Quoted 47 lines · On Wed, 11 Sep 2013 10:25:58 +0200 Andreas Färber <[email protected]> wrote:

Am 11.09.2013 10:22, schrieb Igor Mammedov:

Quoted 46 lines
Quoted 43 lines · On Tue, 10 Sep 2013 17:48:59 -0300 Eduardo Habkost <[email protected]> wrote:

There's no Intel CPU with family=6,model=2, and Linux and Windows guests disable SEP when seeing that combination due to Pentium Pro erratum #82.

In addition to just having SEP ignored by guests, Skype (and maybe other applications) runs sysenter directly without passing through ntdll on Windows, and crashes because Windows ignored the SEP CPUID bit.

So, having model > 2 is a better default on qemu64 and qemu32 for two
reasons: making SEP really available for guests, and avoiding crashing applications that work on bare metal.

model=3 would fix the problem, but it causes CPU enumeration problems for Windows guests[1]. So this patch sets model=6, that matches "Athlon (PM core)" on AMD and "P2 with on-die L2 cache" on Intel and it allows Windows to use all CPUs as well as fixing sysenter.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=508623

Cc Andrea Arcangeli <[email protected]>
---
 include/hw/i386/pc.h | 8 ++++++++
 target-i386/cpu.c    | 4 ++--
 2 files changed, 10 insertions(+), 2 deletions(-)
include/hw/i386/pc.h +8 -0
index 7fb04d8..195e962 100644
@@ -258,6 +258,14 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
             .driver = TYPE_X86_CPU,\
             .property = "pmu",\
             .value = "on",\
+        },{\
+            .driver   = "qemu64-" TYPE_X86_CPU,\
+            .property = "model",\
+            .value    = stringify(2),\
+        },{\
+            .driver   = "qemu32-" TYPE_X86_CPU,\
+            .property = "model",\
+            .value    = stringify(3),\
         }
 
Quoted 4 lines
Quoted 1 line

include/hw/i386/pc.h int e820_add_entry(uint64_t, uint64_t, uint32_t); · line 271

Quoted 1 line
include/hw/i386/pc.h +0 -0
 #define PC_COMPAT_1_4 \

Shouldn't this hunk be in PC_COMPAT_1_6 rather than alongside PMU, which I believe was for 1_5?

grr, you are right.
my reviewed-by stands, provided compats are moved to PC_COMPAT_1_6.

Quoted 29 lines

Andreas

Quoted 25 lines
Quoted 14 lines
target-i386/cpu.c +1 -1
index c36345e..36cfbce 100644
@@ -544,7 +544,7 @@ static x86_def_t builtin_x86_defs[] = {
         .level = 4,
         .vendor = CPUID_VENDOR_AMD,
         .family = 6,
-        .model = 2,
+        .model = 6,
         .stepping = 3,
         .features[FEAT_1_EDX] =
             PPRO_FEATURES |

target-i386/cpu.c static x86_def_t builtin_x86_defs[] = { · line 653

Quoted 8 lines
target-i386/cpu.c +1 -1
@@ -647,7 +647,7 @@ static x86_def_t builtin_x86_defs[] = {
         .level = 4,
         .vendor = CPUID_VENDOR_INTEL,
         .family = 6,
-        .model = 3,
+        .model = 6,
         .stepping = 3,
         .features[FEAT_1_EDX] =
             PPRO_FEATURES,
#4 lore raw

Am 11.09.2013 10:37, schrieb Igor Mammedov:

Quoted 50 lines
Quoted 47 lines · On Wed, 11 Sep 2013 10:25:58 +0200 Andreas Färber <[email protected]> wrote:

Am 11.09.2013 10:22, schrieb Igor Mammedov:

Quoted 46 lines
Quoted 43 lines · On Tue, 10 Sep 2013 17:48:59 -0300 Eduardo Habkost <[email protected]> wrote:

There's no Intel CPU with family=6,model=2, and Linux and Windows guests disable SEP when seeing that combination due to Pentium Pro erratum #82.

In addition to just having SEP ignored by guests, Skype (and maybe other applications) runs sysenter directly without passing through ntdll on Windows, and crashes because Windows ignored the SEP CPUID bit.

So, having model > 2 is a better default on qemu64 and qemu32 for two
reasons: making SEP really available for guests, and avoiding crashing applications that work on bare metal.

model=3 would fix the problem, but it causes CPU enumeration problems for Windows guests[1]. So this patch sets model=6, that matches "Athlon (PM core)" on AMD and "P2 with on-die L2 cache" on Intel and it allows Windows to use all CPUs as well as fixing sysenter.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=508623

Cc Andrea Arcangeli <[email protected]>
---
 include/hw/i386/pc.h | 8 ++++++++
 target-i386/cpu.c    | 4 ++--
 2 files changed, 10 insertions(+), 2 deletions(-)
include/hw/i386/pc.h +8 -0
index 7fb04d8..195e962 100644
@@ -258,6 +258,14 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
             .driver = TYPE_X86_CPU,\
             .property = "pmu",\
             .value = "on",\
+        },{\
+            .driver   = "qemu64-" TYPE_X86_CPU,\
+            .property = "model",\
+            .value    = stringify(2),\
+        },{\
+            .driver   = "qemu32-" TYPE_X86_CPU,\
+            .property = "model",\
+            .value    = stringify(3),\
         }
 
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

include/hw/i386/pc.h int e820_add_entry(uint64_t, uint64_t, uint32_t); · line 271

Quoted 1 line
include/hw/i386/pc.h +0 -0
 #define PC_COMPAT_1_4 \

Shouldn't this hunk be in PC_COMPAT_1_6 rather than alongside PMU, which I believe was for 1_5?

grr, you are right.
my reviewed-by stands, provided compats are moved to PC_COMPAT_1_6.

Fixed now that Stefan's net-next pull has been merged. Thanks, applied to qom-cpu:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu

Andreas

Quoted 32 lines
Quoted 31 lines

Andreas

Quoted 25 lines
Quoted 14 lines
target-i386/cpu.c +1 -1
index c36345e..36cfbce 100644
@@ -544,7 +544,7 @@ static x86_def_t builtin_x86_defs[] = {
         .level = 4,
         .vendor = CPUID_VENDOR_AMD,
         .family = 6,
-        .model = 2,
+        .model = 6,
         .stepping = 3,
         .features[FEAT_1_EDX] =
             PPRO_FEATURES |

target-i386/cpu.c static x86_def_t builtin_x86_defs[] = { · line 653

Quoted 8 lines
target-i386/cpu.c +1 -1
@@ -647,7 +647,7 @@ static x86_def_t builtin_x86_defs[] = {
         .level = 4,
         .vendor = CPUID_VENDOR_INTEL,
         .family = 6,
-        .model = 3,
+        .model = 6,
         .stepping = 3,
         .features[FEAT_1_EDX] =
             PPRO_FEATURES,
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#5 lore raw
Quoted 55 lines · Andreas Färber

Am 11.09.2013 10:37, schrieb Igor Mammedov:

Quoted 54 lines
Quoted 51 lines · On Wed, 11 Sep 2013 10:25:58 +0200 Andreas Färber <[email protected]> wrote:

Am 11.09.2013 10:22, schrieb Igor Mammedov:

Quoted 46 lines
Quoted 43 lines · On Tue, 10 Sep 2013 17:48:59 -0300 Eduardo Habkost <[email protected]> wrote:

There's no Intel CPU with family=6,model=2, and Linux and Windows guests disable SEP when seeing that combination due to Pentium Pro erratum #82.

In addition to just having SEP ignored by guests, Skype (and maybe other applications) runs sysenter directly without passing through ntdll on Windows, and crashes because Windows ignored the SEP CPUID bit.

So, having model > 2 is a better default on qemu64 and qemu32 for two
reasons: making SEP really available for guests, and avoiding crashing applications that work on bare metal.

model=3 would fix the problem, but it causes CPU enumeration problems for Windows guests[1]. So this patch sets model=6, that matches "Athlon (PM core)" on AMD and "P2 with on-die L2 cache" on Intel and it allows Windows to use all CPUs as well as fixing sysenter.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=508623

Cc Andrea Arcangeli <[email protected]>
---
 include/hw/i386/pc.h | 8 ++++++++
 target-i386/cpu.c    | 4 ++--
 2 files changed, 10 insertions(+), 2 deletions(-)
include/hw/i386/pc.h +8 -0
index 7fb04d8..195e962 100644
@@ -258,6 +258,14 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
             .driver = TYPE_X86_CPU,\
             .property = "pmu",\
             .value = "on",\
+        },{\
+            .driver   = "qemu64-" TYPE_X86_CPU,\
+            .property = "model",\
+            .value    = stringify(2),\
+        },{\
+            .driver   = "qemu32-" TYPE_X86_CPU,\
+            .property = "model",\
+            .value    = stringify(3),\
         }
 
Quoted 1 line

include/hw/i386/pc.h int e820_add_entry(uint64_t, uint64_t, uint32_t); · line 271

Quoted 1 line
include/hw/i386/pc.h +0 -0
 #define PC_COMPAT_1_4 \

Shouldn't this hunk be in PC_COMPAT_1_6 rather than alongside PMU, which I believe was for 1_5?

Quoted 6 lines
Quoted 2 lines

grr, you are right.
my reviewed-by stands, provided compats are moved to PC_COMPAT_1_6.

Fixed now that Stefan's net-next pull has been merged. Thanks, applied to qom-cpu:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu

Thanks for catching and fixing it, and sorry for the confusion.

Signature · 1 line
Eduardo