All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ilya Leoshkevich <iii@linux.ibm.com>
To: "Alex Bennée" <alex.bennee@linaro.org>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: qemu-devel@nongnu.org, Ilya Leoshkevich <iii@linux.ibm.com>
Subject: [PATCH 1/3] cpu: Set current_cpu early in qemu-user
Date: Mon, 13 Jan 2025 14:36:27 +0100	[thread overview]
Message-ID: <20250113134658.68376-2-iii@linux.ibm.com> (raw)
In-Reply-To: <20250113134658.68376-1-iii@linux.ibm.com>

gdb_handlesig() uses current_cpu.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
 bsd-user/main.c      | 2 ++
 linux-user/main.c    | 2 ++
 linux-user/syscall.c | 1 +
 3 files changed, 5 insertions(+)

diff --git a/bsd-user/main.c b/bsd-user/main.c
index 0a5bc578365..aa052e515c9 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -627,6 +627,8 @@ int main(int argc, char **argv)
 
     target_cpu_init(env, regs);
 
+    current_cpu = cpu;
+
     if (gdbstub) {
         gdbserver_start(gdbstub);
         gdb_handlesig(cpu, 0, NULL, NULL, 0);
diff --git a/linux-user/main.c b/linux-user/main.c
index b97634a32dd..b2bf0688617 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -1022,6 +1022,8 @@ int main(int argc, char **argv, char **envp)
 
     target_cpu_copy_regs(env, regs);
 
+    current_cpu = cpu;
+
     if (gdbstub) {
         if (gdbserver_start(gdbstub) < 0) {
             fprintf(stderr, "qemu: could not open gdbserver on %s\n",
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 78c7c0b34ef..a101f177632 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -6542,6 +6542,7 @@ static void *clone_func(void *arg)
     env = info->env;
     cpu = env_cpu(env);
     thread_cpu = cpu;
+    current_cpu = cpu;
     ts = get_task_state(cpu);
     info->tid = sys_gettid();
     task_settid(ts);
-- 
2.47.1



  reply	other threads:[~2025-01-13 13:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-13 13:36 [PATCH 0/3] gdbstub: Protect gdb_handlesig() with EXCLUSIVE_GUARD() Ilya Leoshkevich
2025-01-13 13:36 ` Ilya Leoshkevich [this message]
2025-01-13 13:36 ` [PATCH 2/3] cpu: Introduce EXCLUSIVE_GUARD() Ilya Leoshkevich
2025-01-13 13:36 ` [PATCH 3/3] gdbstub: Protect gdb_handlesig() with EXCLUSIVE_GUARD() Ilya Leoshkevich

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=20250113134658.68376-2-iii@linux.ibm.com \
    --to=iii@linux.ibm.com \
    --cc=alex.bennee@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.