Blame SOURCES/kvm-pc-Disable-RDTSCP-on-AMD-CPU-models.patch

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