Received: from eggs.gnu.org ([2001:4830:134:3::10]:39483) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSEsZ-0002jq-2I for qemu-devel@nongnu.org; Tue, 26 Jul 2016 22:47:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bSEsT-0001lU-PT for qemu-devel@nongnu.org; Tue, 26 Jul 2016 22:47:25 -0400 Date: Wed, 27 Jul 2016 11:50:23 +1000 From: David Gibson Message-ID: <20160727015023.GQ17429@voom.fritz.box> References: <1469571686-7284-1-git-send-email-benh@kernel.crashing.org> <1469571686-7284-2-git-send-email-benh@kernel.crashing.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="+hz2tM55CCA8Ej21" Content-Disposition: inline In-Reply-To: <1469571686-7284-2-git-send-email-benh@kernel.crashing.org> Subject: Re: [Qemu-devel] [PATCH 02/32] ppc: Provide basic raise_exception_* functions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Benjamin Herrenschmidt Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org --+hz2tM55CCA8Ej21 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 27, 2016 at 08:20:56AM +1000, Benjamin Herrenschmidt wrote: > Instead of using the same helpers called from translate.c, let's have > a bunch of functions that take the various argument combinations, > especially the retaddr which will be needed in subsequent patches, > and leave the helpers to be just that, helpers for translate.c >=20 > We don't yet convert all users, we'll go through them in subsequent > patches. >=20 > Signed-off-by: Benjamin Herrenschmidt > --- > target-ppc/cpu.h | 8 ++++++++ > target-ppc/excp_helper.c | 51 ++++++++++++++++++++++++++++++++----------= ------ > 2 files changed, 42 insertions(+), 17 deletions(-) >=20 > diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h > index 5fce1ff..2ee7a5e 100644 > --- a/target-ppc/cpu.h > +++ b/target-ppc/cpu.h > @@ -2295,6 +2295,14 @@ static inline void cpu_get_tb_cpu_state(CPUPPCStat= e *env, target_ulong *pc, > *flags =3D env->hflags; > } > =20 > +void QEMU_NORETURN raise_exception(CPUPPCState *env, uint32_t exception); > +void QEMU_NORETURN raise_exception_ra(CPUPPCState *env, uint32_t excepti= on, > + uintptr_t raddr); > +void QEMU_NORETURN raise_exception_err(CPUPPCState *env, uint32_t except= ion, > + uint32_t error_code); > +void QEMU_NORETURN raise_exception_err_ra(CPUPPCState *env, uint32_t exc= eption, > + uint32_t error_code, uintptr_t= raddr); > + > #if !defined(CONFIG_USER_ONLY) > static inline int booke206_tlbm_id(CPUPPCState *env, ppcmas_tlb_t *tlbm) > { > diff --git a/target-ppc/excp_helper.c b/target-ppc/excp_helper.c > index d6e1678..f4b115e 100644 > --- a/target-ppc/excp_helper.c > +++ b/target-ppc/excp_helper.c > @@ -898,34 +898,53 @@ static void cpu_dump_rfi(target_ulong RA, target_ul= ong msr) > /***********************************************************************= ******/ > /* Exceptions processing helpers */ > =20 > -void helper_raise_exception_err(CPUPPCState *env, uint32_t exception, > - uint32_t error_code) > +void raise_exception_err_ra(CPUPPCState *env, uint32_t exception, > + uint32_t error_code, uintptr_t raddr) > { > CPUState *cs =3D CPU(ppc_env_get_cpu(env)); > =20 > -#if 0 > - printf("Raise exception %3x code : %d\n", exception, error_code); > -#endif > cs->exception_index =3D exception; > env->error_code =3D error_code; > - cpu_loop_exit(cs); > + cpu_loop_exit_restore(cs, raddr); > +} > + > +void raise_exception_err(CPUPPCState *env, uint32_t exception, > + uint32_t error_code) > +{ > + raise_exception_err_ra(env, exception, error_code, 0); > +} > + > +void raise_exception(CPUPPCState *env, uint32_t exception) > +{ > + raise_exception_err_ra(env, exception, 0, 0); > +} > + > +void raise_exception_ra(CPUPPCState *env, uint32_t exception, > + uintptr_t raddr) > +{ > + raise_exception_err_ra(env, exception, 0, 0); This should pass raddr as the last argument, shouldn't it? > +} > + > +void helper_raise_exception_err(CPUPPCState *env, uint32_t exception, > + uint32_t error_code) > +{ > + raise_exception_err_ra(env, exception, error_code, 0); > } > =20 > void helper_raise_exception(CPUPPCState *env, uint32_t exception) > { > - helper_raise_exception_err(env, exception, 0); > + raise_exception_err_ra(env, exception, 0, 0); > } > =20 > #if !defined(CONFIG_USER_ONLY) > void helper_store_msr(CPUPPCState *env, target_ulong val) > { > - CPUState *cs; > + uint32_t excp =3D hreg_store_msr(env, val, 0); > =20 > - val =3D hreg_store_msr(env, val, 0); > - if (val !=3D 0) { > - cs =3D CPU(ppc_env_get_cpu(env)); > + if (excp !=3D 0) { > + CPUState *cs =3D CPU(ppc_env_get_cpu(env)); > cs->interrupt_request |=3D CPU_INTERRUPT_EXITTB; > - helper_raise_exception(env, val); > + raise_exception(env, excp); > } > } > =20 > @@ -951,7 +970,7 @@ void helper_pminsn(CPUPPCState *env, powerpc_pm_insn_= t insn) > * but this doesn't seem to be a problem. > */ > env->msr |=3D (1ull << MSR_EE); > - helper_raise_exception(env, EXCP_HLT); > + raise_exception(env, EXCP_HLT); > } > #endif /* defined(TARGET_PPC64) */ > =20 > @@ -1041,8 +1060,7 @@ void helper_tw(CPUPPCState *env, target_ulong arg1,= target_ulong arg2, > ((int32_t)arg1 =3D=3D (int32_t)arg2 && (flags & 0x04))= || > ((uint32_t)arg1 < (uint32_t)arg2 && (flags & 0x02)) || > ((uint32_t)arg1 > (uint32_t)arg2 && (flags & 0x01)))))= { > - helper_raise_exception_err(env, POWERPC_EXCP_PROGRAM, > - POWERPC_EXCP_TRAP); > + raise_exception_err(env, POWERPC_EXCP_PROGRAM, POWERPC_EXCP_TRAP= ); > } > } > =20 > @@ -1055,8 +1073,7 @@ void helper_td(CPUPPCState *env, target_ulong arg1,= target_ulong arg2, > ((int64_t)arg1 =3D=3D (int64_t)arg2 && (flags & 0x04))= || > ((uint64_t)arg1 < (uint64_t)arg2 && (flags & 0x02)) || > ((uint64_t)arg1 > (uint64_t)arg2 && (flags & 0x01)))))= { > - helper_raise_exception_err(env, POWERPC_EXCP_PROGRAM, > - POWERPC_EXCP_TRAP); > + raise_exception_err(env, POWERPC_EXCP_PROGRAM, POWERPC_EXCP_TRAP= ); > } > } > #endif --=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 --+hz2tM55CCA8Ej21 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXmBNfAAoJEGw4ysog2bOSzBkP/3ZMYvXg6U01sj0DMq5B3hgC MPaQpkgyzlgfUmCN/I3oguGlqp6gZ4He1GvlHxaP1xuabL6VqtwPKa31Q0XfFaTG 1IbiAy0eLU0HOAyy1c10oI2XXs7zbDqybLGDM+uLx+EpB2TRZ/qG08J/aeHyqJoU /KjGDBW42px19uafOsU0FR45PTICugr9F1281q81HfxrYjSnYYHPS3b5Jq8TEqty jI71gPK/fNBjxKaOv/ljkLD6/aau3VBeHE65MyNTkuB+fsMNWBMFMkkF+qrw8oVE TWu0j4/yBqhygl7heFfXwOuXaCtCdZmVAD0XIwfMI4UQ3t0oIVVEdlJguuLHqCeL h3G/Oz/5P1SLTIJwnCAyQMHTBFV0bYDMF0nJssylLWBKpdLvxoa7ZO+3wq9gm2TD y5m68hhJcT7+tf5zDeJacKYNQ3pfpUbtyDAHG6/UZqcCeNJ20FEGzGluYjQoFpaj accJJWZy7EfKAQ1qeGFTmk31w5YHYOySHau3iRIyxXIGMVZdCp7zMBys2HQAHmSg BiRDiYnwp9Rkpy90BWAYLrMBgrBpR88G9ucGvzql4/t1viB1JqEFS4fafCGVuOCN CU39Q3qn89R0N/R+L1Oc5e+ZPghd/7D7PQlufNwbZ4aWpF/ngBcrpKSJCzIec+Nq 1VukoFEuZpDiToYaYFxM =niHc -----END PGP SIGNATURE----- --+hz2tM55CCA8Ej21--