qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [5069] [sh4] code translation bug fix
Date: Fri, 22 Aug 2008 08:58:01 +0000	[thread overview]
Message-ID: <E1KWST3-00057x-1l@cvs.savannah.gnu.org> (raw)

Revision: 5069
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5069
Author:   aurel32
Date:     2008-08-22 08:58:00 +0000 (Fri, 22 Aug 2008)

Log Message:
-----------
[sh4] code translation bug fix

When a TLB miss occurs while pre-decrement store instruction such as
"mov.l Rm, @-Rn" is executed, re-execution of such instruction cause
status confusion. Because pre Rn decrement is executed before TLB miss,
re-execution decrements Rn again.
In other words, in a translated instruction array, register status
should not modified before memory access instruction.

(Shin-ichiro KAWASAKI)

Modified Paths:
--------------
    trunk/target-sh4/translate.c

Modified: trunk/target-sh4/translate.c
===================================================================
--- trunk/target-sh4/translate.c	2008-08-22 08:57:52 UTC (rev 5068)
+++ trunk/target-sh4/translate.c	2008-08-22 08:58:00 UTC (rev 5069)
@@ -390,21 +390,27 @@
 	return;
     case 0x2004:		/* mov.b Rm,@-Rn */
 	gen_op_movl_rN_T0(REG(B7_4));
-	gen_op_dec1_rN(REG(B11_8));
+	gen_op_dec1_rN(REG(B11_8));    /* modify register status */
 	gen_op_movl_rN_T1(REG(B11_8));
-	gen_op_stb_T0_T1(ctx);
+	gen_op_inc1_rN(REG(B11_8));    /* recover register status */
+	gen_op_stb_T0_T1(ctx);         /* might cause re-execution */
+	gen_op_dec1_rN(REG(B11_8));    /* modify register status */
 	return;
     case 0x2005:		/* mov.w Rm,@-Rn */
 	gen_op_movl_rN_T0(REG(B7_4));
 	gen_op_dec2_rN(REG(B11_8));
 	gen_op_movl_rN_T1(REG(B11_8));
+	gen_op_inc2_rN(REG(B11_8));
 	gen_op_stw_T0_T1(ctx);
+	gen_op_dec2_rN(REG(B11_8));
 	return;
     case 0x2006:		/* mov.l Rm,@-Rn */
 	gen_op_movl_rN_T0(REG(B7_4));
 	gen_op_dec4_rN(REG(B11_8));
 	gen_op_movl_rN_T1(REG(B11_8));
+	gen_op_inc4_rN(REG(B11_8));
 	gen_op_stl_T0_T1(ctx);
+	gen_op_dec4_rN(REG(B11_8));
 	return;
     case 0x6004:		/* mov.b @Rm+,Rn */
 	gen_op_movl_rN_T0(REG(B7_4));
@@ -570,20 +576,20 @@
 	gen_op_movl_rN_T0(REG(B11_8));
 	gen_op_ldl_T0_T0(ctx);
 	gen_op_movl_T0_T1();
-	gen_op_inc4_rN(REG(B11_8));
 	gen_op_movl_rN_T0(REG(B7_4));
 	gen_op_ldl_T0_T0(ctx);
 	gen_op_macl_T0_T1();
+	gen_op_inc4_rN(REG(B11_8));
 	gen_op_inc4_rN(REG(B7_4));
 	return;
     case 0x400f:		/* mac.w @Rm+,@Rn+ */
 	gen_op_movl_rN_T0(REG(B11_8));
 	gen_op_ldl_T0_T0(ctx);
 	gen_op_movl_T0_T1();
-	gen_op_inc2_rN(REG(B11_8));
 	gen_op_movl_rN_T0(REG(B7_4));
 	gen_op_ldl_T0_T0(ctx);
 	gen_op_macw_T0_T1();
+	gen_op_inc2_rN(REG(B11_8));
 	gen_op_inc2_rN(REG(B7_4));
 	return;
     case 0x0007:		/* mul.l Rm,Rn */
@@ -706,12 +712,16 @@
 	    gen_op_dec8_rN(REG(B11_8));
 	    gen_op_fmov_drN_DT0(XREG(B7_4));
 	    gen_op_movl_rN_T1(REG(B11_8));
+	    gen_op_inc8_rN(REG(B11_8));
 	    gen_op_stfq_DT0_T1(ctx);
+	    gen_op_dec8_rN(REG(B11_8));
 	} else {
 	    gen_op_dec4_rN(REG(B11_8));
 	    gen_op_fmov_frN_FT0(FREG(B7_4));
 	    gen_op_movl_rN_T1(REG(B11_8));
+	    gen_op_inc4_rN(REG(B11_8));
 	    gen_op_stfl_FT0_T1(ctx);
+	    gen_op_dec4_rN(REG(B11_8));
 	}
 	return;
     case 0xf006: /* fmov @(R0,Rm),{F,D,X}Rm - FPSCR: Nothing */
@@ -947,7 +957,9 @@
 	gen_op_dec4_rN(REG(B11_8));
 	gen_op_movl_rN_T1(REG(B11_8));
 	gen_op_movl_rN_T0(ALTREG(B6_4));
+	gen_op_inc4_rN(REG(B11_8));
 	gen_op_stl_T0_T1(ctx);
+	gen_op_dec4_rN(REG(B11_8));
 	return;
     }
 
@@ -1008,7 +1020,9 @@
     gen_op_##stop##_##reg##_T0 ();				\
     gen_op_dec4_rN (REG(B11_8));				\
     gen_op_movl_rN_T1 (REG(B11_8));				\
+    gen_op_inc4_rN (REG(B11_8));				\
     gen_op_stl_T0_T1 (ctx);					\
+    gen_op_dec4_rN (REG(B11_8));				\
     return;
 	LDST(sr, 0x400e, 0x4007, ldc, 0x0002, 0x4003, stc, ctx->bstate =
 	     BS_STOP;)

                 reply	other threads:[~2008-08-22  8:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=E1KWST3-00057x-1l@cvs.savannah.gnu.org \
    --to=aurelien@aurel32.net \
    --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).