1b87cf
From 1d93a3944a200b7c955800faa598e0e11da098f8 Mon Sep 17 00:00:00 2001
1b87cf
Message-Id: <1d93a3944a200b7c955800faa598e0e11da098f8@dist-git>
edecca
From: Jiri Denemark <jdenemar@redhat.com>
edecca
Date: Fri, 27 Mar 2015 12:48:40 +0100
edecca
Subject: [PATCH] RHEL: Hack around changed Broadwell/Haswell CPUs
edecca
edecca
RHEL-only
edecca
edecca
Upstream tried to solve the change of Broadwell and Haswell CPUs by
edecca
removing rtm and hle features from the corresponding CPU models for new
edecca
machine types. Then they reverted this and introduced new *-noTSX models
edecca
instead. However, the original fix was backported to RHEL.
edecca
edecca
This patch makes sure Broadwell and Haswell will always contain rtm and
edecca
hle features regardless on RHEL version or machine type used.
edecca
edecca
https://bugzilla.redhat.com/show_bug.cgi?id=1199446
edecca
edecca
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
edecca
---
1b87cf
 src/qemu/qemu_command.c                       | 22 +++++++++++++++++++
edecca
 tests/qemuxml2argvdata/cpu-Haswell.args       |  2 +-
a41c76
 .../qemuxml2argvdata/cpu-host-model-cmt.args  |  2 +-
1b87cf
 .../cpu-translation.x86_64-4.0.0.args         |  2 +-
1b87cf
 .../cpu-translation.x86_64-latest.args        |  2 +-
1b87cf
 tests/qemuxml2argvdata/cpu-tsc-frequency.args |  2 +-
edecca
 tests/qemuxml2argvdata/q35-acpi-nouefi.args   |  2 +-
edecca
 tests/qemuxml2argvdata/q35-acpi-uefi.args     |  2 +-
edecca
 tests/qemuxml2argvdata/q35-noacpi-nouefi.args |  2 +-
1b87cf
 9 files changed, 30 insertions(+), 8 deletions(-)
