render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
a41c76
From 0dd015e1aff1a56a4584824d1a97c9eacabf7f03 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <0dd015e1aff1a56a4584824d1a97c9eacabf7f03@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
---
a41c76
 src/qemu/qemu_command.c                       | 21 +++++++++++++++++++
edecca
 tests/qemuxml2argvdata/cpu-Haswell.args       |  2 +-
a41c76
 .../qemuxml2argvdata/cpu-host-model-cmt.args  |  2 +-
a41c76
 .../cpu-translation.x86_64-4.0.0.args         |  4 ++--
a41c76
 .../cpu-translation.x86_64-latest.args        |  4 ++--
a41c76
 tests/qemuxml2argvdata/cpu-tsc-frequency.args |  4 ++--
edecca
 tests/qemuxml2argvdata/q35-acpi-nouefi.args   |  2 +-
edecca
 tests/qemuxml2argvdata/q35-acpi-uefi.args     |  2 +-
edecca
 tests/qemuxml2argvdata/q35-noacpi-nouefi.args |  2 +-
a41c76
 9 files changed, 32 insertions(+), 11 deletions(-)
edecca
edecca
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
a41c76
index 904d2beab5..e10cc7fc74 100644
edecca
--- a/src/qemu/qemu_command.c
edecca
+++ b/src/qemu/qemu_command.c
a41c76
@@ -6469,6 +6469,8 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
a41c76
 {
edecca
     size_t i;
edecca
     virCPUDefPtr cpu = def->cpu;
edecca
+    bool hle = false;
edecca
+    bool rtm = false;
edecca
 
a41c76
     switch ((virCPUMode) cpu->mode) {
a41c76
     case VIR_CPU_MODE_HOST_PASSTHROUGH:
a41c76
@@ -6524,6 +6526,11 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
edecca
         virBufferAsprintf(buf, ",vendor=%s", cpu->vendor_id);
edecca
 
edecca
     for (i = 0; i < cpu->nfeatures; i++) {
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:
a41c76
@@ -6541,6 +6548,20 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr 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)
a41c76
+            qemuBuildCpuFeature(qemuCaps, buf, "rtm", true);
a41c76
+        if (!hle)
a41c76
+            qemuBuildCpuFeature(qemuCaps, buf, "hle", true);
edecca
+    }
edecca
+
a41c76
     return 0;
a41c76
 }
a41c76
 
edecca
diff --git a/tests/qemuxml2argvdata/cpu-Haswell.args b/tests/qemuxml2argvdata/cpu-Haswell.args
a41c76
index a33b16f7ce..d35de5ea58 100644
edecca
--- a/tests/qemuxml2argvdata/cpu-Haswell.args
edecca
+++ b/tests/qemuxml2argvdata/cpu-Haswell.args
a41c76
@@ -11,7 +11,7 @@ QEMU_AUDIO_DRV=none \
edecca
 -name QEMUGuest1 \
edecca
 -S \
edecca
 -machine pc,accel=kvm,usb=off,dump-guest-core=off \
edecca
--cpu Haswell \
edecca
+-cpu Haswell,+rtm,+hle \
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
a41c76
index 42f969fd62..c8795acb3e 100644
edecca
--- a/tests/qemuxml2argvdata/cpu-host-model-cmt.args
edecca
+++ b/tests/qemuxml2argvdata/cpu-host-model-cmt.args
a41c76
@@ -12,7 +12,7 @@ QEMU_AUDIO_DRV=none \
edecca
 -S \
edecca
 -machine pc,accel=tcg,usb=off,dump-guest-core=off \
edecca
 -cpu Haswell,+vme,+ds,+acpi,+ss,+ht,+tm,+pbe,+dtes64,+monitor,+ds_cpl,+vmx,\
a41c76
-+smx,+est,+tm2,+xtpr,+pdcm,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm \
a41c76
++smx,+est,+tm2,+xtpr,+pdcm,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm,+rtm,+hle \
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
a41c76
index f8e19fca24..08c672fd2c 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
a41c76
@@ -14,8 +14,8 @@ QEMU_AUDIO_DRV=none \
a41c76
 file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
a41c76
 -machine pc-i440fx-4.0,accel=tcg,usb=off,dump-guest-core=off \
a41c76
 -cpu Haswell,pclmuldq=on,ds_cpl=on,tsc_adjust=on,fxsr_opt=on,lahf_lm=on,\
