Commit 3ad4bb2d3d22f3be94db7bcabac8586cfb222efb

Authored by ths
1 parent 820e00f2

Barf on branches/jumps in branch delay slots. Spotted by Stefan Weil.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2513 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 13 additions and 5 deletions
target-mips/translate.c
... ... @@ -1368,12 +1368,20 @@ static inline void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest)
1368 1368 static void gen_compute_branch (DisasContext *ctx, uint32_t opc,
1369 1369 int rs, int rt, int32_t offset)
1370 1370 {
1371   - target_ulong btarget;
1372   - int blink, bcond;
  1371 + target_ulong btarget = -1;
  1372 + int blink = 0;
  1373 + int bcond = 0;
  1374 +
  1375 + if (ctx->hflags & MIPS_HFLAG_BMASK) {
  1376 + if (loglevel & CPU_LOG_TB_IN_ASM) {
  1377 + fprintf(logfile,
  1378 + "undefined branch in delay slot at pc 0x%08x\n", ctx->pc);
  1379 + }
  1380 + MIPS_INVAL("branch/jump in bdelay slot");
  1381 + generate_exception(ctx, EXCP_RI);
  1382 + return;
  1383 + }
1373 1384  
1374   - btarget = -1;
1375   - blink = 0;
1376   - bcond = 0;
1377 1385 /* Load needed operands */
1378 1386 switch (opc) {
1379 1387 case OPC_BEQ:
... ...