From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40395) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agNue-00051Y-77 for qemu-devel@nongnu.org; Wed, 16 Mar 2016 22:43:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1agNuc-0006en-MX for qemu-devel@nongnu.org; Wed, 16 Mar 2016 22:43:48 -0400 Date: Thu, 17 Mar 2016 13:34:55 +1100 From: David Gibson Message-ID: <20160317023455.GK9032@voom> References: <1457974600-13828-1-git-send-email-clg@fr.ibm.com> <1457974600-13828-7-git-send-email-clg@fr.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="M1akecbV8LB7u7K0" Content-Disposition: inline In-Reply-To: <1457974600-13828-7-git-send-email-clg@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 --M1akecbV8LB7u7K0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Mar 14, 2016 at 05:56:29PM +0100, C=E9dric Le Goater wrote: > From: Benjamin Herrenschmidt >=20 > 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. >=20 > Signed-off-by: Benjamin Herrenschmidt > Reviewed-by: David Gibson 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. I'm certainly willing to hear a case for this if it makes other patches in the series significantly easier though. > --- > hw/ppc/spapr.c | 11 ++--------- > target-ppc/cpu.h | 1 + > target-ppc/translate_init.c | 37 ++++++++++++++++++++++++++++++++++++- > 3 files changed, 39 insertions(+), 10 deletions(-) >=20 > 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 *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 9ce301f18922..a7da0d3e95a9 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 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 *data) > 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 this, > + * 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 that > + * under KVM, the actual HW LPCR will be set differently by KVM itse= lf, > + * the settings below ensure proper operations with TCG in absence of > + * a real hypervisor > + */ > + lpcr->default_value &=3D ~(LPCR_VPM0 | LPCR_VPM1 | LPCR_ISL | LPCR_K= BV); > + lpcr->default_value |=3D LPCR_LPES0 | LPCR_LPES1; > + > + /* We should be followed by a CPU reset but update the active value > + * 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 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 --M1akecbV8LB7u7K0 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJW6hfPAAoJEGw4ysog2bOSjDUQAMBwxkDyxlo5NVUM+M3brghj AECK9GYJF6pFtkO+m+ZTo0uUDHswthfnTrcHA+Qgv6NFDFP7Y3zs3UQzkU7NvUJw PINPqJEQS6SjXTTyGOnsXIzswzyL8Q/g5TtUREFquLJaGWO2k5sxzwGi846vP5Ym bZKtbGryLMlGHqKDdVtbSOT/KmYNkqaI/P1GxoD9zqN2lTrTbV43kwSpgqNRalh/ MnfhXQ54AgesL1rS3Q+AHAaD23wBHimya66e23xzZB80wpOIjK5F0qO8FWEMlHZ3 LmaRyhi6FeyHqU3PmrxT2Ufr2fkpwkuGo22kXeaCf4XPM4CNV16M2dNqqgExfSeB DSvueIqg3MnhSO+zvIBZlu2OnMRvi3WnGHilTRWHDh3o4+S3hvZJOaHJPsizNySK Om7ns08K3t2ITsrbnzXKraHaDLUpCJWb6eh04T9/6Nt2ioN/Wt33sW0y5Q56eAGg d401RyuY6CIWHnfqV23IndbpGfH7L1ujFfiPXDONiLWPTfBPdUpbycckcZjXSukP QpFPOTDLOSP9fw3VP8dEH0+vKhJhcguNysnz6pSI1KbEFniCT++cjL81h1yButQv /xGnZ+uyDx5BnM0eHwwOr51El/+Gwa8ghQ0Ed/tn5K74eSR/cHxFcb+6NubUPMQf v9r0KZ3kyB+T5UpaW9yG =V6Ka -----END PGP SIGNATURE----- --M1akecbV8LB7u7K0--