mirror of
https://github.com/xemu-project/xemu.git
synced 2025-02-11 07:05:22 +00:00
target/avr: Disable interrupts when env->skip set
This bit is not saved across interrupts, so we must delay delivering the interrupt until the skip has been processed. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1118 Reviewed-by: Michael Rolnik <mrolnik@gmail.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
cecaad5401
commit
36027c7097
@ -31,6 +31,15 @@ bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
|
|||||||
AVRCPU *cpu = AVR_CPU(cs);
|
AVRCPU *cpu = AVR_CPU(cs);
|
||||||
CPUAVRState *env = &cpu->env;
|
CPUAVRState *env = &cpu->env;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We cannot separate a skip from the next instruction,
|
||||||
|
* as the skip would not be preserved across the interrupt.
|
||||||
|
* Separating the two insn normally only happens at page boundaries.
|
||||||
|
*/
|
||||||
|
if (env->skip) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (interrupt_request & CPU_INTERRUPT_RESET) {
|
if (interrupt_request & CPU_INTERRUPT_RESET) {
|
||||||
if (cpu_interrupts_enabled(env)) {
|
if (cpu_interrupts_enabled(env)) {
|
||||||
cs->exception_index = EXCP_RESET;
|
cs->exception_index = EXCP_RESET;
|
||||||
|
@ -2971,8 +2971,18 @@ static void avr_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
|
|||||||
if (skip_label) {
|
if (skip_label) {
|
||||||
canonicalize_skip(ctx);
|
canonicalize_skip(ctx);
|
||||||
gen_set_label(skip_label);
|
gen_set_label(skip_label);
|
||||||
if (ctx->base.is_jmp == DISAS_NORETURN) {
|
|
||||||
|
switch (ctx->base.is_jmp) {
|
||||||
|
case DISAS_NORETURN:
|
||||||
ctx->base.is_jmp = DISAS_CHAIN;
|
ctx->base.is_jmp = DISAS_CHAIN;
|
||||||
|
break;
|
||||||
|
case DISAS_NEXT:
|
||||||
|
if (ctx->base.tb->flags & TB_FLAGS_SKIP) {
|
||||||
|
ctx->base.is_jmp = DISAS_TOO_MANY;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2989,6 +2999,11 @@ static void avr_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs)
|
|||||||
{
|
{
|
||||||
DisasContext *ctx = container_of(dcbase, DisasContext, base);
|
DisasContext *ctx = container_of(dcbase, DisasContext, base);
|
||||||
bool nonconst_skip = canonicalize_skip(ctx);
|
bool nonconst_skip = canonicalize_skip(ctx);
|
||||||
|
/*
|
||||||
|
* Because we disable interrupts while env->skip is set,
|
||||||
|
* we must return to the main loop to re-evaluate afterward.
|
||||||
|
*/
|
||||||
|
bool force_exit = ctx->base.tb->flags & TB_FLAGS_SKIP;
|
||||||
|
|
||||||
switch (ctx->base.is_jmp) {
|
switch (ctx->base.is_jmp) {
|
||||||
case DISAS_NORETURN:
|
case DISAS_NORETURN:
|
||||||
@ -2997,7 +3012,7 @@ static void avr_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs)
|
|||||||
case DISAS_NEXT:
|
case DISAS_NEXT:
|
||||||
case DISAS_TOO_MANY:
|
case DISAS_TOO_MANY:
|
||||||
case DISAS_CHAIN:
|
case DISAS_CHAIN:
|
||||||
if (!nonconst_skip) {
|
if (!nonconst_skip && !force_exit) {
|
||||||
/* Note gen_goto_tb checks singlestep. */
|
/* Note gen_goto_tb checks singlestep. */
|
||||||
gen_goto_tb(ctx, 1, ctx->npc);
|
gen_goto_tb(ctx, 1, ctx->npc);
|
||||||
break;
|
break;
|
||||||
@ -3005,8 +3020,11 @@ static void avr_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs)
|
|||||||
tcg_gen_movi_tl(cpu_pc, ctx->npc);
|
tcg_gen_movi_tl(cpu_pc, ctx->npc);
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case DISAS_LOOKUP:
|
case DISAS_LOOKUP:
|
||||||
tcg_gen_lookup_and_goto_ptr();
|
if (!force_exit) {
|
||||||
break;
|
tcg_gen_lookup_and_goto_ptr();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* fall through */
|
||||||
case DISAS_EXIT:
|
case DISAS_EXIT:
|
||||||
tcg_gen_exit_tb(NULL, 0);
|
tcg_gen_exit_tb(NULL, 0);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user