qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: fam@euphon.net, berrange@redhat.com,
	"David Hildenbrand" <david@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	f4bug@amsat.org, stefanha@redhat.com, crosa@redhat.com,
	pbonzini@redhat.com,
	"Pavel Dovgalyuk" <Pavel.Dovgalyuk@ispras.ru>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	aurelien@aurel32.net
Subject: [PATCH  v1 1/7] softmmu: fix watchpoint-interrupt races
Date: Tue, 23 Nov 2021 20:57:23 +0000	[thread overview]
Message-ID: <20211123205729.2205806-2-alex.bennee@linaro.org> (raw)
In-Reply-To: <20211123205729.2205806-1-alex.bennee@linaro.org>

From: Pavel Dovgalyuk <pavel.dovgalyuk@ispras.ru>

Watchpoint may be processed in two phases. First one is detecting
the instruction with target memory access. And the second one is
executing only one instruction and setting the debug interrupt flag.
Hardware interrupts can break this sequence when they happen after
the first watchpoint phase.
This patch postpones the interrupt request until watchpoint is
processed.

Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Message-Id: <163662451431.125458.14945698834107669531.stgit@pasha-ThinkPad-X280>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 accel/tcg/cpu-exec.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 2d14d02f6c..9cb892e326 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -742,6 +742,11 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
             qemu_mutex_unlock_iothread();
             return true;
         }
+        /* Process watchpoints first, or interrupts will ruin everything */
+        if (cpu->watchpoint_hit) {
+            qemu_mutex_unlock_iothread();
+            return false;
+        }
 #if !defined(CONFIG_USER_ONLY)
         if (replay_mode == REPLAY_MODE_PLAY && !replay_has_interrupt()) {
             /* Do nothing */
-- 
2.30.2



  reply	other threads:[~2021-11-23 21:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-23 20:57 [PATCH for 6.2 v1 0/7] more tcg, plugin, test and build fixes Alex Bennée
2021-11-23 20:57 ` Alex Bennée [this message]
2021-11-24  7:38   ` [PATCH v1 1/7] softmmu: fix watchpoint-interrupt races Richard Henderson
2021-11-24 10:22     ` Alex Bennée
2021-11-23 20:57 ` [PATCH v1 2/7] accel/tcg: suppress IRQ check for special TBs Alex Bennée
2021-11-24  9:23   ` Richard Henderson
2021-11-24 10:24     ` Alex Bennée
2021-11-24 14:42       ` Richard Henderson
2021-11-24 16:04         ` Alex Bennée
2021-11-23 20:57 ` [PATCH v1 3/7] tests/avocado: fix tcg_plugin mem access count test Alex Bennée
2021-11-24  7:20   ` Philippe Mathieu-Daudé
2021-11-24  9:30   ` Richard Henderson
2021-11-23 20:57 ` [PATCH v1 4/7] plugins/meson.build: fix linker issue with weird paths Alex Bennée
2021-11-24  7:18   ` Philippe Mathieu-Daudé
2021-11-23 20:57 ` [PATCH v1 5/7] gdbstub: handle a potentially racing TaskState Alex Bennée
2021-11-23 20:57 ` [PATCH v1 6/7] MAINTAINERS: Remove me as a reviewer for the build and test/avocado Alex Bennée
2021-11-23 20:57 ` [PATCH v1 7/7] MAINTAINERS: Add section for Aarch64 GitLab custom runner Alex Bennée

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=20211123205729.2205806-2-alex.bennee@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=Pavel.Dovgalyuk@ispras.ru \
    --cc=aurelien@aurel32.net \
    --cc=berrange@redhat.com \
    --cc=crosa@redhat.com \
    --cc=david@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=fam@euphon.net \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=stefanha@redhat.com \
    /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).