diff mbox series

[1/3] cpu: Set current_cpu early in qemu-user

Message ID 20250113134658.68376-2-iii@linux.ibm.com (mailing list archive)
State New
Headers show
Series gdbstub: Protect gdb_handlesig() with EXCLUSIVE_GUARD() | expand

Commit Message

Ilya Leoshkevich Jan. 13, 2025, 1:36 p.m. UTC
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 mbox series

Patch

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);