mirror of https://github.com/proxmox/mirror_qemu
target-arm: Break the TB after ISB to execute self-modified code correctly
If any store instruction writes the code inside the same TB after this store insn, the execution of the TB must be stopped to execute new code correctly. As described in ARMv8 manual D3.4.6 self-modifying code must do an IC invalidation to be valid, and an ISB after it. So it's enough to end the TB after ISB instruction on the code translation. Also this TB break is necessary to take any pending interrupts immediately after an ISB (as required by ARMv8 ARM D1.14.4). Signed-off-by: Sergey Sorokin <afarallax@yandex.ru> [PMM: tweaked commit message and comments slightly] Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>master
parent
82c39f6a88
commit
6df99dec9e
|
@ -657,8 +657,12 @@ static const ARMCPRegInfo v6_cp_reginfo[] = {
|
||||||
{ .name = "MVA_prefetch",
|
{ .name = "MVA_prefetch",
|
||||||
.cp = 15, .crn = 7, .crm = 13, .opc1 = 0, .opc2 = 1,
|
.cp = 15, .crn = 7, .crm = 13, .opc1 = 0, .opc2 = 1,
|
||||||
.access = PL1_W, .type = ARM_CP_NOP },
|
.access = PL1_W, .type = ARM_CP_NOP },
|
||||||
|
/* We need to break the TB after ISB to execute self-modifying code
|
||||||
|
* correctly and also to take any pending interrupts immediately.
|
||||||
|
* So use arm_cp_write_ignore() function instead of ARM_CP_NOP flag.
|
||||||
|
*/
|
||||||
{ .name = "ISB", .cp = 15, .crn = 7, .crm = 5, .opc1 = 0, .opc2 = 4,
|
{ .name = "ISB", .cp = 15, .crn = 7, .crm = 5, .opc1 = 0, .opc2 = 4,
|
||||||
.access = PL0_W, .type = ARM_CP_NOP },
|
.access = PL0_W, .type = ARM_CP_NO_RAW, .writefn = arm_cp_write_ignore },
|
||||||
{ .name = "DSB", .cp = 15, .crn = 7, .crm = 10, .opc1 = 0, .opc2 = 4,
|
{ .name = "DSB", .cp = 15, .crn = 7, .crm = 10, .opc1 = 0, .opc2 = 4,
|
||||||
.access = PL0_W, .type = ARM_CP_NOP },
|
.access = PL0_W, .type = ARM_CP_NOP },
|
||||||
{ .name = "DMB", .cp = 15, .crn = 7, .crm = 10, .opc1 = 0, .opc2 = 5,
|
{ .name = "DMB", .cp = 15, .crn = 7, .crm = 10, .opc1 = 0, .opc2 = 5,
|
||||||
|
|
|
@ -1230,9 +1230,15 @@ static void handle_sync(DisasContext *s, uint32_t insn,
|
||||||
return;
|
return;
|
||||||
case 4: /* DSB */
|
case 4: /* DSB */
|
||||||
case 5: /* DMB */
|
case 5: /* DMB */
|
||||||
case 6: /* ISB */
|
|
||||||
/* We don't emulate caches so barriers are no-ops */
|
/* We don't emulate caches so barriers are no-ops */
|
||||||
return;
|
return;
|
||||||
|
case 6: /* ISB */
|
||||||
|
/* We need to break the TB after this insn to execute
|
||||||
|
* a self-modified code correctly and also to take
|
||||||
|
* any pending interrupts immediately.
|
||||||
|
*/
|
||||||
|
s->is_jmp = DISAS_UPDATE;
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
unallocated_encoding(s);
|
unallocated_encoding(s);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -7720,10 +7720,16 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
|
||||||
return;
|
return;
|
||||||
case 4: /* dsb */
|
case 4: /* dsb */
|
||||||
case 5: /* dmb */
|
case 5: /* dmb */
|
||||||
case 6: /* isb */
|
|
||||||
ARCH(7);
|
ARCH(7);
|
||||||
/* We don't emulate caches so these are a no-op. */
|
/* We don't emulate caches so these are a no-op. */
|
||||||
return;
|
return;
|
||||||
|
case 6: /* isb */
|
||||||
|
/* We need to break the TB after this insn to execute
|
||||||
|
* self-modifying code correctly and also to take
|
||||||
|
* any pending interrupts immediately.
|
||||||
|
*/
|
||||||
|
gen_lookup_tb(s);
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
goto illegal_op;
|
goto illegal_op;
|
||||||
}
|
}
|
||||||
|
@ -10030,9 +10036,16 @@ static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw
|
||||||
break;
|
break;
|
||||||
case 4: /* dsb */
|
case 4: /* dsb */
|
||||||
case 5: /* dmb */
|
case 5: /* dmb */
|
||||||
case 6: /* isb */
|
|
||||||
/* These execute as NOPs. */
|
/* These execute as NOPs. */
|
||||||
break;
|
break;
|
||||||
|
case 6: /* isb */
|
||||||
|
/* We need to break the TB after this insn
|
||||||
|
* to execute self-modifying code correctly
|
||||||
|
* and also to take any pending interrupts
|
||||||
|
* immediately.
|
||||||
|
*/
|
||||||
|
gen_lookup_tb(s);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
goto illegal_op;
|
goto illegal_op;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue