From 2929d46e7df92d1a9c99097f687d9ba7ad90386e Mon Sep 17 00:00:00 2001 From: Pierrick Bouvier Date: Mon, 23 Dec 2024 11:30:00 -0800 Subject: [PATCH] accel/tcg: fix plugin instrumentation missing for some instructions This commit corrects CF_MEMI_ONLY flag. It was initially introduced (cfd405ea) to avoid double instrumentation on instructions which are recompiled when using icount, because associated to an MMIO access. However, we observed that some instructions were not instrumented, so we should set this flag only when recompiling a record/replay branch. Signed-off-by: Pierrick Bouvier --- accel/tcg/translate-all.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 572a8a879725..e31320e2a43b 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -625,15 +625,18 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr) cc->tcg_ops->io_recompile_replay_branch(cpu, tb)) { cpu->neg.icount_decr.u16.low++; n = 2; + /* + * Limit instrumentation to memory operations only (which execute after + * completion), so we don't double instrument the instruction. + */ + n |= CF_MEMI_ONLY; } /* - * Exit the loop and potentially generate a new TB executing the - * just the I/O insns. We also limit instrumentation to memory - * operations only (which execute after completion) so we don't - * double instrument the instruction. + * Exit the loop and potentially generate a new TB executing just the + * I/O insns. */ - cpu->cflags_next_tb = curr_cflags(cpu) | CF_MEMI_ONLY | n; + cpu->cflags_next_tb = curr_cflags(cpu) | n; if (qemu_loglevel_mask(CPU_LOG_EXEC)) { vaddr pc = cpu->cc->get_pc(cpu);