Skip to content

Commit

Permalink
Merge pull request qemu#30 from lalrae/fix-hflags-in-delay-slot
Browse files Browse the repository at this point in the history
target-mips: fix hflags modified in delay / forbidden slot

Fixes qemu#29

Signed-off-by: Leon Alrae leon.alrae@imgtec.com
  • Loading branch information
Leon Alrae committed Jan 13, 2015
2 parents dd28128 + 902b883 commit dbea488
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions target-mips/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -10893,14 +10893,25 @@ static void gen_rdhwr(DisasContext *ctx, int rt, int rd)
tcg_temp_free(t0);
}

static inline void clear_branch_hflags(DisasContext *ctx)
{
ctx->hflags &= ~MIPS_HFLAG_BMASK;
if (ctx->bstate == BS_NONE) {
save_cpu_state(ctx, 0);
} else {
/* it is not safe to save ctx->hflags as hflags may be changed
in execution time by the instruction in delay / forbidden slot. */
tcg_gen_andi_i32(hflags, hflags, ~MIPS_HFLAG_BMASK);
}
}

static void gen_branch(DisasContext *ctx, int insn_bytes)
{
if (ctx->hflags & MIPS_HFLAG_BMASK) {
int proc_hflags = ctx->hflags & MIPS_HFLAG_BMASK;
/* Branches completion */
ctx->hflags &= ~MIPS_HFLAG_BMASK;
clear_branch_hflags(ctx);
ctx->bstate = BS_BRANCH;
save_cpu_state(ctx, 0);
/* FIXME: Need to clear can_do_io. */
switch (proc_hflags & MIPS_HFLAG_BMASK_BASE) {
case MIPS_HFLAG_FBNSLOT:
Expand Down Expand Up @@ -10958,8 +10969,8 @@ static void gen_branch(DisasContext *ctx, int insn_bytes)
tcg_gen_exit_tb(0);
break;
default:
MIPS_DEBUG("unknown branch");
break;
fprintf(stderr, "unknown branch 0x%x\n", proc_hflags);
abort();
}
}
}
Expand Down

0 comments on commit dbea488

Please sign in to comment.