Skip to content

Commit

Permalink
[DYNAREC] Added a DMB_ISH before fetching jmp address (helps Bastion,…
Browse files Browse the repository at this point in the history
… probably other too)
  • Loading branch information
ptitSeb committed Aug 27, 2023
1 parent 2dcd274 commit 6079f39
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/dynarec/dynarec_arm_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,15 @@ void jump_to_next(dynarec_arm_t* dyn, uintptr_t ip, int reg, int ninst)
if(reg!=xEIP) {
MOV_REG(xEIP, reg);
}
DMB_ISH();
MOV32(x2, getJumpTable());
MOV_REG_LSR_IMM5(x3, xEIP, JMPTABL_SHIFT);
LDR_REG_LSL_IMM5(x2, x2, x3, 2); // shiftsizeof(uintptr_t)
UBFX(x3, xEIP, 0, JMPTABL_SHIFT);
LDR_REG_LSL_IMM5(x3, x2, x3, 2); // shiftsizeof(uintptr_t)
} else {
uintptr_t p = getJumpTableAddress(ip);
DMB_ISH();
MOV32(x2, p);
MOV32_(xEIP, ip);
LDR_IMM9(x3, x2, 0);
Expand All @@ -288,6 +290,7 @@ void ret_to_epilog(dynarec_arm_t* dyn, int ninst)
MESSAGE(LOG_DUMP, "Ret next\n");
POP1(xEIP);
MOV32(x2, getJumpTable());
DMB_ISH();
MOV_REG_LSR_IMM5(x3, xEIP, JMPTABL_SHIFT);
LDR_REG_LSL_IMM5(x2, x2, x3, 2); // shiftsizeof(uintptr_t)
UBFX(x3, xEIP, 0, JMPTABL_SHIFT);
Expand All @@ -310,6 +313,7 @@ void retn_to_epilog(dynarec_arm_t* dyn, int ninst, int n)
} else {
ADD_IMM8(xESP, xESP, n);
}
DMB_ISH();
MOV32(x2, getJumpTable());
MOV_REG_LSR_IMM5(x3, xEIP, JMPTABL_SHIFT);
LDR_REG_LSL_IMM5(x2, x2, x3, 2); // shiftsizeof(uintptr_t)
Expand All @@ -326,6 +330,7 @@ void retn_to_epilog(dynarec_arm_t* dyn, int ninst, int n)
void iret_to_epilog(dynarec_arm_t* dyn, int ninst)
{
MESSAGE(LOG_DUMP, "IRet epilog\n");
DMB_ISH();
// POP IP
POP1(xEIP);
// POP CS
Expand Down

0 comments on commit 6079f39

Please sign in to comment.