Received: from eggs.gnu.org ([2001:4830:134:3::10]:37426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aiwuM-0002IO-M2 for qemu-devel@nongnu.org; Thu, 24 Mar 2016 00:30:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aiwuD-00071W-5t for qemu-devel@nongnu.org; Thu, 24 Mar 2016 00:30:06 -0400 From: David Gibson Date: Thu, 24 Mar 2016 15:30:48 +1100 Message-Id: <1458793858-4010-7-git-send-email-david@gibson.dropbear.id.au> In-Reply-To: <1458793858-4010-1-git-send-email-david@gibson.dropbear.id.au> References: <1458793858-4010-1-git-send-email-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 06/16] ppc: Create cpu_ppc_set_papr() helper List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: peter.maydell@linaro.org Cc: thuth@redhat.com, agraf@suse.de, qemu-devel@nongnu.org, clg@fr.ibm.com, qemu-ppc@nongnu.org, David Gibson From: Benjamin Herrenschmidt And move the code adjusting the MSR mask and calling kvmppc_set_papr() to it. This allows us to add a few more things such as disabling setting of MSR:HV and appropriate LPCR bits which will be used when fixing the exception model. Signed-off-by: Benjamin Herrenschmidt Reviewed-by: David Gibson [clg: removed LPCR setting ] Signed-off-by: C=C3=A9dric Le Goater Signed-off-by: David Gibson --- hw/ppc/spapr.c | 11 ++--------- target-ppc/cpu.h | 1 + target-ppc/translate_init.c | 23 ++++++++++++++++++++++- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index d43d6d9..ebbc6fe 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1613,15 +1613,8 @@ static void spapr_cpu_init(sPAPRMachineState *spap= r, PowerPCCPU *cpu, /* Set time-base frequency to 512 MHz */ cpu_ppc_tb_init(env, TIMEBASE_FREQ); =20 - /* PAPR always has exception vectors in RAM not ROM. To ensure this, - * MSR[IP] should never be set. - */ - env->msr_mask &=3D ~(1 << 6); - - /* Tell KVM that we're in PAPR mode */ - if (kvm_enabled()) { - kvmppc_set_papr(cpu); - } + /* Enable PAPR mode in TCG or KVM */ + cpu_ppc_set_papr(cpu); =20 if (cpu->max_compat) { Error *local_err =3D NULL; diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h index 9ce301f..a7da0d3 100644 --- a/target-ppc/cpu.h +++ b/target-ppc/cpu.h @@ -1268,6 +1268,7 @@ void store_booke_tcr (CPUPPCState *env, target_ulon= g val); void store_booke_tsr (CPUPPCState *env, target_ulong val); void ppc_tlb_invalidate_all (CPUPPCState *env); void ppc_tlb_invalidate_one (CPUPPCState *env, target_ulong addr); +void cpu_ppc_set_papr(PowerPCCPU *cpu); #endif #endif =20 diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c index 3ecbd85..4d82e1c 100644 --- a/target-ppc/translate_init.c +++ b/target-ppc/translate_init.c @@ -8380,8 +8380,29 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data= ) pcc->l1_icache_size =3D 0x8000; pcc->interrupts_big_endian =3D ppc_cpu_interrupts_big_endian_lpcr; } -#endif /* defined (TARGET_PPC64) */ =20 +#if !defined(CONFIG_USER_ONLY) + +void cpu_ppc_set_papr(PowerPCCPU *cpu) +{ + CPUPPCState *env =3D &cpu->env; + + /* PAPR always has exception vectors in RAM not ROM. To ensure this, + * MSR[IP] should never be set. + * + * We also disallow setting of MSR_HV + */ + env->msr_mask &=3D ~((1ull << MSR_EP) | MSR_HVB); + + /* Tell KVM that we're in PAPR mode */ + if (kvm_enabled()) { + kvmppc_set_papr(cpu); + } +} + +#endif /* !defined(CONFIG_USER_ONLY) */ + +#endif /* defined (TARGET_PPC64) */ =20 /***********************************************************************= ******/ /* Generic CPU instantiation routine = */ --=20 2.5.5