0a122b
From 1144c6fa17e7d3fca1e2940c8bd0da966c74e4c5 Mon Sep 17 00:00:00 2001
0a122b
From: Eduardo Habkost <ehabkost@redhat.com>
0a122b
Date: Mon, 20 Jan 2014 19:05:30 +0100
0a122b
Subject: [PATCH 33/34] pc: Enable x2apic by default on more recent CPU models (v2)
0a122b
0a122b
RH-Author: Eduardo Habkost <ehabkost@redhat.com>
0a122b
Message-id: <1390244730-31038-3-git-send-email-ehabkost@redhat.com>
0a122b
Patchwork-id: 56848
0a122b
O-Subject: [RHEL7 qemu-kvm PATCH 2/2] pc: Enable x2apic by default on more recent CPU models (v2)
0a122b
Bugzilla: 1049706
0a122b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
RH-Acked-by: Bandan Das <bsd@redhat.com>
0a122b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
0a122b
0a122b
Bugzilla: 1049706
0a122b
Brew scratch build: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=6900764
0a122b
Upstream status: not applicable (see notes below)
0a122b
0a122b
On RHEL-6 we already enabled x2apic by default on Conroe, Penryn,
0a122b
Nehalem, Westmere, SandyBridge, Haswell, Opteron_G{1,2,3}.
0a122b
0a122b
To not introduce performance regressions, this patch changes the rhel7
0a122b
machine-types to enable x2apic by default on all those models and also
0a122b
on Opteron_G{4,5}.
0a122b
0a122b
Quoting the patch I sent upstream[1]:
0a122b
0a122b
> Normally we try to keep the CPU model definitions as close as the real
0a122b
> CPUs as possible, but x2apic can be emulated by KVM without host CPU
0a122b
> support for x2apic, and it improves performance by reducing APIC access
0a122b
> overhead. x2apic emulation is available on KVM since 2009 (Linux
0a122b
> 2.6.32-rc1), there's no reason for not enabling x2apic by default when
0a122b
> running KVM.
0a122b
0a122b
Upstream status is "not applicable" because this patch touches only the
0a122b
rhel7-specific PC code. I am doing this because my plan is to enable
0a122b
x2apic by default even if upstream rejects my patch, and I want to get
0a122b
this done as soon as possible to get more testing exposure.
0a122b
0a122b
[1] A patch was submitted to change cpu.c to add x2apic to those CPU models
0a122b
    upstream, and can be seen at:
0a122b
    Message-Id: <1390228618-21663-1-git-send-email-ehabkost@redhat.com>
0a122b
    http://article.gmane.org/gmane.comp.emulators.qemu/251492
0a122b
0a122b
    The upstream patch is a resend. A similar patch was sent in
0a122b
    September 2013, was ACKed by Gleb, but was ignored by all
0a122b
    maintainers.
0a122b
0a122b
Changes v2:
0a122b
 * Use the new pc_compat_rhel*() functions
0a122b
 * Disable x2apic explicitly on Opteron_G{4,5} on pc_compat_rhel650()
0a122b
0a122b
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
0a122b
---
0a122b
 hw/i386/pc_piix.c | 12 ++++++++++++
0a122b
 hw/i386/pc_q35.c  | 10 ++++++++++
0a122b
 2 files changed, 22 insertions(+)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 hw/i386/pc_piix.c |   12 ++++++++++++
0a122b
 hw/i386/pc_q35.c  |   10 ++++++++++
0a122b
 2 files changed, 22 insertions(+), 0 deletions(-)
0a122b
0a122b
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
0a122b
index 769571c..663c9d5 100644
0a122b
--- a/hw/i386/pc_piix.c
0a122b
+++ b/hw/i386/pc_piix.c
0a122b
@@ -745,6 +745,16 @@ machine_init(pc_machine_init);
0a122b
 
0a122b
 static void pc_compat_rhel700(QEMUMachineInitArgs *args)
0a122b
 {
0a122b
+    x86_cpu_compat_set_features("Conroe", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
0a122b
+    x86_cpu_compat_set_features("Penryn", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
0a122b
+    x86_cpu_compat_set_features("Nehalem", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
0a122b
+    x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
0a122b
+    /* SandyBridge and Haswell already have x2apic enabled */
0a122b
+    x86_cpu_compat_set_features("Opteron_G1", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
0a122b
+    x86_cpu_compat_set_features("Opteron_G2", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
0a122b
+    x86_cpu_compat_set_features("Opteron_G3", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
0a122b
+    x86_cpu_compat_set_features("Opteron_G4", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
0a122b
+    x86_cpu_compat_set_features("Opteron_G5", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
0a122b
 }
0a122b
 
0a122b
 static void pc_init_rhel700(QEMUMachineInitArgs *args)
0a122b
@@ -899,6 +909,8 @@ static void pc_compat_rhel650(QEMUMachineInitArgs *args)
0a122b
     x86_cpu_compat_set_features("Opteron_G1", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
0a122b
     x86_cpu_compat_set_features("Opteron_G2", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
0a122b
     x86_cpu_compat_set_features("Opteron_G3", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
0a122b
+    x86_cpu_compat_set_features("Opteron_G4", FEAT_1_ECX, 0, CPUID_EXT_X2APIC);
0a122b
+    x86_cpu_compat_set_features("Opteron_G5", FEAT_1_ECX, 0, CPUID_EXT_X2APIC);
0a122b
 
0a122b
     x86_cpu_compat_set_features("phenom", FEAT_8000_0001_EDX,
0a122b
                                 0, CPUID_EXT2_RDTSCP);
0a122b
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
0a122b
index 0280a95..232c62d 100644
0a122b
--- a/hw/i386/pc_q35.c
0a122b
+++ b/hw/i386/pc_q35.c
0a122b
@@ -270,6 +270,16 @@ machine_init(pc_q35_machine_init);
0a122b
 
0a122b
 static void pc_q35_compat_rhel700(QEMUMachineInitArgs *args)
0a122b
 {
0a122b
+    x86_cpu_compat_set_features("Conroe", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
0a122b
+    x86_cpu_compat_set_features("Penryn", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
0a122b
+    x86_cpu_compat_set_features("Nehalem", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
0a122b
+    x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
0a122b
+    /* SandyBridge and Haswell already have x2apic enabled */
0a122b
+    x86_cpu_compat_set_features("Opteron_G1", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
0a122b
+    x86_cpu_compat_set_features("Opteron_G2", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
0a122b
+    x86_cpu_compat_set_features("Opteron_G3", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
0a122b
+    x86_cpu_compat_set_features("Opteron_G4", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
0a122b
+    x86_cpu_compat_set_features("Opteron_G5", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
0a122b
 }
0a122b
 
0a122b
 static void pc_q35_init_rhel700(QEMUMachineInitArgs *args)
0a122b
-- 
0a122b
1.7.1
0a122b