Blame SOURCES/kvm-spapr-Correct-compatibility-mode-setting-for-hotplug.patch

9bac43
From 4d5b8f8fecbbf460f8c2f789784542e2d0e1fd20 Mon Sep 17 00:00:00 2001
9bac43
From: David Gibson <dgibson@redhat.com>
9bac43
Date: Fri, 12 Jan 2018 03:43:33 +0100
9bac43
Subject: [PATCH 06/12] spapr: Correct compatibility mode setting for
9bac43
 hotplugged CPUs
9bac43
9bac43
RH-Author: David Gibson <dgibson@redhat.com>
9bac43
Message-id: <20180112034333.5242-1-dgibson@redhat.com>
9bac43
Patchwork-id: 78556
9bac43
O-Subject: [RHEL-7.5 qemu-kvm-rhev PATCH] spapr: Correct compatibility mode setting for hotplugged CPUs
9bac43
Bugzilla: 1528234
9bac43
RH-Acked-by: Thomas Huth <thuth@redhat.com>
9bac43
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
9bac43
RH-Acked-by: Serhii Popovych <spopovyc@redhat.com>
9bac43
9bac43
From: David Gibson <david@gibson.dropbear.id.au>
9bac43
9bac43
Currently the pseries machine sets the compatibility mode for the
9bac43
guest's cpus in two places: 1) at machine reset and 2) after CAS
9bac43
negotiation.
9bac43
9bac43
This means that if we set or negotiate a compatiblity mode, then
9bac43
hotplug a cpu, the hotplugged cpu doesn't get the right mode set and
9bac43
will incorrectly have the full native features.
9bac43
9bac43
To correct this, we set the compatibility mode on a cpu when it is
9bac43
brought online with the 'start-cpu' RTAS call.  Given that we no
9bac43
longer need to set the compatibility mode on all CPUs at machine
9bac43
reset, so we change that to only set the mode for the boot cpu.
9bac43
9bac43
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
9bac43
Reported-by: Satheesh Rajendran <sathnaga@linux.vnet.ibm.com>
9bac43
Tested-by: Satheesh Rajendran <sathnaga@linux.vnet.ibm.com>
9bac43
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
9bac43
(cherry picked from commit 51f84465dd985fc21589b2eac1f18658fc9783e9)
9bac43
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9bac43
9bac43
Conflicts:
9bac43
	hw/ppc/spapr_rtas.c
9bac43
9bac43
Minor contextual conflict.
9bac43
9bac43
Signed-off-by: David Gibson <dgibson@redhat.com>
9bac43
---
9bac43
 hw/ppc/spapr.c      | 2 +-
9bac43
 hw/ppc/spapr_rtas.c | 9 +++++++++
9bac43
 2 files changed, 10 insertions(+), 1 deletion(-)
9bac43
9bac43
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
9bac43
index e276632..cdc56f3 100644
9bac43
--- a/hw/ppc/spapr.c
9bac43
+++ b/hw/ppc/spapr.c
9bac43
@@ -1462,7 +1462,7 @@ static void ppc_spapr_reset(void)
9bac43
         spapr_ovec_cleanup(spapr->ov5_cas);
9bac43
         spapr->ov5_cas = spapr_ovec_new();
9bac43
 
9bac43
-        ppc_set_compat_all(spapr->max_compat_pvr, &error_fatal);
9bac43
+        ppc_set_compat(first_ppc_cpu, spapr->max_compat_pvr, &error_fatal);
9bac43
     }
9bac43
 
9bac43
     fdt = spapr_build_fdt(spapr, rtas_addr, spapr->rtas_size);
9bac43
diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c
9bac43
index 94a2799..93f09a0 100644
9bac43
--- a/hw/ppc/spapr_rtas.c
9bac43
+++ b/hw/ppc/spapr_rtas.c
9bac43
@@ -162,6 +162,7 @@ static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPRMachineState *spapr,
9bac43
     if (cpu != NULL) {
9bac43
         CPUState *cs = CPU(cpu);
9bac43
         CPUPPCState *env = &cpu->env;
9bac43
+        Error *local_err = NULL;
9bac43
 
9bac43
         if (!cs->halted) {
9bac43
             rtas_st(rets, 0, RTAS_OUT_HW_ERROR);
9bac43
@@ -173,6 +174,14 @@ static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPRMachineState *spapr,
9bac43
          * new cpu enters */
9bac43
         kvm_cpu_synchronize_state(cs);
9bac43
 
9bac43
+        /* Set compatibility mode to match existing cpus */
9bac43
+        ppc_set_compat(cpu, POWERPC_CPU(first_cpu)->compat_pvr, &local_err);
9bac43
+        if (local_err) {
9bac43
+            error_report_err(local_err);
9bac43
+            rtas_st(rets, 0, RTAS_OUT_HW_ERROR);
9bac43
+            return;
9bac43
+        }
9bac43
+
9bac43
         env->msr = (1ULL << MSR_SF) | (1ULL << MSR_ME);
9bac43
         env->nip = start;
9bac43
         env->gpr[3] = r3;
9bac43
-- 
9bac43
1.8.3.1
9bac43