qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Douglas Crosher <dtc-ubuntu@scieneer.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, rth@twiddle.net
Subject: [PATCH] cpu_exec_step_atomic: update the cpu running flag
Date: Tue, 22 Sep 2020 17:42:41 +1000	[thread overview]
Message-ID: <a272c656-f7c5-019d-1cc0-499b8f80f2fc@scieneer.com> (raw)


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	other threads:[~2020-09-22  7:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-22  7:42 Douglas Crosher [this message]
2021-01-15 23:05 ` [PATCH] cpu_exec_step_atomic: update the cpu running flag Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a272c656-f7c5-019d-1cc0-499b8f80f2fc@scieneer.com \
    --to=dtc-ubuntu@scieneer.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).