qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] MIPS: Correct MIPS16/microMIPS branch size calculation
@ 2012-06-08  1:06 Maciej W. Rozycki
  2012-06-12 15:01 ` Richard Henderson
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Maciej W. Rozycki @ 2012-06-08  1:06 UTC (permalink / raw)
  To: qemu-devel; +Cc: Maciej W. Rozycki, Aurelien Jarno

From: Nathan Froyd <froydnj@codesourcery.com>

 Nathan's original terse comment:

"Use MIPS_HFLAG_B16 to determine the address of a jump instruction when we 
need to restart a delay slot instruction."

and was not accompanied by a test case nor I have one offhand.

 However this change appears obviously correct to me, and the same 
calculation is already used in exception_resume_pc applied to ordinary, 
Debug and NMI exceptions.  This code on the other hand applies to reset 
exceptions and instruction restarts in the context of I/O.

Signed-off-by: Maciej W. Rozycki <macro@codesourcery.com>
---

 Sent on behalf of Nathan, who's since left the company.  Please apply.

  Maciej

qemu-mips-b16.diff
Index: qemu-git-trunk/exec.c
===================================================================
--- qemu-git-trunk.orig/exec.c	2012-06-04 05:34:18.655419589 +0100
+++ qemu-git-trunk/exec.c	2012-06-04 05:42:53.295516541 +0100
@@ -4235,7 +4235,7 @@ void cpu_io_recompile(CPUArchState *env,
        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);
         env->icount_decr.u16.low++;
         env->hflags &= ~MIPS_HFLAG_BMASK;
     }
Index: qemu-git-trunk/target-mips/translate.c
===================================================================
--- qemu-git-trunk.orig/target-mips/translate.c	2012-06-04 05:42:49.475411277 +0100
+++ qemu-git-trunk/target-mips/translate.c	2012-06-04 05:42:53.295516541 +0100
@@ -12796,7 +12796,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;
     }

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-11-17 11:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).