Blob Blame History Raw
From 9baf8dbaac5707b25f9126a5ba06716efe6793d5 Mon Sep 17 00:00:00 2001
From: Miroslav Rezanina <mrezanin@redhat.com>
Date: Thu, 17 Oct 2013 10:38:42 +0200
Subject: [PATCH 05/25] target-i386: Set model=6 on qemu64 & qemu32 CPU models
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Message-id: <1379363997-11783-2-git-send-email-ehabkost@redhat.com>
Patchwork-id: 54398
O-Subject: [RHEL7 PATCH 1/4] target-i386: Set model=6 on qemu64 & qemu32 CPU models
Bugzilla: 1004290
RH-Acked-by: Bandan Das <bsd@redhat.com>
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>

Bugzilla: 1004290
Upstream status: commit f8e6a11aecc96e9d8a84f17d7c07019471714e20.
Brew build: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=6290888

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 let's set 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 <aarcange@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
(cherry picked from commit 5cb6eb263d92972b54f84e0acf75e7159de20498)
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Conflicts:
	include/hw/i386/pc.h

Backport notes:
 * PC_COMPAT_1_6 does not exist on the RHEL-7 tree
 * RHEL-6 already have model=6 on qemu64 since RHEL-6.0, but not on
   qemu32, so PC_RHEL6_5_COMPAT includes only the qemu32 compat change

Maintainer's notes:
 * Cherry-picked from Andreas Färber's qom-cpu tree
 * Upstream status valid for qemu tree
---
 hw/i386/pc_piix.c | 4 ++++
 target-i386/cpu.c | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)
---
 hw/i386/pc_piix.c |    4 ++++
 target-i386/cpu.c |    4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index a19f155..39be127 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -861,6 +861,10 @@ static QEMUMachine pc_machine_rhel700 = {
         .property = "level",\
         .value = stringify(0),\
     },{\
+        .driver   = "qemu32-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(3),\
+    },{\
         .driver   = "usb-ccid",\
         .property = "serial",\
         .value    = "1",\
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index a0358c0..170a46c 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -434,7 +434,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 |
@@ -537,7 +537,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,
-- 
1.7.1