Commit 51f84465 authored by David Gibson's avatar David Gibson
Browse files

spapr: Correct compatibility mode setting for hotplugged CPUs



Currently the pseries machine sets the compatibility mode for the
guest's cpus in two places: 1) at machine reset and 2) after CAS
negotiation.

This means that if we set or negotiate a compatiblity mode, then
hotplug a cpu, the hotplugged cpu doesn't get the right mode set and
will incorrectly have the full native features.

To correct this, we set the compatibility mode on a cpu when it is
brought online with the 'start-cpu' RTAS call.  Given that we no
longer need to set the compatibility mode on all CPUs at machine
reset, so we change that to only set the mode for the boot cpu.

Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
Reported-by: default avatarSatheesh Rajendran <sathnaga@linux.vnet.ibm.com>
Tested-by: default avatarSatheesh Rajendran <sathnaga@linux.vnet.ibm.com>
Reviewed-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
parent a7167668
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1504,7 +1504,7 @@ static void spapr_machine_reset(void)
        spapr_ovec_cleanup(spapr->ov5_cas);
        spapr->ov5_cas = spapr_ovec_new();

        ppc_set_compat_all(spapr->max_compat_pvr, &error_fatal);
        ppc_set_compat(first_ppc_cpu, spapr->max_compat_pvr, &error_fatal);
    }

    fdt = spapr_build_fdt(spapr, rtas_addr, spapr->rtas_size);
+9 −0
Original line number Diff line number Diff line
@@ -163,6 +163,7 @@ static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPRMachineState *spapr,
        CPUState *cs = CPU(cpu);
        CPUPPCState *env = &cpu->env;
        PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
        Error *local_err = NULL;

        if (!cs->halted) {
            rtas_st(rets, 0, RTAS_OUT_HW_ERROR);
@@ -174,6 +175,14 @@ static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPRMachineState *spapr,
         * new cpu enters */
        kvm_cpu_synchronize_state(cs);

        /* Set compatibility mode to match existing cpus */
        ppc_set_compat(cpu, POWERPC_CPU(first_cpu)->compat_pvr, &local_err);
        if (local_err) {
            error_report_err(local_err);
            rtas_st(rets, 0, RTAS_OUT_HW_ERROR);
            return;
        }

        env->msr = (1ULL << MSR_SF) | (1ULL << MSR_ME);

        /* Enable Power-saving mode Exit Cause exceptions for the new CPU */