diff mbox series

[15/18] cpu: Set current_cpu early in qemu-user

Message ID 20240923162208.90745-16-iii@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series Stop all qemu-cpu threads on a breakpoint | expand

Commit Message

Ilya Leoshkevich Sept. 23, 2024, 4:13 p.m. UTC
qemu_plugin_get_registers() may be called before cpu_exec(), and it
requires current_cpu.

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

Patch

diff --git a/bsd-user/main.c b/bsd-user/main.c
index b424a21f643..fb70aadbcee 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -617,6 +617,7 @@  int main(int argc, char **argv)
         gdbserver_start(gdbstub);
         gdb_handlesig(cpu, 0, NULL, NULL, 0);
     }
+    current_cpu = cpu;
     cpu_loop(env);
     /* never exits */
     return 0;
diff --git a/linux-user/main.c b/linux-user/main.c
index 60091cf3053..4a794445d72 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -1022,6 +1022,7 @@  int main(int argc, char **argv, char **envp)
     qemu_semihosting_guestfd_init();
 #endif
 
+    current_cpu = cpu;
     cpu_loop(env);
     /* never exits */
     return 0;
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 344c2e65234..46a8ba7098c 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -6531,6 +6531,7 @@  static void *clone_func(void *arg)
     pthread_mutex_lock(&clone_lock);
     pthread_mutex_unlock(&clone_lock);
     bql_lock();
+    current_cpu = cpu;
     cpu_loop(env);
     /* never exits */
     return NULL;