linux-user/sh4: Fix crashes on signal delivery in conditional delay slot
PATCH 1/1 linux-user/sh4: Fix crashes on signal delivery in conditional delay slot
If we get a signal in the delay slot, we must roll-back the PC to the jump instruction. This was already fixed by the commit 3b894b699c9a ("linux-user/sh4: Fix crashes on signal delivery"), however this fix omits a test for TB_FLAG_DELAY_SLOT_COND. TB_FLAG_DELAY_SLOT_COND is set by the conditional delayed branches bf/s and bt/s. Qemu did not roll-back the PC in this case, resulting in incorrect program execution.
This patch fixes it.
--- linux-user/sh4/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/sh4/signal.c +1 -1
@@ -109,7 +109,7 @@ static void unwind_gusa(CPUSH4State *regthe SP, otherwise we would be pushing the signal context to invalid memory. */ regs->gregs[15 ] = regs->gregs[1 ]; - }else if (regs->flags &TB_FLAG_DELAY_SLOT ) { + }else if (regs->flags & (TB_FLAG_DELAY_SLOT |TB_FLAG_DELAY_SLOT_COND )) {/* If we are in a delay slot, push the previous instruction. */ regs->pc -=2 ; }
Quoted 23 lines · Mikulas Patocka
If we get a signal in the delay slot, we must roll-back the PC to the jump instruction. This was already fixed by the commit
3b894b699c9a("linux-user/sh4: Fix crashes on signal delivery"), however this fix omits a test forTB_FLAG_DELAY_SLOT_COND.TB_FLAG_DELAY_SLOT_CONDis set by the conditional delayed branches bf/s and bt/s. Qemu did not roll-back the PC in this case, resulting in incorrect program execution.This patch fixes it.
Signed-off-by Mikulas Patocka <[email protected]>--- linux-user/sh4/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Index:
qemu/linux-user/sh4/signal.c
===================================================================
linux-user/sh4/signal.c static void unwind_gusa(CPUSH4State *reg · line 115
Quoted 8 lines
linux-user/sh4/signal.c +1
-1@@ -109,7 +109,7 @@ static void unwind_gusa(CPUSH4State *regthe SP, otherwise we would be pushing the signal context to invalid memory. */ regs->gregs[15 ] = regs->gregs[1 ]; - }else if (regs->flags &TB_FLAG_DELAY_SLOT ) { + }else if (regs->flags & (TB_FLAG_DELAY_SLOT |TB_FLAG_DELAY_SLOT_COND )) {/* If we are in a delay slot, push the previous instruction. */ regs->pc -=2 ; }
Signature · 1 line
Yosinori Sato