summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDouglas Crosher <dtc-ubuntu@scieneer.com>2020-09-22 17:42:41 +1000
committerRichard Henderson <richard.henderson@linaro.org>2021-01-22 12:48:01 -1000
commitbfff072c5035b8dfbdebeb6b9143f3ae8fe9f9f4 (patch)
treedcd2cde5658380681e509bc34457db6d87749408
parent0e32462630687a18039464511bd0447ada5709c3 (diff)
downloadfocaccia-qemu-bfff072c5035b8dfbdebeb6b9143f3ae8fe9f9f4.tar.gz
focaccia-qemu-bfff072c5035b8dfbdebeb6b9143f3ae8fe9f9f4.zip
tcg: update the cpu running flag in cpu_exec_step_atomic
The cpu_exec_step_atomic() function is called with the cpu->running
clear and proceeds to run target code without setting this flag. If
this target code generates an exception then handle_cpu_signal() will
unnecessarily abort.  For example if atomic code generates a memory
protection fault.

This patch at least sets and clears this running flag, and adds some
assertions to help detect other cases.

Signed-off-by: Douglas Crosher <dtc-ubuntu@scieneer.com>
Message-Id: <a272c656-f7c5-019d-1cc0-499b8f80f2fc@scieneer.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
-rw-r--r--accel/tcg/cpu-exec.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index e0df9b6a1d..8053aa3f11 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -285,6 +285,9 @@ void cpu_exec_step_atomic(CPUState *cpu)
 
     if (sigsetjmp(cpu->jmp_env, 0) == 0) {
         start_exclusive();
+        g_assert(cpu == current_cpu);
+        g_assert(!cpu->running);
+        cpu->running = true;
 
         tb = tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags, cf_mask);
         if (tb == NULL) {
@@ -323,6 +326,7 @@ void cpu_exec_step_atomic(CPUState *cpu)
      */
     g_assert(cpu_in_exclusive_context(cpu));
     parallel_cpus = true;
+    cpu->running = false;
     end_exclusive();
 }