From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36545) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZyjbF-0003dO-4f for qemu-devel@nongnu.org; Tue, 17 Nov 2015 11:59:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zyjb9-0002YO-V4 for qemu-devel@nongnu.org; Tue, 17 Nov 2015 11:59:21 -0500 Received: from mailapp01.imgtec.com ([195.59.15.196]:47852 helo=imgpgp01.kl.imgtec.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zyjb9-0002YG-M9 for qemu-devel@nongnu.org; Tue, 17 Nov 2015 11:59:15 -0500 Date: Tue, 17 Nov 2015 16:59:12 +0000 From: James Hogan Message-ID: <20151117165912.GE18109@jhogan-linux.le.imgtec.org> References: <1447690698-20276-1-git-send-email-james.hogan@imgtec.com> <564B5134.7010106@imgtec.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="o0ZfoUVt4BxPQnbU" Content-Disposition: inline In-Reply-To: <564B5134.7010106@imgtec.com> Subject: Re: [Qemu-devel] [PATCH] target-mips: Fix exceptions while UX=0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Leon Alrae Cc: qemu-devel@nongnu.org, Aurelien Jarno --o0ZfoUVt4BxPQnbU Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Leon, On Tue, Nov 17, 2015 at 04:09:24PM +0000, Leon Alrae wrote: > On 16/11/15 16:18, James Hogan wrote: > > However when exceptions are taken outside of exception level, > > mips_cpu_do_interrupt() manipulates the env->hflags directly rather than > > using compute_hflags() to update them, and this code wasn't updated > > accordingly. As a result, when UX is cleared, MIPS_HFLAG_AWRAP is set, > > but it doesn't get cleared on entry back into kernel mode due to an > > exception. Kernel mode then cannot access the 64-bit segments resulting > > in a nested exception loop. >=20 > Indeed, thanks for the fix. >=20 > >=20 > > Fix by updating mips_cpu_do_interrupt() to clear the MIPS_HFLAG_WRAP > > flag when necessary, according to compute_hflags(). > >=20 > > Fixes: 01f728857941 ("target-mips: Status.UX/SX/KX enable 32-bit...") > > Signed-off-by: James Hogan > > Cc: Leon Alrae > > Cc: Aurelien Jarno > > --- > > Note, compute_hflags() doesn't seem to take KX into account pre-r6, > > which seems wrong. >=20 > Why does it seem wrong? According to PRA, prior to R6 (excluding the > R5+EVA case which we don=E2=80=99t support) this special behaviour for da= ta > references (i.e. sign-extension of the effective address when 64-bit > addressing is disabled) is only in User Mode. Okay, i see that KX=3D0 is described as causing an address error exception pre-r6, which seems to be handled correctly in get_physical_address. Please ignore that comment. >=20 > > --- > > target-mips/helper.c | 4 ++++ > > 1 file changed, 4 insertions(+) > >=20 > > diff --git a/target-mips/helper.c b/target-mips/helper.c > > index b3fe816fecf8..0625f610a015 100644 > > --- a/target-mips/helper.c > > +++ b/target-mips/helper.c > > @@ -725,6 +725,10 @@ void mips_cpu_do_interrupt(CPUState *cs) > > env->CP0_Status |=3D (1 << CP0St_EXL); > > if (env->insn_flags & ISA_MIPS3) { > > env->hflags |=3D MIPS_HFLAG_64; > > + if (!(env->insn_flags & ISA_MIPS64R6) || > > + env->CP0_Status & (1 << CP0St_KX)) { > > + env->hflags &=3D ~MIPS_HFLAG_AWRAP; > > + } >=20 > Any reason you skipped set_error_EPC and enter_DEPC? The flag needs to > be cleared there as well I think. Yes, I agree. That was an oversight. I will resubmit. Thanks James >=20 > Thanks, > Leon >=20 > > } > > env->hflags |=3D MIPS_HFLAG_CP0; > > env->hflags &=3D ~(MIPS_HFLAG_KSU); > >=20 >=20 --o0ZfoUVt4BxPQnbU Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJWS1zgAAoJEGwLaZPeOHZ6K5kP/10Li3Rdf4QL+xU7dL6S/GOr J3nVjAK65uVot3o5JC6gS1bLHhLS8fTV2Wv62TWB8oH2j6l8W70z3LRwoRuiHlft +ZB8OIfpPiO4XR8Fs+5GXyoHSTbFkfDbBTqvsJSmEqnBZ9MNPDeUk6BKke228cG0 9XRI9Xd1IpIxlHOkRPcjG3dbf3tQOzbKI8Yu8+uYctKWcRDeeh4osJ8tOvasaXdX XcdB42VULUZxwbAPtnXyzXug6mZYVsutRayIOkZSFdGAxNNFmgmlEKEtKGmZ/OGo 5/WmosK4kZa2KME6ULNE0C+t6pmLsTimuxS+1KbL8dEO3oQWiZHPVjuXHnyuQDw8 1kvXjAYoESZclP7NrlNSBm3a6UVFk3POhv2M2mUgfslsTamJPQdkIHt/G6DL3bjb TViKZUCiGBPH3AXs6qwj1uUohSipeZAwU41TwoZhxawtcLrCa70BLWjDTSRM8TAt eGhmtmGRVB3XA2eHuBuIOer/l/ukYezY+gzksO7c9qjAjJCPzjbQdwiZs3paDa3t F94cLG0sH5F2ZanKcKj27MFxIxUXHkxRoQTRP6VvHbKMzU71OhtW5jl7ybuYvQHh QS7Mdxbtn4hcLX0do9oD4sUHVMOqy8V2h2YePxiCwSRfDMaAvS1f5PtFpxOh8wFS 5Yrz6OXSOAaCjL408+72 =us6J -----END PGP SIGNATURE----- --o0ZfoUVt4BxPQnbU--