Blame SOURCES/kvm-ppc-fix-setting-of-compat-mode.patch

4a2fec
From 7f958a52f5e8e4dd02182b308c96d5bde25a1327 Mon Sep 17 00:00:00 2001
4a2fec
From: Suraj Jitindar Singh <sursingh@redhat.com>
4a2fec
Date: Wed, 6 Dec 2017 02:57:59 +0100
4a2fec
Subject: [PATCH 19/21] ppc: fix setting of compat mode
4a2fec
4a2fec
RH-Author: Suraj Jitindar Singh <sursingh@redhat.com>
4a2fec
Message-id: <1512529079-12590-1-git-send-email-sursingh@redhat.com>
4a2fec
Patchwork-id: 78173
4a2fec
O-Subject: [RHEL7.5 qemu-kvm-rhev PATCH] ppc: fix setting of compat mode
4a2fec
Bugzilla: 1396119
4a2fec
RH-Acked-by: David Gibson <dgibson@redhat.com>
4a2fec
RH-Acked-by: Thomas Huth <thuth@redhat.com>
4a2fec
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
4a2fec
4a2fec
From: Greg Kurz <groug@kaod.org>
4a2fec
4a2fec
While trying to make KVM PR usable again, commit 5dfaa532ae introduced a
4a2fec
regression: the current compat_pvr value is passed to KVM instead of the
4a2fec
new one. This means that we always pass 0 instead of the max-cpu-compat
4a2fec
PVR during the initial machine reset. And at CAS time, we either pass
4a2fec
the PVR from the command line or even don't call kvmppc_set_compat() at
4a2fec
all, ie, the PCR will not be set as expected.
4a2fec
4a2fec
For example if we start a big endian fedora26 guest in power7 compat
4a2fec
mode on a POWER8 host, we get this in the guest:
4a2fec
4a2fec
$ cat /proc/cpuinfo
4a2fec
processor       : 0
4a2fec
cpu             : POWER7 (architected), altivec supported
4a2fec
clock           : 4024.000000MHz
4a2fec
revision        : 2.0 (pvr 004d 0200)
4a2fec
4a2fec
timebase        : 512000000
4a2fec
platform        : pSeries
4a2fec
model           : IBM pSeries (emulated by qemu)
4a2fec
machine         : CHRP IBM pSeries (emulated by qemu)
4a2fec
MMU             : Hash
4a2fec
4a2fec
but the guest can still execute POWER8 instructions, and the following
4a2fec
program succeeds:
4a2fec
4a2fec
int main()
4a2fec
{
4a2fec
        asm("vncipher 0,0,0"); // ISA 2.07 instruction
4a2fec
}
4a2fec
4a2fec
Let's pass the new compat_pvr to kvmppc_set_compat() and the program fails
4a2fec
with SIGILL as expected.
4a2fec
4a2fec
Reported-by: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
4a2fec
Signed-off-by: Greg Kurz <groug@kaod.org>
4a2fec
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4a2fec
(cherry picked from commit e4f0c6bb1a9f72ad9e32c3171d36bae17ea1cd67)
4a2fec
4a2fec
Signed-off-by: Suraj Jitindar Singh <sursingh@redhat.com>
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 target/ppc/compat.c | 2 +-
4a2fec
 1 file changed, 1 insertion(+), 1 deletion(-)
4a2fec
4a2fec
diff --git a/target/ppc/compat.c b/target/ppc/compat.c
4a2fec
index 540b4eb..2d95434 100644
4a2fec
--- a/target/ppc/compat.c
4a2fec
+++ b/target/ppc/compat.c
4a2fec
@@ -152,7 +152,7 @@ void ppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr, Error **errp)
4a2fec
     cpu_synchronize_state(CPU(cpu));
4a2fec
 
4a2fec
     if (kvm_enabled() && cpu->compat_pvr != compat_pvr) {
4a2fec
-        int ret = kvmppc_set_compat(cpu, cpu->compat_pvr);
4a2fec
+        int ret = kvmppc_set_compat(cpu, compat_pvr);
4a2fec
         if (ret < 0) {
4a2fec
             error_setg_errno(errp, -ret,
4a2fec
                              "Unable to set CPU compatibility mode in KVM");
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec