thebeanogamer / rpms / qemu-kvm

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