From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41932) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aggKm-0005pY-Ae for qemu-devel@nongnu.org; Thu, 17 Mar 2016 18:24:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aggKi-0001Xh-U3 for qemu-devel@nongnu.org; Thu, 17 Mar 2016 18:24:00 -0400 Date: Fri, 18 Mar 2016 09:03:46 +1100 From: David Gibson Message-ID: <20160317220346.GW9032@voom> References: <1457974600-13828-1-git-send-email-clg@fr.ibm.com> <1457974600-13828-7-git-send-email-clg@fr.ibm.com> <20160317023455.GK9032@voom> <56EAA41B.8070702@fr.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="LznoD+qmdO0FySBL" Content-Disposition: inline In-Reply-To: <56EAA41B.8070702@fr.ibm.com> Subject: Re: [Qemu-devel] [PATCH 06/17] ppc: Create cpu_ppc_set_papr() helper List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?iso-8859-1?Q?C=E9dric?= Le Goater Cc: Thomas Huth , qemu-ppc@nongnu.org, qemu-devel@nongnu.org --LznoD+qmdO0FySBL Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Mar 17, 2016 at 01:33:31PM +0100, C=E9dric Le Goater wrote: > On 03/17/2016 03:34 AM, David Gibson wrote: > > On Mon, Mar 14, 2016 at 05:56:29PM +0100, C=E9dric Le Goater wrote: > >> 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 setti= ng > >> 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 > >=20 > > I'm a little nervous about applying this before 2.6. This affects the > > value of the LPCR which is used to control exception behaviour in some > > cases. I'm pretty sure the current behaviour is wrong, but we do know > > it doesn't break horribly for existing machines, which we'd have to > > retest with the new behaviour. >=20 > Yes. I agree. >=20 > > I'm certainly willing to hear a case for this if it makes other > > patches in the series significantly easier though. >=20 > I think we should split this patch in two. Put the cpu_ppc_set_papr() hel= per=20 > and the MSR change in the first one and keep the LPCR changes for the sec= ond.=20 > The latter belong to another set of fixes related the exception > models. Yes, I think that makes sense. >=20 > C. >=20 > >> --- > >> hw/ppc/spapr.c | 11 ++--------- > >> target-ppc/cpu.h | 1 + > >> target-ppc/translate_init.c | 37 ++++++++++++++++++++++++++++++++++++- > >> 3 files changed, 39 insertions(+), 10 deletions(-) > >> > >> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > >> index 43708a2a9086..9c01872ce4d3 100644 > >> --- a/hw/ppc/spapr.c > >> +++ b/hw/ppc/spapr.c > >> @@ -1612,15 +1612,8 @@ static void spapr_cpu_init(sPAPRMachineState *s= papr, 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 th= is, > >> - * 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 9ce301f18922..a7da0d3e95a9 100644 > >> --- a/target-ppc/cpu.h > >> +++ b/target-ppc/cpu.h > >> @@ -1268,6 +1268,7 @@ void store_booke_tcr (CPUPPCState *env, target_u= long 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 46dabe58783a..093ef036320d 100644 > >> --- a/target-ppc/translate_init.c > >> +++ b/target-ppc/translate_init.c > >> @@ -8496,8 +8496,43 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *d= ata) > >> pcc->interrupts_big_endian =3D ppc_cpu_interrupts_big_endian_lpcr; > >> pcc->threads_per_core =3D 8; > >> } > >> -#endif /* defined (TARGET_PPC64) */ > >> =20 > >> +#if !defined(CONFIG_USER_ONLY) > >> + > >> +void cpu_ppc_set_papr(PowerPCCPU *cpu) > >> +{ > >> + CPUPPCState *env =3D &cpu->env; > >> + ppc_spr_t *lpcr =3D &env->spr_cb[SPR_LPCR]; > >> + > >> + /* PAPR always has exception vectors in RAM not ROM. To ensure th= is, > >> + * MSR[IP] should never be set. > >> + * > >> + * We also disallow setting of MSR_HV > >> + */ > >> + env->msr_mask &=3D ~((1ull << MSR_EP) | MSR_HVB); > >> + > >> + /* Set emulated LPCR to not send interrupts to hypervisor. Note t= hat > >> + * under KVM, the actual HW LPCR will be set differently by KVM i= tself, > >> + * the settings below ensure proper operations with TCG in absenc= e of > >> + * a real hypervisor > >> + */ > >> + lpcr->default_value &=3D ~(LPCR_VPM0 | LPCR_VPM1 | LPCR_ISL | LPC= R_KBV); > >> + lpcr->default_value |=3D LPCR_LPES0 | LPCR_LPES1; > >> + > >> + /* We should be followed by a CPU reset but update the active val= ue > >> + * just in case... > >> + */ > >> + env->spr[SPR_LPCR] =3D lpcr->default_value; > >> + > >> + /* 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 >=20 --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --LznoD+qmdO0FySBL Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJW6ynBAAoJEGw4ysog2bOSEzsQAM7iJvIaoKSQRxQAR1At70Vo sPNU9xXaYJIPKxI87eFSqlLYHrtmzP2KvSXPhXCY4tCxNO0FBlQgFLqEaAJ3obPZ 7R3WkguclNN+6J9a8GYRaXoawYHyV1xEXUVGgFGmx1+7ZghH6LlTUVZUNbkFc4y0 m4Zg1ZGE9oSonjGtcBUR5aCXgechY61OSrXHkC8UYcyj1BMotPq9NkyQLIu271ng EikT9heoFqL3mTxKPkO1SN+Ucx6iwgBDiCjmihngPnsc1V/E2VHAXnQYy76He4hb lhuDnlOwDqKsH18kJpDeCU2U0Kni7O1De/ybyEXUs+ZlB5MWpBLentU+zOawu2An i+yHiqPp1fW1JZkEo+H2raI3ZnpO4BSGyF8VvAOeimTjtYGs35WVddUYL/z3bMC7 pq0mpuLJFa/cpLw0ixMo1zVXvGMJxLoJIbnU+Fp2PaehHDloHv032wJNu9SG5IdM JzVf2o2sHvh6uAobrrFCtt2h9BmTBdk3hyw2BMeaNU6MZmQgF9ITsR9cXyoKPIN9 wp7hOmUEeDVDODuTXNU0W1PAaobXSFhWnS8hDU662vQzMPaoU2JPh/vk37WR0Mkl PmvaJeEgvJWnkdbrFgTblxFoybosphjbdK3RCQ9hn+JSx0CQyAZb4akj2U+xSqbw qmqGhws76+uEl+1Ng/4c =7Nch -----END PGP SIGNATURE----- --LznoD+qmdO0FySBL--