render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
fbe740
From 0dd015e1aff1a56a4584824d1a97c9eacabf7f03 Mon Sep 17 00:00:00 2001
fbe740
Message-Id: <0dd015e1aff1a56a4584824d1a97c9eacabf7f03@dist-git>
9c6c51
From: Jiri Denemark <jdenemar@redhat.com>
9c6c51
Date: Fri, 27 Mar 2015 12:48:40 +0100
9c6c51
Subject: [PATCH] RHEL: Hack around changed Broadwell/Haswell CPUs
9c6c51
9c6c51
RHEL-only
9c6c51
9c6c51
Upstream tried to solve the change of Broadwell and Haswell CPUs by
9c6c51
removing rtm and hle features from the corresponding CPU models for new
9c6c51
machine types. Then they reverted this and introduced new *-noTSX models
9c6c51
instead. However, the original fix was backported to RHEL.
9c6c51
9c6c51
This patch makes sure Broadwell and Haswell will always contain rtm and
9c6c51
hle features regardless on RHEL version or machine type used.
9c6c51
9c6c51
https://bugzilla.redhat.com/show_bug.cgi?id=1199446
9c6c51
9c6c51
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9c6c51
---
fbe740
 src/qemu/qemu_command.c                       | 21 +++++++++++++++++++
9c6c51
 tests/qemuxml2argvdata/cpu-Haswell.args       |  2 +-
fbe740
 .../qemuxml2argvdata/cpu-host-model-cmt.args  |  2 +-
fbe740
 .../cpu-translation.x86_64-4.0.0.args         |  4 ++--
fbe740
 .../cpu-translation.x86_64-latest.args        |  4 ++--
fbe740
 tests/qemuxml2argvdata/cpu-tsc-frequency.args |  4 ++--
9c6c51
 tests/qemuxml2argvdata/q35-acpi-nouefi.args   |  2 +-
9c6c51
 tests/qemuxml2argvdata/q35-acpi-uefi.args     |  2 +-
9c6c51
 tests/qemuxml2argvdata/q35-noacpi-nouefi.args |  2 +-
fbe740
 9 files changed, 32 insertions(+), 11 deletions(-)
