render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
d0f569
From 1d93a3944a200b7c955800faa598e0e11da098f8 Mon Sep 17 00:00:00 2001
d0f569
Message-Id: <1d93a3944a200b7c955800faa598e0e11da098f8@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
---
d0f569
 src/qemu/qemu_command.c                       | 22 +++++++++++++++++++
9c6c51
 tests/qemuxml2argvdata/cpu-Haswell.args       |  2 +-
fbe740
 .../qemuxml2argvdata/cpu-host-model-cmt.args  |  2 +-
d0f569
 .../cpu-translation.x86_64-4.0.0.args         |  2 +-
d0f569
 .../cpu-translation.x86_64-latest.args        |  2 +-
d0f569
 tests/qemuxml2argvdata/cpu-tsc-frequency.args |  2 +-
9c6c51
 tests/qemuxml2argvdata/q35-acpi-nouefi.args   |  2 +-
9c6c51
 tests/qemuxml2argvdata/q35-acpi-uefi.args     |  2 +-
9c6c51
 tests/qemuxml2argvdata/q35-noacpi-nouefi.args |  2 +-
d0f569
 9 files changed, 30 insertions(+), 8 deletions(-)
9c6c51
9c6c51
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
d0f569
index d822533ccb..6b4647a711 100644
9c6c51
--- a/src/qemu/qemu_command.c
9c6c51
+++ b/src/qemu/qemu_command.c
d0f569
@@ -6521,6 +6521,8 @@ qemuBuildCpuModelArgStr(virQEMUDriver *driver,
fbe740
 {
9c6c51
     size_t i;
d0f569
     virCPUDef *cpu = def->cpu;
9c6c51
+    bool hle = false;
9c6c51
+    bool rtm = false;
9c6c51
 
fbe740
     switch ((virCPUMode) cpu->mode) {
fbe740
     case VIR_CPU_MODE_HOST_PASSTHROUGH:
d0f569
@@ -6587,6 +6589,12 @@ qemuBuildCpuModelArgStr(virQEMUDriver *driver,
9c6c51
     for (i = 0; i < cpu->nfeatures; i++) {
d0f569
         const char *featname =
d0f569
             virQEMUCapsCPUFeatureToQEMU(qemuCaps, cpu->features[i].name);
d0f569
+
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:
d0f569
@@ -6604,6 +6612,20 @@ qemuBuildCpuModelArgStr(virQEMUDriver *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)
d0f569
+            virBufferAddLit(buf, ",rtm=on");
fbe740
+        if (!hle)
d0f569
+            virBufferAddLit(buf, ",hle=on");
9c6c51
+    }
9c6c51
+
fbe740
     return 0;
fbe740
 }
fbe740
 
9c6c51
diff --git a/tests/qemuxml2argvdata/cpu-Haswell.args b/tests/qemuxml2argvdata/cpu-Haswell.args
d0f569
index b57fdfddc5..965274c1f0 100644
9c6c51
--- a/tests/qemuxml2argvdata/cpu-Haswell.args
9c6c51
+++ b/tests/qemuxml2argvdata/cpu-Haswell.args
d0f569
@@ -13,7 +13,7 @@ QEMU_AUDIO_DRV=none \
d0f569
 -object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
d0f569
 -machine pc,usb=off,dump-guest-core=off \
d0f569
 -accel kvm \
9c6c51
--cpu Haswell \
d0f569
+-cpu Haswell,rtm=on,hle=on \
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
d0f569
index 0de04e877d..602f70de86 100644
9c6c51
--- a/tests/qemuxml2argvdata/cpu-host-model-cmt.args
9c6c51
+++ b/tests/qemuxml2argvdata/cpu-host-model-cmt.args
d0f569
@@ -13,7 +13,7 @@ QEMU_AUDIO_DRV=none \
d0f569
 -object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
d0f569
 -machine pc,usb=off,dump-guest-core=off \
d0f569
 -accel tcg \
d0f569
--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 \
d0f569
+-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 \
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
d0f569
index 09141106d5..ace08d5d76 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
d0f569
@@ -13,7 +13,7 @@ QEMU_AUDIO_DRV=none \
d0f569
 -object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
d0f569
 -machine pc-i440fx-4.0,usb=off,dump-guest-core=off \
d0f569
 -accel tcg \
d0f569
--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 \
d0f569
+-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 \
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
d0f569
index 2dab572a6b..a9f7c4b910 100644
fbe740
--- a/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
fbe740
+++ b/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
d0f569
@@ -12,7 +12,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
d0f569
 -object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-QEMUGuest1/master-key.aes"}' \
d0f569
 -machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram \
d0f569
 -accel tcg \
d0f569
--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 \
d0f569
+-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 \
fbe740
 -m 214 \
d0f569
 -object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \
fbe740
 -overcommit mem-lock=off \
9c6c51
diff --git a/tests/qemuxml2argvdata/cpu-tsc-frequency.args b/tests/qemuxml2argvdata/cpu-tsc-frequency.args
d0f569
index 4a032f5d85..48fb75abcc 100644
9c6c51
--- a/tests/qemuxml2argvdata/cpu-tsc-frequency.args
9c6c51
+++ b/tests/qemuxml2argvdata/cpu-tsc-frequency.args
d0f569
@@ -13,7 +13,7 @@ QEMU_AUDIO_DRV=none \
d0f569
 -object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
d0f569
 -machine pc,usb=off,dump-guest-core=off \
d0f569
 -accel kvm \
d0f569
--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 \
d0f569
+-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 \
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
d0f569
index 3faee48c77..a1f742712d 100644
9c6c51
--- a/tests/qemuxml2argvdata/q35-acpi-nouefi.args
9c6c51
+++ b/tests/qemuxml2argvdata/q35-acpi-nouefi.args
d0f569
@@ -13,7 +13,7 @@ QEMU_AUDIO_DRV=none \
d0f569
 -object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-guest/master-key.aes \
d0f569
 -machine q35,usb=off,dump-guest-core=off \
d0f569
 -accel tcg \
9c6c51
--cpu Haswell \
d0f569
+-cpu Haswell,rtm=on,hle=on \
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
d0f569
index 60da1e282a..620056223a 100644
9c6c51
--- a/tests/qemuxml2argvdata/q35-acpi-uefi.args
9c6c51
+++ b/tests/qemuxml2argvdata/q35-acpi-uefi.args
d0f569
@@ -13,7 +13,7 @@ QEMU_AUDIO_DRV=none \
d0f569
 -object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-guest/master-key.aes \
d0f569
 -machine q35,usb=off,dump-guest-core=off \
d0f569
 -accel tcg \
9c6c51
--cpu Haswell \
d0f569
+-cpu Haswell,rtm=on,hle=on \
d0f569
 -drive file=/usr/share/OVMF/OVMF_CODE.fd,if=pflash,format=raw,unit=0,readonly=on \
d0f569
 -drive file=/var/lib/libvirt/qemu/nvram/guest_VARS.fd,if=pflash,format=raw,unit=1 \
d0f569
 -m 1024 \
9c6c51
diff --git a/tests/qemuxml2argvdata/q35-noacpi-nouefi.args b/tests/qemuxml2argvdata/q35-noacpi-nouefi.args
d0f569
index 14e5bbc22a..ea66536c2a 100644
9c6c51
--- a/tests/qemuxml2argvdata/q35-noacpi-nouefi.args
9c6c51
+++ b/tests/qemuxml2argvdata/q35-noacpi-nouefi.args
d0f569
@@ -13,7 +13,7 @@ QEMU_AUDIO_DRV=none \
d0f569
 -object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-guest/master-key.aes \
d0f569
 -machine q35,usb=off,dump-guest-core=off \
d0f569
 -accel tcg \
9c6c51
--cpu Haswell \
d0f569
+-cpu Haswell,rtm=on,hle=on \
9c6c51
 -m 1024 \
fbe740
 -realtime mlock=off \
9c6c51
 -smp 1,sockets=1,cores=1,threads=1 \
9c6c51
-- 
d0f569
2.34.1
9c6c51