From: Leon Alrae <leon.alrae@imgtec.com>
To: "Maciej W. Rozycki" <macro@codesourcery.com>, qemu-devel@nongnu.org
Cc: Aurelien Jarno <aurelien@aurel32.net>
Subject: Re: [Qemu-devel] [PATCH v2] mips: Correct MIPS16/microMIPS branch size calculation
Date: Mon, 17 Nov 2014 11:26:45 +0000 [thread overview]
Message-ID: <5469DB75.6060606@imgtec.com> (raw)
In-Reply-To: <alpine.DEB.1.10.1411070143380.2881@tp.orcam.me.uk>
On 07/11/2014 20:05, Maciej W. Rozycki wrote:
> Correct MIPS16/microMIPS branch size calculation in PC adjustment
> needed:
>
> - to set the value of CP0.ErrorEPC at the entry to the reset exception,
>
> - for the purpose of branch reexecution in the context of device I/O.
>
> Follow the approach taken in `exception_resume_pc' for ordinary, Debug
> and NMI exceptions.
>
> MIPS16 and microMIPS branches can be 2 or 4 bytes in size and that has
> to be reflected in calculation. Original MIPS ISA branches, which is
> where this code originates from, are always 4 bytes long, just as all
> original MIPS ISA instructions.
>
> Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
> Signed-off-by: Maciej W. Rozycki <macro@codesourcery.com>
> ---
> Another change that has waited for too long, with the original
> discussion archived here:
>
> http://lists.nongnu.org/archive/html/qemu-devel/2012-06/msg01230.html
>
> Resending with what hopefully is a better description and updated to
> reflect the move of `cpu_io_recompile' from exec.c to translate-all.c.
>
> Please apply,
>
> Maciej
>
> qemu-mips-b16.diff
> Index: qemu-git-trunk/target-mips/translate.c
> ===================================================================
> --- qemu-git-trunk.orig/target-mips/translate.c 2014-11-07 18:34:30.927788566 +0000
> +++ qemu-git-trunk/target-mips/translate.c 2014-11-07 18:34:35.428958223 +0000
> @@ -19452,7 +19452,8 @@ void cpu_state_reset(CPUMIPSState *env)
> if (env->hflags & MIPS_HFLAG_BMASK) {
> /* If the exception was raised from a delay slot,
> come back to the jump. */
> - env->CP0_ErrorEPC = env->active_tc.PC - 4;
> + env->CP0_ErrorEPC = (env->active_tc.PC
> + - (env->hflags & MIPS_HFLAG_B16 ? 2 : 4));
> } else {
> env->CP0_ErrorEPC = env->active_tc.PC;
> }
> Index: qemu-git-trunk/translate-all.c
> ===================================================================
> --- qemu-git-trunk.orig/translate-all.c 2014-11-07 17:33:13.037575065 +0000
> +++ qemu-git-trunk/translate-all.c 2014-11-07 18:34:35.428958223 +0000
> @@ -1534,7 +1534,7 @@ void cpu_io_recompile(CPUState *cpu, uin
> branch. */
> #if defined(TARGET_MIPS)
> if ((env->hflags & MIPS_HFLAG_BMASK) != 0 && n > 1) {
> - env->active_tc.PC -= 4;
> + env->active_tc.PC -= (env->hflags & MIPS_HFLAG_B16 ? 2 : 4);
> cpu->icount_decr.u16.low++;
> env->hflags &= ~MIPS_HFLAG_BMASK;
> }
>
Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
prev parent reply other threads:[~2014-11-17 11:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-08 1:06 [Qemu-devel] [PATCH] MIPS: Correct MIPS16/microMIPS branch size calculation Maciej W. Rozycki
2012-06-12 15:01 ` Richard Henderson
2012-06-12 15:11 ` Peter Maydell
2014-11-07 20:05 ` [Qemu-devel] [PATCH v2] mips: " Maciej W. Rozycki
2014-11-17 11:26 ` Leon Alrae [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=5469DB75.6060606@imgtec.com \
--to=leon.alrae@imgtec.com \
--cc=aurelien@aurel32.net \
--cc=macro@codesourcery.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).