From: Emilio Cota Date: Tue, 24 Jan 2023 18:01:24 +0000 (+0000) Subject: translator: always pair plugin_gen_insn_{start, end} calls X-Git-Tag: v8.0.0-rc0~80^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0f92d94ae37952ed3e6771bc429de4b739eb6ca3;p=thirdparty%2Fqemu.git translator: always pair plugin_gen_insn_{start, end} calls Related: #1381 Signed-off-by: Emilio Cota Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20230108164731.61469-3-cota@braap.org> Signed-off-by: Alex Bennée Message-Id: <20230124180127.1881110-33-alex.bennee@linaro.org> --- diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index 061519691f9..ef5193c67e3 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -100,19 +100,24 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int max_insns, ops->translate_insn(db, cpu); } - /* Stop translation if translate_insn so indicated. */ - if (db->is_jmp != DISAS_NEXT) { - break; - } - /* * We can't instrument after instructions that change control * flow although this only really affects post-load operations. + * + * Calling plugin_gen_insn_end() before we possibly stop translation + * is important. Even if this ends up as dead code, plugin generation + * needs to see a matching plugin_gen_insn_{start,end}() pair in order + * to accurately track instrumented helpers that might access memory. */ if (plugin_enabled) { plugin_gen_insn_end(); } + /* Stop translation if translate_insn so indicated. */ + if (db->is_jmp != DISAS_NEXT) { + break; + } + /* Stop translation if the output buffer is full, or we have executed all of the allowed instructions. */ if (tcg_op_buf_full() || db->num_insns >= db->max_insns) {