0a122b
From 32c34876557574575cec036f09f7c826ccb4368a Mon Sep 17 00:00:00 2001
0a122b
From: Eduardo Habkost <ehabkost@redhat.com>
0a122b
Date: Mon, 27 Jan 2014 16:07:43 +0100
0a122b
Subject: [PATCH 21/22] pc: Disable RDTSCP on AMD CPU models
0a122b
0a122b
RH-Author: Eduardo Habkost <ehabkost@redhat.com>
0a122b
Message-id: <1390838863-11030-3-git-send-email-ehabkost@redhat.com>
0a122b
Patchwork-id: 56961
0a122b
O-Subject: [RHEL7 qemu-kvm PATCH v2 2/2] pc: Disable RDTSCP on AMD CPU models
0a122b
Bugzilla: 1056428
0a122b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
0a122b
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
0a122b
Bugzilla: 874400
0a122b
Upstream status: not applicable (see notes below)
0a122b
Brew scratch build: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=6953316
0a122b
0a122b
KVM can't expose RDTSCP to guests on AMD CPUs, so there's no point in
0a122b
having RDTSCP enabled on AMD CPU models.
0a122b
0a122b
About upstream status and rationale for making it RHEL-specific:
0a122b
0a122b
This is another case where independently from the upstream decision, we
0a122b
will want to add RHEL-specific code to fiddle with the CPU definitions.
0a122b
0a122b
TCG does support RDTSCP, so it makes sense for upstream to keep RDTSCP
0a122b
enabled on those CPU models. We, on the other hand, care about KVM and
0a122b
know libvirt doesn't use enforce mode yet (but should eventually use
0a122b
it), so it makes sense to disable RDTSCP on AMD models in RHEL.
0a122b
0a122b
(This will eventually be a problem for libvirt upstream, when it starts
0a122b
using or emulating "enforce" mode. I have added notes at:
0a122b
http://wiki.qemu.org/Features/CPUModels#Disabling_features_that_were_always_disabled_on_KVM )
0a122b
0a122b
Changes v1 -> v2:
0a122b
 * Fix typo: "phenon" -> "phenom"
0a122b
0a122b
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
0a122b
---
0a122b
 hw/i386/pc_piix.c | 14 ++++++++++++++
0a122b
 hw/i386/pc_q35.c  | 14 ++++++++++++++
0a122b
 2 files changed, 28 insertions(+)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 hw/i386/pc_piix.c |   14 ++++++++++++++
0a122b
 hw/i386/pc_q35.c  |   14 ++++++++++++++
0a122b
 2 files changed, 28 insertions(+), 0 deletions(-)
0a122b
0a122b
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
0a122b
index b918f69..aac920a 100644
0a122b
--- a/hw/i386/pc_piix.c
0a122b
+++ b/hw/i386/pc_piix.c
0a122b
@@ -760,6 +760,20 @@ static void pc_compat_rhel700(QEMUMachineInitArgs *args)
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
+    /* KVM can't expose RDTSCP on AMD CPUs, so there's no point in enabling it
0a122b
+     * on AMD CPU models.
0a122b
+     */
0a122b
+    x86_cpu_compat_set_features("phenom", FEAT_8000_0001_EDX, 0,
0a122b
+                                CPUID_EXT2_RDTSCP);
0a122b
+    x86_cpu_compat_set_features("Opteron_G2", FEAT_8000_0001_EDX, 0,
0a122b
+                                CPUID_EXT2_RDTSCP);
0a122b
+    x86_cpu_compat_set_features("Opteron_G3", FEAT_8000_0001_EDX, 0,
0a122b
+                                CPUID_EXT2_RDTSCP);
0a122b
+    x86_cpu_compat_set_features("Opteron_G4", FEAT_8000_0001_EDX, 0,
0a122b
+                                CPUID_EXT2_RDTSCP);
0a122b
+    x86_cpu_compat_set_features("Opteron_G5", FEAT_8000_0001_EDX, 0,
0a122b
+                                CPUID_EXT2_RDTSCP);
0a122b
 }
0a122b
 
0a122b
 static void pc_init_rhel700(QEMUMachineInitArgs *args)
0a122b
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
0a122b
index 1ac46be..1aa8bde 100644
0a122b
--- a/hw/i386/pc_q35.c
0a122b
+++ b/hw/i386/pc_q35.c
0a122b
@@ -283,6 +283,20 @@ static void pc_q35_compat_rhel700(QEMUMachineInitArgs *args)
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
+    /* KVM can't expose RDTSCP on AMD CPUs, so there's no point in enabling it
0a122b
+     * on AMD CPU models.
0a122b
+     */
0a122b
+    x86_cpu_compat_set_features("phenom", FEAT_8000_0001_EDX, 0,
0a122b
+                                CPUID_EXT2_RDTSCP);
0a122b
+    x86_cpu_compat_set_features("Opteron_G2", FEAT_8000_0001_EDX, 0,
0a122b
+                                CPUID_EXT2_RDTSCP);
0a122b
+    x86_cpu_compat_set_features("Opteron_G3", FEAT_8000_0001_EDX, 0,
0a122b
+                                CPUID_EXT2_RDTSCP);
0a122b
+    x86_cpu_compat_set_features("Opteron_G4", FEAT_8000_0001_EDX, 0,
0a122b
+                                CPUID_EXT2_RDTSCP);
0a122b
+    x86_cpu_compat_set_features("Opteron_G5", FEAT_8000_0001_EDX, 0,
0a122b
+                                CPUID_EXT2_RDTSCP);
0a122b
 }
0a122b
 
0a122b
 static void pc_q35_init_rhel700(QEMUMachineInitArgs *args)
0a122b
-- 
0a122b
1.7.1
0a122b