From: James Hogan <james.hogan@imgtec.com>
To: Leon Alrae <leon.alrae@imgtec.com>
Cc: qemu-devel@nongnu.org, Aurelien Jarno <aurelien@aurel32.net>
Subject: Re: [Qemu-devel] [PATCH] target-mips: Fix exceptions while UX=0
Date: Tue, 17 Nov 2015 16:59:12 +0000 [thread overview]
Message-ID: <20151117165912.GE18109@jhogan-linux.le.imgtec.org> (raw)
In-Reply-To: <564B5134.7010106@imgtec.com>
[-- Attachment #1: Type: text/plain, Size: 2599 bytes --]
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.
>
> Indeed, thanks for the fix.
>
> >
> > Fix by updating mips_cpu_do_interrupt() to clear the MIPS_HFLAG_WRAP
> > flag when necessary, according to compute_hflags().
> >
> > Fixes: 01f728857941 ("target-mips: Status.UX/SX/KX enable 32-bit...")
> > Signed-off-by: James Hogan <james.hogan@imgtec.com>
> > Cc: Leon Alrae <leon.alrae@imgtec.com>
> > Cc: Aurelien Jarno <aurelien@aurel32.net>
> > ---
> > Note, compute_hflags() doesn't seem to take KX into account pre-r6,
> > which seems wrong.
>
> Why does it seem wrong? According to PRA, prior to R6 (excluding the
> R5+EVA case which we don’t support) this special behaviour for data
> 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=0 is described as causing an address error exception
pre-r6, which seems to be handled correctly in get_physical_address.
Please ignore that comment.
>
> > ---
> > target-mips/helper.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > 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 |= (1 << CP0St_EXL);
> > if (env->insn_flags & ISA_MIPS3) {
> > env->hflags |= MIPS_HFLAG_64;
> > + if (!(env->insn_flags & ISA_MIPS64R6) ||
> > + env->CP0_Status & (1 << CP0St_KX)) {
> > + env->hflags &= ~MIPS_HFLAG_AWRAP;
> > + }
>
> 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
>
> Thanks,
> Leon
>
> > }
> > env->hflags |= MIPS_HFLAG_CP0;
> > env->hflags &= ~(MIPS_HFLAG_KSU);
> >
>
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
prev parent reply other threads:[~2015-11-17 16:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-16 16:18 [Qemu-devel] [PATCH] target-mips: Fix exceptions while UX=0 James Hogan
2015-11-17 16:09 ` Leon Alrae
2015-11-17 16:59 ` James Hogan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151117165912.GE18109@jhogan-linux.le.imgtec.org \
--to=james.hogan@imgtec.com \
--cc=aurelien@aurel32.net \
--cc=leon.alrae@imgtec.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).