9c6c51
9c6c51
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
fbe740
index 904d2beab5..e10cc7fc74 100644
9c6c51
--- a/src/qemu/qemu_command.c
9c6c51
+++ b/src/qemu/qemu_command.c
fbe740
@@ -6469,6 +6469,8 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
fbe740
 {
9c6c51
     size_t i;
9c6c51
     virCPUDefPtr cpu = def->cpu;
9c6c51
+    bool hle = false;
9c6c51
+    bool rtm = false;
9c6c51
 
fbe740
     switch ((virCPUMode) cpu->mode) {
fbe740
     case VIR_CPU_MODE_HOST_PASSTHROUGH:
fbe740
@@ -6524,6 +6526,11 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
9c6c51
         virBufferAsprintf(buf, ",vendor=%s", cpu->vendor_id);
9c6c51
 
9c6c51
     for (i = 0; i < cpu->nfeatures; i++) {
9c6c51
+        if (STREQ("rtm", cpu->features[i].name))
9c6c51
+            rtm = true;
9c6c51
+        if (STREQ("hle", cpu->features[i].name))
9c6c51
+            hle = true;
9c6c51
+
9c6c51
         switch ((virCPUFeaturePolicy) cpu->features[i].policy) {
9c6c51
         case VIR_CPU_FEATURE_FORCE:
9c6c51
         case VIR_CPU_FEATURE_REQUIRE:
fbe740
@@ -6541,6 +6548,20 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
9c6c51
         }
9c6c51
     }
9c6c51
 
9c6c51
+    /* Some versions of qemu-kvm in RHEL provide Broadwell and Haswell CPU
9c6c51
+     * models which lack rtm and hle features when used with some machine
9c6c51
+     * types. Let's make sure Broadwell and Haswell will always have these
9c6c51
+     * features. But only if the features were not explicitly mentioned in
9c6c51
+     * the guest CPU definition.
9c6c51
+     */
9c6c51
+    if (STREQ_NULLABLE(cpu->model, "Broadwell") ||
9c6c51
+        STREQ_NULLABLE(cpu->model, "Haswell")) {
fbe740
+        if (!rtm)
fbe740
+            qemuBuildCpuFeature(qemuCaps, buf, "rtm", true);
fbe740
+        if (!hle)
fbe740
+            qemuBuildCpuFeature(qemuCaps, buf, "hle", true);
9c6c51
+    }
9c6c51
+
fbe740
     return 0;
fbe740
 }
fbe740
 
9c6c51
diff --git a/tests/qemuxml2argvdata/cpu-Haswell.args b/tests/qemuxml2argvdata/cpu-Haswell.args
fbe740
index a33b16f7ce..d35de5ea58 100644
9c6c51
--- a/tests/qemuxml2argvdata/cpu-Haswell.args
9c6c51
+++ b/tests/qemuxml2argvdata/cpu-Haswell.args
fbe740
@@ -11,7 +11,7 @@ QEMU_AUDIO_DRV=none \
9c6c51
 -name QEMUGuest1 \
9c6c51
 -S \
9c6c51
 -machine pc,accel=kvm,usb=off,dump-guest-core=off \
9c6c51
--cpu Haswell \
9c6c51
+-cpu Haswell,+rtm,+hle \
9c6c51
 -m 214 \
fbe740
 -realtime mlock=off \
9c6c51
 -smp 6,sockets=6,cores=1,threads=1 \
9c6c51
diff --git a/tests/qemuxml2argvdata/cpu-host-model-cmt.args b/tests/qemuxml2argvdata/cpu-host-model-cmt.args
fbe740
index 42f969fd62..c8795acb3e 100644
9c6c51
--- a/tests/qemuxml2argvdata/cpu-host-model-cmt.args
9c6c51
+++ b/tests/qemuxml2argvdata/cpu-host-model-cmt.args
fbe740
@@ -12,7 +12,7 @@ QEMU_AUDIO_DRV=none \
9c6c51
 -S \
9c6c51
 -machine pc,accel=tcg,usb=off,dump-guest-core=off \
9c6c51
 -cpu Haswell,+vme,+ds,+acpi,+ss,+ht,+tm,+pbe,+dtes64,+monitor,+ds_cpl,+vmx,\
fbe740
-+smx,+est,+tm2,+xtpr,+pdcm,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm \
fbe740
++smx,+est,+tm2,+xtpr,+pdcm,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm,+rtm,+hle \
9c6c51
 -m 214 \
fbe740
 -realtime mlock=off \
9c6c51
 -smp 6,sockets=6,cores=1,threads=1 \
fbe740
diff --git a/tests/qemuxml2argvdata/cpu-translation.x86_64-4.0.0.args b/tests/qemuxml2argvdata/cpu-translation.x86_64-4.0.0.args
fbe740
index f8e19fca24..08c672fd2c 100644
fbe740
--- a/tests/qemuxml2argvdata/cpu-translation.x86_64-4.0.0.args
fbe740
+++ b/tests/qemuxml2argvdata/cpu-translation.x86_64-4.0.0.args
fbe740
@@ -14,8 +14,8 @@ QEMU_AUDIO_DRV=none \
fbe740
 file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
fbe740
 -machine pc-i440fx-4.0,accel=tcg,usb=off,dump-guest-core=off \
fbe740
 -cpu Haswell,pclmuldq=on,ds_cpl=on,tsc_adjust=on,fxsr_opt=on,lahf_lm=on,\
fbe740
-cmp_legacy=on,nodeid_msr=on,perfctr_core=on,perfctr_nb=on,kvm_pv_eoi=on,\
fbe740
-kvm_pv_unhalt=on \
fbe740
+cmp_legacy=on,nodeid_msr=on,perfctr_core=on,perfctr_nb=on,rtm=on,hle=on,\
fbe740
+kvm_pv_eoi=on,kvm_pv_unhalt=on \
fbe740
 -m 214 \
fbe740
 -overcommit mem-lock=off \
fbe740
 -smp 1,sockets=1,cores=1,threads=1 \
fbe740
diff --git a/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args b/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
fbe740
index 9322b826f4..1dbfc9553b 100644
fbe740
--- a/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
fbe740
+++ b/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
fbe740
@@ -14,8 +14,8 @@ QEMU_AUDIO_DRV=none \
fbe740
 file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
fbe740
 -machine pc,accel=tcg,usb=off,dump-guest-core=off \
fbe740
 -cpu Haswell,pclmulqdq=on,ds-cpl=on,tsc-adjust=on,fxsr-opt=on,lahf-lm=on,\
fbe740
-cmp-legacy=on,nodeid-msr=on,perfctr-core=on,perfctr-nb=on,kvm-pv-eoi=on,\
fbe740
-kvm-pv-unhalt=on \
fbe740
+cmp-legacy=on,nodeid-msr=on,perfctr-core=on,perfctr-nb=on,rtm=on,hle=on,\
fbe740
+kvm-pv-eoi=on,kvm-pv-unhalt=on \
fbe740
 -m 214 \
fbe740
 -overcommit mem-lock=off \
fbe740
 -smp 1,sockets=1,cores=1,threads=1 \
9c6c51
diff --git a/tests/qemuxml2argvdata/cpu-tsc-frequency.args b/tests/qemuxml2argvdata/cpu-tsc-frequency.args
fbe740
index 55b72b4404..45a777d468 100644
9c6c51
--- a/tests/qemuxml2argvdata/cpu-tsc-frequency.args
9c6c51
+++ b/tests/qemuxml2argvdata/cpu-tsc-frequency.args
fbe740
@@ -12,8 +12,8 @@ QEMU_AUDIO_DRV=none \
fbe740
 -S \
9c6c51
 -machine pc,accel=kvm,usb=off,dump-guest-core=off \
9c6c51
 -cpu Haswell,+vme,+ds,+acpi,+ss,+ht,+tm,+pbe,+dtes64,+monitor,+ds_cpl,+vmx,\
fbe740
-+smx,+est,+tm2,+xtpr,+pdcm,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm,+invtsc,\
fbe740
-tsc-frequency=3504000000 \
fbe740
++smx,+est,+tm2,+xtpr,+pdcm,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm,+invtsc,+rtm,\
fbe740
++hle,tsc-frequency=3504000000 \
9c6c51
 -m 214 \
fbe740
 -realtime mlock=off \
9c6c51
 -smp 1,sockets=1,cores=1,threads=1 \
9c6c51
diff --git a/tests/qemuxml2argvdata/q35-acpi-nouefi.args b/tests/qemuxml2argvdata/q35-acpi-nouefi.args
fbe740
index 09e06c96ea..aed56fb1fc 100644
9c6c51
--- a/tests/qemuxml2argvdata/q35-acpi-nouefi.args
9c6c51
+++ b/tests/qemuxml2argvdata/q35-acpi-nouefi.args
fbe740
@@ -11,7 +11,7 @@ QEMU_AUDIO_DRV=none \
9c6c51
 -name guest \
9c6c51
 -S \
9c6c51
 -machine q35,accel=tcg,usb=off,dump-guest-core=off \
9c6c51
--cpu Haswell \
9c6c51
+-cpu Haswell,+rtm,+hle \
9c6c51
 -m 1024 \
fbe740
 -realtime mlock=off \
9c6c51
 -smp 1,sockets=1,cores=1,threads=1 \
9c6c51
diff --git a/tests/qemuxml2argvdata/q35-acpi-uefi.args b/tests/qemuxml2argvdata/q35-acpi-uefi.args
fbe740
index d00fe5bc1d..1f4bfe7f87 100644
9c6c51
--- a/tests/qemuxml2argvdata/q35-acpi-uefi.args
9c6c51
+++ b/tests/qemuxml2argvdata/q35-acpi-uefi.args
fbe740
@@ -11,7 +11,7 @@ QEMU_AUDIO_DRV=none \
9c6c51
 -name guest \
9c6c51
 -S \
9c6c51
 -machine q35,accel=tcg,usb=off,dump-guest-core=off \
9c6c51
--cpu Haswell \
9c6c51
+-cpu Haswell,+rtm,+hle \
9c6c51
 -drive file=/usr/share/OVMF/OVMF_CODE.fd,if=pflash,format=raw,unit=0,\
9c6c51
 readonly=on \
9c6c51
 -drive file=/var/lib/libvirt/qemu/nvram/guest_VARS.fd,if=pflash,format=raw,\
9c6c51
diff --git a/tests/qemuxml2argvdata/q35-noacpi-nouefi.args b/tests/qemuxml2argvdata/q35-noacpi-nouefi.args
fbe740
index de34dff1cf..ccea7f91f9 100644
9c6c51
--- a/tests/qemuxml2argvdata/q35-noacpi-nouefi.args
9c6c51
+++ b/tests/qemuxml2argvdata/q35-noacpi-nouefi.args
fbe740
@@ -11,7 +11,7 @@ QEMU_AUDIO_DRV=none \
9c6c51
 -name guest \
9c6c51
 -S \
9c6c51
 -machine q35,accel=tcg,usb=off,dump-guest-core=off \
9c6c51
--cpu Haswell \
9c6c51
+-cpu Haswell,+rtm,+hle \
9c6c51
 -m 1024 \
fbe740
 -realtime mlock=off \
9c6c51
 -smp 1,sockets=1,cores=1,threads=1 \
9c6c51
-- 
fbe740
2.25.0
9c6c51