edecca
edecca
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
1b87cf
index d822533ccb..6b4647a711 100644
edecca
--- a/src/qemu/qemu_command.c
edecca
+++ b/src/qemu/qemu_command.c
1b87cf
@@ -6521,6 +6521,8 @@ qemuBuildCpuModelArgStr(virQEMUDriver *driver,
a41c76
 {
edecca
     size_t i;
1b87cf
     virCPUDef *cpu = def->cpu;
edecca
+    bool hle = false;
edecca
+    bool rtm = false;
edecca
 
a41c76
     switch ((virCPUMode) cpu->mode) {
a41c76
     case VIR_CPU_MODE_HOST_PASSTHROUGH:
1b87cf
@@ -6587,6 +6589,12 @@ qemuBuildCpuModelArgStr(virQEMUDriver *driver,
edecca
     for (i = 0; i < cpu->nfeatures; i++) {
1b87cf
         const char *featname =
1b87cf
             virQEMUCapsCPUFeatureToQEMU(qemuCaps, cpu->features[i].name);
1b87cf
+
edecca
+        if (STREQ("rtm", cpu->features[i].name))
edecca
+            rtm = true;
edecca
+        if (STREQ("hle", cpu->features[i].name))
edecca
+            hle = true;
edecca
+
edecca
         switch ((virCPUFeaturePolicy) cpu->features[i].policy) {
edecca
         case VIR_CPU_FEATURE_FORCE:
edecca
         case VIR_CPU_FEATURE_REQUIRE:
1b87cf
@@ -6604,6 +6612,20 @@ qemuBuildCpuModelArgStr(virQEMUDriver *driver,
edecca
         }
edecca
     }
edecca
 
edecca
+    /* Some versions of qemu-kvm in RHEL provide Broadwell and Haswell CPU
edecca
+     * models which lack rtm and hle features when used with some machine
edecca
+     * types. Let's make sure Broadwell and Haswell will always have these
edecca
+     * features. But only if the features were not explicitly mentioned in
edecca
+     * the guest CPU definition.
edecca
+     */
edecca
+    if (STREQ_NULLABLE(cpu->model, "Broadwell") ||
edecca
+        STREQ_NULLABLE(cpu->model, "Haswell")) {
a41c76
+        if (!rtm)
1b87cf
+            virBufferAddLit(buf, ",rtm=on");
a41c76
+        if (!hle)
1b87cf
+            virBufferAddLit(buf, ",hle=on");
edecca
+    }
edecca
+
a41c76
     return 0;
a41c76
 }
a41c76
 
edecca
diff --git a/tests/qemuxml2argvdata/cpu-Haswell.args b/tests/qemuxml2argvdata/cpu-Haswell.args
1b87cf
index b57fdfddc5..965274c1f0 100644
edecca
--- a/tests/qemuxml2argvdata/cpu-Haswell.args
edecca
+++ b/tests/qemuxml2argvdata/cpu-Haswell.args
1b87cf
@@ -13,7 +13,7 @@ QEMU_AUDIO_DRV=none \
1b87cf
 -object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
1b87cf
 -machine pc,usb=off,dump-guest-core=off \
1b87cf
 -accel kvm \
edecca
--cpu Haswell \
1b87cf
+-cpu Haswell,rtm=on,hle=on \
edecca
 -m 214 \
a41c76
 -realtime mlock=off \
edecca
 -smp 6,sockets=6,cores=1,threads=1 \
edecca
diff --git a/tests/qemuxml2argvdata/cpu-host-model-cmt.args b/tests/qemuxml2argvdata/cpu-host-model-cmt.args
1b87cf
index 0de04e877d..602f70de86 100644
edecca
--- a/tests/qemuxml2argvdata/cpu-host-model-cmt.args
edecca
+++ b/tests/qemuxml2argvdata/cpu-host-model-cmt.args
1b87cf
@@ -13,7 +13,7 @@ QEMU_AUDIO_DRV=none \
1b87cf
 -object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
1b87cf
 -machine pc,usb=off,dump-guest-core=off \
1b87cf
 -accel tcg \
1b87cf
--cpu Haswell,vme=on,ds=on,acpi=on,ss=on,ht=on,tm=on,pbe=on,dtes64=on,monitor=on,ds-cpl=on,vmx=on,smx=on,est=on,tm2=on,xtpr=on,pdcm=on,f16c=on,rdrand=on,pdpe1gb=on,abm=on,lahf-lm=on \
1b87cf
+-cpu Haswell,vme=on,ds=on,acpi=on,ss=on,ht=on,tm=on,pbe=on,dtes64=on,monitor=on,ds-cpl=on,vmx=on,smx=on,est=on,tm2=on,xtpr=on,pdcm=on,f16c=on,rdrand=on,pdpe1gb=on,abm=on,lahf-lm=on,rtm=on,hle=on \
edecca
 -m 214 \
a41c76
 -realtime mlock=off \
edecca
 -smp 6,sockets=6,cores=1,threads=1 \
a41c76
diff --git a/tests/qemuxml2argvdata/cpu-translation.x86_64-4.0.0.args b/tests/qemuxml2argvdata/cpu-translation.x86_64-4.0.0.args
1b87cf
index 09141106d5..ace08d5d76 100644
a41c76
--- a/tests/qemuxml2argvdata/cpu-translation.x86_64-4.0.0.args
a41c76
+++ b/tests/qemuxml2argvdata/cpu-translation.x86_64-4.0.0.args
1b87cf
@@ -13,7 +13,7 @@ QEMU_AUDIO_DRV=none \
1b87cf
 -object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
1b87cf
 -machine pc-i440fx-4.0,usb=off,dump-guest-core=off \
1b87cf
 -accel tcg \
1b87cf
--cpu Haswell,pclmulqdq=on,ds-cpl=on,tsc-adjust=on,fxsr-opt=on,lahf-lm=on,cmp-legacy=on,nodeid-msr=on,perfctr-core=on,perfctr-nb=on,kvm-pv-eoi=on,kvm-pv-unhalt=on \
1b87cf
+-cpu Haswell,pclmulqdq=on,ds-cpl=on,tsc-adjust=on,fxsr-opt=on,lahf-lm=on,cmp-legacy=on,nodeid-msr=on,perfctr-core=on,perfctr-nb=on,rtm=on,hle=on,kvm-pv-eoi=on,kvm-pv-unhalt=on \
a41c76
 -m 214 \
a41c76
 -overcommit mem-lock=off \
a41c76
 -smp 1,sockets=1,cores=1,threads=1 \
a41c76
diff --git a/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args b/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
1b87cf
index 2dab572a6b..a9f7c4b910 100644
a41c76
--- a/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
a41c76
+++ b/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
1b87cf
@@ -12,7 +12,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
1b87cf
 -object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-QEMUGuest1/master-key.aes"}' \
1b87cf
 -machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram \
1b87cf
 -accel tcg \
1b87cf
--cpu Haswell,pclmulqdq=on,ds-cpl=on,tsc-adjust=on,fxsr-opt=on,lahf-lm=on,cmp-legacy=on,nodeid-msr=on,perfctr-core=on,perfctr-nb=on,kvm-pv-eoi=on,kvm-pv-unhalt=on \
1b87cf
+-cpu Haswell,pclmulqdq=on,ds-cpl=on,tsc-adjust=on,fxsr-opt=on,lahf-lm=on,cmp-legacy=on,nodeid-msr=on,perfctr-core=on,perfctr-nb=on,rtm=on,hle=on,kvm-pv-eoi=on,kvm-pv-unhalt=on \
a41c76
 -m 214 \
1b87cf
 -object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \
a41c76
 -overcommit mem-lock=off \
edecca
diff --git a/tests/qemuxml2argvdata/cpu-tsc-frequency.args b/tests/qemuxml2argvdata/cpu-tsc-frequency.args
1b87cf
index 4a032f5d85..48fb75abcc 100644
edecca
--- a/tests/qemuxml2argvdata/cpu-tsc-frequency.args
edecca
+++ b/tests/qemuxml2argvdata/cpu-tsc-frequency.args
1b87cf
@@ -13,7 +13,7 @@ QEMU_AUDIO_DRV=none \
1b87cf
 -object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
1b87cf
 -machine pc,usb=off,dump-guest-core=off \
1b87cf
 -accel kvm \
1b87cf
--cpu Haswell,vme=on,ds=on,acpi=on,ss=on,ht=on,tm=on,pbe=on,dtes64=on,monitor=on,ds-cpl=on,vmx=on,smx=on,est=on,tm2=on,xtpr=on,pdcm=on,f16c=on,rdrand=on,pdpe1gb=on,abm=on,lahf-lm=on,invtsc=on,tsc-frequency=4567890000 \
1b87cf
+-cpu Haswell,vme=on,ds=on,acpi=on,ss=on,ht=on,tm=on,pbe=on,dtes64=on,monitor=on,ds-cpl=on,vmx=on,smx=on,est=on,tm2=on,xtpr=on,pdcm=on,f16c=on,rdrand=on,pdpe1gb=on,abm=on,lahf-lm=on,invtsc=on,rtm=on,hle=on,tsc-frequency=4567890000 \
edecca
 -m 214 \
a41c76
 -realtime mlock=off \
edecca
 -smp 1,sockets=1,cores=1,threads=1 \
edecca
diff --git a/tests/qemuxml2argvdata/q35-acpi-nouefi.args b/tests/qemuxml2argvdata/q35-acpi-nouefi.args
1b87cf
index 3faee48c77..a1f742712d 100644
edecca
--- a/tests/qemuxml2argvdata/q35-acpi-nouefi.args
edecca
+++ b/tests/qemuxml2argvdata/q35-acpi-nouefi.args
1b87cf
@@ -13,7 +13,7 @@ QEMU_AUDIO_DRV=none \
1b87cf
 -object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-guest/master-key.aes \
1b87cf
 -machine q35,usb=off,dump-guest-core=off \
1b87cf
 -accel tcg \
edecca
--cpu Haswell \
1b87cf
+-cpu Haswell,rtm=on,hle=on \
edecca
 -m 1024 \
a41c76
 -realtime mlock=off \
edecca
 -smp 1,sockets=1,cores=1,threads=1 \
edecca
diff --git a/tests/qemuxml2argvdata/q35-acpi-uefi.args b/tests/qemuxml2argvdata/q35-acpi-uefi.args
1b87cf
index 60da1e282a..620056223a 100644
edecca
--- a/tests/qemuxml2argvdata/q35-acpi-uefi.args
edecca
+++ b/tests/qemuxml2argvdata/q35-acpi-uefi.args
1b87cf
@@ -13,7 +13,7 @@ QEMU_AUDIO_DRV=none \
1b87cf
 -object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-guest/master-key.aes \
1b87cf
 -machine q35,usb=off,dump-guest-core=off \
1b87cf
 -accel tcg \
edecca
--cpu Haswell \
1b87cf
+-cpu Haswell,rtm=on,hle=on \
1b87cf
 -drive file=/usr/share/OVMF/OVMF_CODE.fd,if=pflash,format=raw,unit=0,readonly=on \
1b87cf
 -drive file=/var/lib/libvirt/qemu/nvram/guest_VARS.fd,if=pflash,format=raw,unit=1 \
1b87cf
 -m 1024 \
edecca
diff --git a/tests/qemuxml2argvdata/q35-noacpi-nouefi.args b/tests/qemuxml2argvdata/q35-noacpi-nouefi.args
1b87cf
index 14e5bbc22a..ea66536c2a 100644
edecca
--- a/tests/qemuxml2argvdata/q35-noacpi-nouefi.args
edecca
+++ b/tests/qemuxml2argvdata/q35-noacpi-nouefi.args
1b87cf
@@ -13,7 +13,7 @@ QEMU_AUDIO_DRV=none \
1b87cf
 -object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-guest/master-key.aes \
1b87cf
 -machine q35,usb=off,dump-guest-core=off \
1b87cf
 -accel tcg \
edecca
--cpu Haswell \
1b87cf
+-cpu Haswell,rtm=on,hle=on \
edecca
 -m 1024 \
a41c76
 -realtime mlock=off \
edecca
 -smp 1,sockets=1,cores=1,threads=1 \
edecca
-- 
1b87cf
2.34.1
edecca