From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSEsY-0002jo-K7 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 1bSEsV-0001nv-MM for qemu-devel@nongnu.org; Tue, 26 Jul 2016 22:47:25 -0400 Date: Wed, 27 Jul 2016 12:33:10 +1000 From: David Gibson Message-ID: <20160727023310.GY17429@voom.fritz.box> References: <1469571686-7284-1-git-send-email-benh@kernel.crashing.org> <1469571686-7284-25-git-send-email-benh@kernel.crashing.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="wHYmV+hLPeNaasdK" Content-Disposition: inline In-Reply-To: <1469571686-7284-25-git-send-email-benh@kernel.crashing.org> Subject: Re: [Qemu-devel] [PATCH 25/32] ppc: Handle unconditional (always/never) traps at translation time List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Benjamin Herrenschmidt Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org --wHYmV+hLPeNaasdK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 27, 2016 at 08:21:19AM +1000, Benjamin Herrenschmidt wrote: > We don't need to call a helper for trap always and trap never > which are used by Linux under some circumstances. >=20 > Signed-off-by: Benjamin Herrenschmidt > --- > target-ppc/translate.c | 48 ++++++++++++++++++++++++++++++++++++++++++--= ---- > 1 file changed, 42 insertions(+), 6 deletions(-) >=20 > diff --git a/target-ppc/translate.c b/target-ppc/translate.c > index 9af3f5f..57a891b 100644 > --- a/target-ppc/translate.c > +++ b/target-ppc/translate.c > @@ -3360,10 +3360,29 @@ static void gen_sc(DisasContext *ctx) > =20 > /*** Trap = ***/ > =20 > +/* Check for unconditional traps (always or never) */ > +static bool check_unconditional_trap(DisasContext *ctx) > +{ > + /* Trap never */ > + if (TO(ctx->opcode) =3D=3D 0) { > + return true; > + } > + /* Trap always */ > + if (TO(ctx->opcode) =3D=3D 31) { > + gen_exception_err(ctx, POWERPC_EXCP_PROGRAM, POWERPC_EXCP_TRAP); Should you be returning true here? Without it, IIUC, the functions below will generate the unconditional trap, then generate more code to actually test the condition and trap again. > + } > + return false; > +} > + > /* tw */ > static void gen_tw(DisasContext *ctx) > { > - TCGv_i32 t0 =3D tcg_const_i32(TO(ctx->opcode)); > + TCGv_i32 t0; > + > + if (check_unconditional_trap(ctx)) { > + return; > + } > + t0 =3D tcg_const_i32(TO(ctx->opcode)); > gen_helper_tw(cpu_env, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opc= ode)], > t0); > tcg_temp_free_i32(t0); > @@ -3372,8 +3391,14 @@ static void gen_tw(DisasContext *ctx) > /* twi */ > static void gen_twi(DisasContext *ctx) > { > - TCGv t0 =3D tcg_const_tl(SIMM(ctx->opcode)); > - TCGv_i32 t1 =3D tcg_const_i32(TO(ctx->opcode)); > + TCGv t0; > + TCGv_i32 t1; > + > + if (check_unconditional_trap(ctx)) { > + return; > + } > + t0 =3D tcg_const_tl(SIMM(ctx->opcode)); > + t1 =3D tcg_const_i32(TO(ctx->opcode)); > gen_helper_tw(cpu_env, cpu_gpr[rA(ctx->opcode)], t0, t1); > tcg_temp_free(t0); > tcg_temp_free_i32(t1); > @@ -3383,7 +3408,12 @@ static void gen_twi(DisasContext *ctx) > /* td */ > static void gen_td(DisasContext *ctx) > { > - TCGv_i32 t0 =3D tcg_const_i32(TO(ctx->opcode)); > + TCGv_i32 t0; > + > + if (check_unconditional_trap(ctx)) { > + return; > + } > + t0 =3D tcg_const_i32(TO(ctx->opcode)); > gen_helper_td(cpu_env, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opc= ode)], > t0); > tcg_temp_free_i32(t0); > @@ -3392,8 +3422,14 @@ static void gen_td(DisasContext *ctx) > /* tdi */ > static void gen_tdi(DisasContext *ctx) > { > - TCGv t0 =3D tcg_const_tl(SIMM(ctx->opcode)); > - TCGv_i32 t1 =3D tcg_const_i32(TO(ctx->opcode)); > + TCGv t0; > + TCGv_i32 t1; > + > + if (check_unconditional_trap(ctx)) { > + return; > + } > + t0 =3D tcg_const_tl(SIMM(ctx->opcode)); > + t1 =3D tcg_const_i32(TO(ctx->opcode)); > gen_helper_td(cpu_env, cpu_gpr[rA(ctx->opcode)], t0, t1); > tcg_temp_free(t0); > tcg_temp_free_i32(t1); --=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 --wHYmV+hLPeNaasdK Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXmB1lAAoJEGw4ysog2bOSH1AQALdf7NZL8DKBVwQcciaccS5P 81AdT3m9+14k0/9VBRbWkxAdryCujYgAGPDKcyainO904bz7h2MRIZEduCWtE75X HXOtDWQGLZEQbgA03ePOepqaH87+thEOmN9TNc3S0ishV/FNpUHuboVOJ7rW+cmD Jkh0ZiW33wSCyxSKbrhnEYsF7Fb/IGVzl1I1/RiUHjnTZSbFGhDSOS7INmJAm4c+ YuOvsPoU/9HQw1Rti+Ll+3lHl9NKySdD1TtZ7eqcYg7S3VnH14ToMz4pz3kdcHCE zEgmnjXiISeEGBz8X+4blPWg0SG8YvbHwjDP1v7tGpb85BQvsV0CJfEa4LuIYHpr fmisvb6kP4CZgWp7++utwJTQS9A/0o6c79c4tYFrAY/+RgUo5Ic3kyYwhCgVAx5o W2bwIKsmF3Da5zBjvjgvimWu4uEDv9S6IuUnifjfKpFOPFYgOYNXOI5YAihbBz+F kB6u+qtOMjFrWxWTTEwoweVxfPU0vXJp1cJYaDpaftA+km888OfV93Kv+kmHXBfQ OO3jM84z+M0celWGZjpGVe+mWn3FgmOICkIVE7IOpZRoKsGR73VdoREMUzE9sYsm w0BuFlWLVJCmGkUFr0TIU3icdTwo05Hhechx+n/FolXh2wW0BAh+KueNxM4uPWoa Akdum4Hl+uIcHvtM1bzT =povG -----END PGP SIGNATURE----- --wHYmV+hLPeNaasdK--