From 167ed5762593daaa9c4908de357f7617338d596d Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Thu, 25 Feb 2021 13:17:31 -0500 Subject: [PATCH] target/arm: Remove unnecessary gen_io_end() calls Since commit ba3e7926691ed3 it has been unnecessary for target code to call gen_io_end() after an IO instruction in icount mode; it is sufficient to call gen_io_start() before it and to force the end of the TB. Many now-unnecessary calls to gen_io_end() were removed in commit 9e9b10c6491153b, but some were missed or accidentally added later. Remove unneeded calls from the arm target: * the call in the handling of exception-return-via-LDM is unnecessary, and the code is already forcing end-of-TB * the call in the VFP access check code is more complicated: we weren't ending the TB, so we need to add the code to force that by setting DISAS_UPDATE * the doc comment for ARM_CP_IO doesn't need to mention gen_io_end() any more Backports commit 55c812b74289863c348449135812027d188f040a from qemu --- qemu/target/arm/translate-vfp.inc.c | 7 +++---- qemu/target/arm/translate.c | 3 --- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/qemu/target/arm/translate-vfp.inc.c b/qemu/target/arm/translate-vfp.inc.c index 0b8ab0a3..dfd222b1 100644 --- a/qemu/target/arm/translate-vfp.inc.c +++ b/qemu/target/arm/translate-vfp.inc.c @@ -121,15 +121,14 @@ static bool full_vfp_access_check(DisasContext *s, bool ignore_vfp_enabled) if (s->v7m_lspact) { /* * Lazy state saving affects external memory and also the NVIC, - * so we must mark it as an IO operation for icount. + * so we must mark it as an IO operation for icount (and cause + * this to be the last insn in the TB). */ if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { + s->base.is_jmp = DISAS_UPDATE; gen_io_start(tcg_ctx); } gen_helper_v7m_preserve_fp_state(tcg_ctx, tcg_ctx->cpu_env); - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_io_end(tcg_ctx); - } /* * If the preserve_fp_state helper doesn't throw an exception * then it will clear LSPACT; we don't need to repeat this for diff --git a/qemu/target/arm/translate.c b/qemu/target/arm/translate.c index 00a0f066..84b478b8 100644 --- a/qemu/target/arm/translate.c +++ b/qemu/target/arm/translate.c @@ -8044,9 +8044,6 @@ static bool do_ldm(DisasContext *s, arg_ldst_block *a, int min_n) gen_io_start(tcg_ctx); } gen_helper_cpsr_write_eret(tcg_ctx, tcg_ctx->cpu_env, tmp); - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_io_end(tcg_ctx); - } tcg_temp_free_i32(tcg_ctx, tmp); /* Must exit loop to check un-masked IRQs */ s->base.is_jmp = DISAS_EXIT;