From 4e88e2e52914d79879c5f753097f81caa0ffe8b8 Mon Sep 17 00:00:00 2001
Message-Id: <4e88e2e52914d79879c5f753097f81caa0ffe8b8.1349175436.git.minovotn@redhat.com>
In-Reply-To: <94968b7fa9b14e71f004474d7ce77e189e6a2bf3.1349175436.git.minovotn@redhat.com>
References: <94968b7fa9b14e71f004474d7ce77e189e6a2bf3.1349175436.git.minovotn@redhat.com>
From: Eduardo Habkost <ehabkost@redhat.com>
Date: Fri, 28 Sep 2012 16:50:23 +0200
Subject: [PATCH 18/34] set level=4 on CPU models Conroe, Penryn, Nehalem (v2)

RH-Author: Eduardo Habkost <ehabkost@redhat.com>
Message-id: <1348851023-31907-19-git-send-email-ehabkost@redhat.com>
Patchwork-id: 42517
O-Subject: [RHEL6 qemu-kvm PATCH 18/18] set level=4 on CPU models Conroe, Penryn, Nehalem (v2)
Bugzilla: 689665
RH-Acked-by: Alex Williamson <alex.williamson@redhat.com>
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>

Bugzilla: 689665
Upstream status: pending
 (The fix will be implemented upstream only after the qdev-based
 compatibility mechanism is finished)
RHEL7 regression BZ: https://bugzilla.redhat.com/show_bug.cgi?id=861209

This changes the "level" field of Conroe, Penry, and Nehalem CPU models
from 2 to 4. This has the effect of exposing the CPUID[EAX=4] leaf, that
contains CPU core/thread topology information. Without this, the -cpu
cores/threads topology specified on the command-line is not exposed
properly (e.g. a cores=2,threads=2 topology appears as a single-core,
with 4 threads).

To keep live-migration compatibility, machine-types rhel6.3.0 keep the
old level=2 values, using the new set_cpu_model_level() function.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Conflicts:
	hw/pc.c

Changes v1 -> v2:
 - Now, the compat calls need to be added only on pc_rhel630_compat(),
   as pc_rhel620_compat() kept the call to pc_rhel630_compat()

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/pc.c             | 3 +++
 target-i386/cpuid.c | 6 +++---
 2 files changed, 6 insertions(+), 3 deletions(-)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 hw/pc.c             | 3 +++
 target-i386/cpuid.c | 6 +++---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/hw/pc.c b/hw/pc.c
index ed83d72..9d7ebde 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1631,6 +1631,9 @@ static void rhel_common_init(const char *type1_version,
 
 static void pc_rhel630_compat(void)
 {
+    set_cpu_model_level("Conroe", 2);
+    set_cpu_model_level("Penryn", 2);
+    set_cpu_model_level("Nehalem", 2);
     disable_kvm_pv_eoi();
     set_pmu_passthrough(true);
     disable_tsc_deadline();
diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index 713da82..7aacdd1 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -470,7 +470,7 @@ static x86_def_t builtin_x86_defs[] = {
     },
     {
         .name = "Conroe",
-        .level = 2,
+        .level = 4,
         .vendor1 = CPUID_VENDOR_INTEL_1,
         .vendor2 = CPUID_VENDOR_INTEL_2,
         .vendor3 = CPUID_VENDOR_INTEL_3,
@@ -490,7 +490,7 @@ static x86_def_t builtin_x86_defs[] = {
     },
     {
         .name = "Penryn",
-        .level = 2,
+        .level = 4,
         .vendor1 = CPUID_VENDOR_INTEL_1,
         .vendor2 = CPUID_VENDOR_INTEL_2,
         .vendor3 = CPUID_VENDOR_INTEL_3,
@@ -511,7 +511,7 @@ static x86_def_t builtin_x86_defs[] = {
     },
     {
         .name = "Nehalem",
-        .level = 2,
+        .level = 4,
         .vendor1 = CPUID_VENDOR_INTEL_1,
         .vendor2 = CPUID_VENDOR_INTEL_2,
         .vendor3 = CPUID_VENDOR_INTEL_3,
-- 
1.7.11.4

