diff mbox series

[v2,34/35] cpu-exec: assert that plugin_mem_cbs is NULL after execution

Message ID 20230124180127.1881110-35-alex.bennee@linaro.org
State Superseded
Headers show
Series maintainer tree pre-PR (testing/docs/semihosting/plugins) | expand

Commit Message

Alex Bennée Jan. 24, 2023, 6:01 p.m. UTC
From: Emilio Cota <cota@braap.org>

Fixes: #1381

Signed-off-by: Emilio Cota <cota@braap.org>
Message-Id: <20230108165107.62488-1-cota@braap.org>
[AJB: manually applied follow-up fix]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 include/qemu/plugin.h | 4 ++++
 accel/tcg/cpu-exec.c  | 2 ++
 2 files changed, 6 insertions(+)

Comments

Richard Henderson Jan. 24, 2023, 7:46 p.m. UTC | #1
On 1/24/23 08:01, Alex Bennée wrote:
> From: Emilio Cota<cota@braap.org>
> 
> Fixes: #1381
> 
> Signed-off-by: Emilio Cota<cota@braap.org>
> Message-Id:<20230108165107.62488-1-cota@braap.org>
> [AJB: manually applied follow-up fix]
> Signed-off-by: Alex Bennée<alex.bennee@linaro.org>
> ---
>   include/qemu/plugin.h | 4 ++++
>   accel/tcg/cpu-exec.c  | 2 ++
>   2 files changed, 6 insertions(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
Philippe Mathieu-Daudé Jan. 25, 2023, 11:27 p.m. UTC | #2
On 24/1/23 19:01, Alex Bennée wrote:
> From: Emilio Cota <cota@braap.org>
> 
> Fixes: #1381
> 
> Signed-off-by: Emilio Cota <cota@braap.org>
> Message-Id: <20230108165107.62488-1-cota@braap.org>
> [AJB: manually applied follow-up fix]
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>   include/qemu/plugin.h | 4 ++++
>   accel/tcg/cpu-exec.c  | 2 ++
>   2 files changed, 6 insertions(+)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
diff mbox series

Patch

diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h
index e0ebedef84..fb338ba576 100644
--- a/include/qemu/plugin.h
+++ b/include/qemu/plugin.h
@@ -59,6 +59,8 @@  get_plugin_meminfo_rw(qemu_plugin_meminfo_t i)
 #ifdef CONFIG_PLUGIN
 extern QemuOptsList qemu_plugin_opts;
 
+#define QEMU_PLUGIN_ASSERT(cond) g_assert(cond)
+
 static inline void qemu_plugin_add_opts(void)
 {
     qemu_add_opts(&qemu_plugin_opts);
@@ -250,6 +252,8 @@  void qemu_plugin_user_postfork(bool is_child);
 
 #else /* !CONFIG_PLUGIN */
 
+#define QEMU_PLUGIN_ASSERT(cond)
+
 static inline void qemu_plugin_add_opts(void)
 { }
 
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 25ec73ef9a..9c857eeb07 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -504,6 +504,7 @@  static void cpu_exec_exit(CPUState *cpu)
     if (cc->tcg_ops->cpu_exec_exit) {
         cc->tcg_ops->cpu_exec_exit(cpu);
     }
+    QEMU_PLUGIN_ASSERT(cpu->plugin_mem_cbs == NULL);
 }
 
 void cpu_exec_step_atomic(CPUState *cpu)
@@ -980,6 +981,7 @@  cpu_exec_loop(CPUState *cpu, SyncClocks *sc)
 
             cpu_loop_exec_tb(cpu, tb, pc, &last_tb, &tb_exit);
 
+            QEMU_PLUGIN_ASSERT(cpu->plugin_mem_cbs == NULL);
             /* Try to align the host and virtual clocks
                if the guest is in advance */
             align_clocks(sc, cpu);