fix branch delay slot cornercases.
authorths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>
Thu, 5 Apr 2007 23:21:37 +0000 (23:21 +0000)
committerths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>
Thu, 5 Apr 2007 23:21:37 +0000 (23:21 +0000)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2615 c046a42c-6fe2-441c-8c8c-71466251a162

target-mips/helper.c
target-mips/translate.c

index dc51814..0cda1ef 100644 (file)
@@ -387,7 +387,6 @@ void do_interrupt (CPUState *env)
                    come back to the jump.  */
                 env->CP0_EPC = env->PC - 4;
                 env->CP0_Cause |= (1 << CP0Ca_BD);
-                env->hflags &= ~MIPS_HFLAG_BMASK;
             } else {
                 env->CP0_EPC = env->PC;
                 env->CP0_Cause &= ~(1 << CP0Ca_BD);
@@ -395,6 +394,7 @@ void do_interrupt (CPUState *env)
             env->CP0_Status |= (1 << CP0St_EXL);
             env->hflags &= ~MIPS_HFLAG_UM;
         }
+        env->hflags &= ~MIPS_HFLAG_BMASK;
         if (env->CP0_Status & (1 << CP0St_BEV)) {
             env->PC = (int32_t)0xBFC00200;
         } else {
index 7b7c464..8da8cc4 100644 (file)
@@ -1640,6 +1640,10 @@ static void gen_compute_branch (DisasContext *ctx, uint32_t opc,
         likely:
             ctx->hflags |= MIPS_HFLAG_BL;
             break;
+        default:
+            MIPS_INVAL("conditional branch/jump");
+            generate_exception(ctx, EXCP_RI);
+            return;
         }
         gen_op_set_bcond();
     }
@@ -1650,7 +1654,6 @@ static void gen_compute_branch (DisasContext *ctx, uint32_t opc,
         gen_op_set_T0(ctx->pc + 8);
         gen_op_store_T0_gpr(blink);
     }
-    return;
 }
 
 /* special3 bitfield operations */
@@ -5053,7 +5056,7 @@ static void decode_opc (CPUState *env, DisasContext *ctx)
         break;
     }
     if (ctx->hflags & MIPS_HFLAG_BMASK) {
-        int hflags = ctx->hflags;
+        int hflags = ctx->hflags & MIPS_HFLAG_BMASK;
         /* Branches completion */
         ctx->hflags &= ~MIPS_HFLAG_BMASK;
         ctx->bstate = BS_BRANCH;