qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] cpu_exec_step_atomic: update the cpu running flag


From: Douglas Crosher
Subject: [PATCH] cpu_exec_step_atomic: update the cpu running flag
Date: Tue, 22 Sep 2020 17:42:41 +1000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0


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.

The related code paths look rather convoluted and it is not immediately clear that this patch comprehensively addresses the issue, but it might at least direct people to a problem, and it might be an incremental improvement, and it gets some code running here. The patch adds some assertions to help detect other cases.

Signed-off-by: Douglas Crosher <dtc-ubuntu@scieneer.com>
---
 accel/tcg/cpu-exec.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 66d38f9d85..c1cf1a01cb 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -241,6 +241,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) {
@@ -279,6 +282,7 @@ void cpu_exec_step_atomic(CPUState *cpu)
      */
     g_assert(cpu_in_exclusive_context(cpu));
     parallel_cpus = true;
+    cpu->running = false;
     end_exclusive();
 }

--
2.25.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]