diff --git a/qemu/target-arm/op_helper.c b/qemu/target-arm/op_helper.c index 6e2d760e..0e5f2a8c 100644 --- a/qemu/target-arm/op_helper.c +++ b/qemu/target-arm/op_helper.c @@ -252,6 +252,13 @@ void HELPER(wfi)(CPUARMState *env) { CPUState *cs = CPU(arm_env_get_cpu(env)); + if (cpu_has_work(cs)) { + /* Don't bother to go into our "low power state" if + * we would just wake up immediately. + */ + return; + } + cs->exception_index = EXCP_HLT; cs->halted = 1; cpu_loop_exit(cs); diff --git a/qemu/target-arm/translate-a64.c b/qemu/target-arm/translate-a64.c index f835491f..79cd761c 100644 --- a/qemu/target-arm/translate-a64.c +++ b/qemu/target-arm/translate-a64.c @@ -11406,6 +11406,10 @@ tb_end: */ gen_a64_set_pc_im(dc, dc->pc); gen_helper_wfi(tcg_ctx, tcg_ctx->cpu_env); + /* The helper doesn't necessarily throw an exception, but we + * must go back to the main loop to check for interrupts anyway. + */ + tcg_gen_exit_tb(tcg_ctx, 0); break; } } diff --git a/qemu/target-arm/translate.c b/qemu/target-arm/translate.c index 0971698c..21c64ea8 100644 --- a/qemu/target-arm/translate.c +++ b/qemu/target-arm/translate.c @@ -11691,6 +11691,10 @@ tb_end: break; case DISAS_WFI: gen_helper_wfi(tcg_ctx, tcg_ctx->cpu_env); + /* The helper doesn't necessarily throw an exception, but we + * must go back to the main loop to check for interrupts anyway. + */ + tcg_gen_exit_tb(tcg_ctx, 0); break; case DISAS_WFE: gen_helper_wfe(tcg_ctx, tcg_ctx->cpu_env);