Received: from eggs.gnu.org ([2001:4830:134:3::10]:39451) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSEsY-0002jl-3R for qemu-devel@nongnu.org; Tue, 26 Jul 2016 22:47:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bSEsV-0001mu-6k for qemu-devel@nongnu.org; Tue, 26 Jul 2016 22:47:24 -0400 Date: Wed, 27 Jul 2016 12:30:15 +1000 From: David Gibson Message-ID: <20160727023015.GX17429@voom.fritz.box> References: <1469571686-7284-1-git-send-email-benh@kernel.crashing.org> <1469571686-7284-24-git-send-email-benh@kernel.crashing.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="kLdbqvpuLRxNeSq5" Content-Disposition: inline In-Reply-To: <1469571686-7284-24-git-send-email-benh@kernel.crashing.org> Subject: Re: [Qemu-devel] [PATCH 24/32] ppc: Make alignment exceptions suck less List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Benjamin Herrenschmidt Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org --kLdbqvpuLRxNeSq5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 27, 2016 at 08:21:18AM +1000, Benjamin Herrenschmidt wrote: > The current alignment exception generation tries to load the opcode > to put in DSISR from a context where a cpu_ldl_code() is really not > a good idea. It might fault and longjmp out and that's not something > we want happening here. >=20 > Instead, pass the releavant opcode bits via the error_code. >=20 > There are a couple of cases of alignment interrupts that won't set > anything, the ones coming from access to direct store segments, but > that doesn't happen in practice, nobody used direct store segments > and they are gone from newer chips. Do I understand correctly that this isn't actually new? This was already wrong for direct store segments, you've just noted it? >=20 > Signed-off-by: Benjamin Herrenschmidt > --- > target-ppc/excp_helper.c | 9 +++++---- > target-ppc/translate.c | 2 +- > 2 files changed, 6 insertions(+), 5 deletions(-) >=20 > diff --git a/target-ppc/excp_helper.c b/target-ppc/excp_helper.c > index c31bbad..9a26578 100644 > --- a/target-ppc/excp_helper.c > +++ b/target-ppc/excp_helper.c > @@ -260,11 +260,12 @@ static inline void powerpc_excp(PowerPCCPU *cpu, in= t excp_model, int excp) > } > break; > case POWERPC_EXCP_ALIGN: /* Alignment exception = */ > - /* XXX: this is false */ > /* Get rS/rD and rA from faulting opcode */ > - /* Broken for LE mode */ > - env->spr[SPR_DSISR] |=3D (cpu_ldl_code(env, env->nip) > - & 0x03FF0000) >> 16; > + /* Note: the opcode fields will not be set properly for a direct > + * store load/store, but nobody cares as nobody actually uses > + * direct store segments. > + */ > + env->spr[SPR_DSISR] |=3D (env->error_code & 0x03FF0000) >> 16; > break; > case POWERPC_EXCP_PROGRAM: /* Program exception = */ > switch (env->error_code & ~0xF) { > diff --git a/target-ppc/translate.c b/target-ppc/translate.c > index ddfec33..9af3f5f 100644 > --- a/target-ppc/translate.c > +++ b/target-ppc/translate.c > @@ -2202,7 +2202,7 @@ static inline void gen_check_align(DisasContext *ct= x, TCGv EA, int mask) > tcg_gen_andi_tl(t0, EA, mask); > tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, l1); > t1 =3D tcg_const_i32(POWERPC_EXCP_ALIGN); > - t2 =3D tcg_const_i32(0); > + t2 =3D tcg_const_i32(ctx->opcode & 0x03FF0000); > gen_update_nip(ctx, ctx->nip - 4); > gen_helper_raise_exception_err(cpu_env, t1, t2); > 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 --kLdbqvpuLRxNeSq5 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXmBy3AAoJEGw4ysog2bOSYbcP/ia08VFKShKMkkJQ7IO8IcwG 9OaIEaErlGccNKehuRlySi+uFswlqwIr42GYDZUsAJvS8hJ6FiSQ0vbRlDQODD1J JMODB+BeJIyRJaqi42efT3fnFLBBjGXG8//ZFakNJF9a9GxsphcFW3QvLk3WaX7k TerymOMQKVoB/N0RqH9SV1/h5aM6mwEjQQcZNScbH8OK9q91IlXm2VZRWJN/EPT6 4sfU36IeQKUAIHIFIJSjTrtBaqAIwyNvnytBaE7cAP0vNe8Rz1jz8+4hu0Ni01x5 DQM1+ZloS/3OWfQYkurM87uhIoWbNXNoFeawAuIZhovhENs0tWHH9U5K3iq9pXaa P9ZAMLyFhzVY96ptJBwNu89KqB+Ca6MyQI8zdAHzjKxeh04vW7/IQc4nnVuCso3u qNRJ4SbwHOSaOMuFWg7T/HZOIc7DgxP2bsH1rGSn9kfB6Sg42ABlT4NkeLuX0zlX UaLgnyXnxlcCjrIcXX62T/XVTCAiw78wW8H12FoUZL4IwRo8JqDuH95n7kUVFcEH P/AgCvTZOz+o+nP1Xcy1OHOtwmgKjfQxmWBf82ryIz6GBpEH/0a0FY09M1JjTiG0 5e5ydpt2yzGAAT2bxSGbAw2H/aBmfx5OvJAw+J15184g/uX9P5OXhJ3Z1Vo6KmBM 3A6XpjLRI0gE/D7MBG1m =nt7I -----END PGP SIGNATURE----- --kLdbqvpuLRxNeSq5--