a41c76
-cmp_legacy=on,nodeid_msr=on,perfctr_core=on,perfctr_nb=on,kvm_pv_eoi=on,\
a41c76
-kvm_pv_unhalt=on \
a41c76
+cmp_legacy=on,nodeid_msr=on,perfctr_core=on,perfctr_nb=on,rtm=on,hle=on,\
a41c76
+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
a41c76
index 9322b826f4..1dbfc9553b 100644
a41c76
--- a/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
a41c76
+++ b/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
a41c76
@@ -14,8 +14,8 @@ QEMU_AUDIO_DRV=none \
a41c76
 file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
a41c76
 -machine pc,accel=tcg,usb=off,dump-guest-core=off \
a41c76
 -cpu Haswell,pclmulqdq=on,ds-cpl=on,tsc-adjust=on,fxsr-opt=on,lahf-lm=on,\
a41c76
-cmp-legacy=on,nodeid-msr=on,perfctr-core=on,perfctr-nb=on,kvm-pv-eoi=on,\
a41c76
-kvm-pv-unhalt=on \
a41c76
+cmp-legacy=on,nodeid-msr=on,perfctr-core=on,perfctr-nb=on,rtm=on,hle=on,\
a41c76
+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 \
edecca
diff --git a/tests/qemuxml2argvdata/cpu-tsc-frequency.args b/tests/qemuxml2argvdata/cpu-tsc-frequency.args
a41c76
index 55b72b4404..45a777d468 100644
edecca
--- a/tests/qemuxml2argvdata/cpu-tsc-frequency.args
edecca
+++ b/tests/qemuxml2argvdata/cpu-tsc-frequency.args
a41c76
@@ -12,8 +12,8 @@ QEMU_AUDIO_DRV=none \
a41c76
 -S \
edecca
 -machine pc,accel=kvm,usb=off,dump-guest-core=off \
edecca
 -cpu Haswell,+vme,+ds,+acpi,+ss,+ht,+tm,+pbe,+dtes64,+monitor,+ds_cpl,+vmx,\
a41c76
-+smx,+est,+tm2,+xtpr,+pdcm,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm,+invtsc,\
a41c76
-tsc-frequency=3504000000 \
a41c76
++smx,+est,+tm2,+xtpr,+pdcm,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm,+invtsc,+rtm,\
a41c76
++hle,tsc-frequency=3504000000 \
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
a41c76
index 09e06c96ea..aed56fb1fc 100644
edecca
--- a/tests/qemuxml2argvdata/q35-acpi-nouefi.args
edecca
+++ b/tests/qemuxml2argvdata/q35-acpi-nouefi.args
a41c76
@@ -11,7 +11,7 @@ QEMU_AUDIO_DRV=none \
edecca
 -name guest \
edecca
 -S \
edecca
 -machine q35,accel=tcg,usb=off,dump-guest-core=off \
edecca
--cpu Haswell \
edecca
+-cpu Haswell,+rtm,+hle \
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
a41c76
index d00fe5bc1d..1f4bfe7f87 100644
edecca
--- a/tests/qemuxml2argvdata/q35-acpi-uefi.args
edecca
+++ b/tests/qemuxml2argvdata/q35-acpi-uefi.args
a41c76
@@ -11,7 +11,7 @@ QEMU_AUDIO_DRV=none \
edecca
 -name guest \
edecca
 -S \
edecca
 -machine q35,accel=tcg,usb=off,dump-guest-core=off \
edecca
--cpu Haswell \
edecca
+-cpu Haswell,+rtm,+hle \
edecca
 -drive file=/usr/share/OVMF/OVMF_CODE.fd,if=pflash,format=raw,unit=0,\
edecca
 readonly=on \
edecca
 -drive file=/var/lib/libvirt/qemu/nvram/guest_VARS.fd,if=pflash,format=raw,\
edecca
diff --git a/tests/qemuxml2argvdata/q35-noacpi-nouefi.args b/tests/qemuxml2argvdata/q35-noacpi-nouefi.args
a41c76
index de34dff1cf..ccea7f91f9 100644
edecca
--- a/tests/qemuxml2argvdata/q35-noacpi-nouefi.args
edecca
+++ b/tests/qemuxml2argvdata/q35-noacpi-nouefi.args
a41c76
@@ -11,7 +11,7 @@ QEMU_AUDIO_DRV=none \
edecca
 -name guest \
edecca
 -S \
edecca
 -machine q35,accel=tcg,usb=off,dump-guest-core=off \
edecca
--cpu Haswell \
edecca
+-cpu Haswell,+rtm,+hle \
edecca
 -m 1024 \
a41c76
 -realtime mlock=off \
edecca
 -smp 1,sockets=1,cores=1,threads=1 \
edecca
-- 
a41c76
2.25.0
edecca