[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 12/18] cpu: Track CPUs executing syscalls
From: |
Ilya Leoshkevich |
Subject: |
[PATCH 12/18] cpu: Track CPUs executing syscalls |
Date: |
Mon, 23 Sep 2024 18:13:07 +0200 |
CPUs that execute syscalls should be considered paused by
all_vcpus_paused(). Lay the groundwork by introducing a bool field in
CPUState to track this. The field is not used by sysemu, but it's only
one byte, so it should not be a problem.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
accel/tcg/user-exec.c | 10 ++++++++++
bsd-user/freebsd/os-syscall.c | 4 ++++
include/exec/cpu-common.h | 2 ++
include/hw/core/cpu.h | 1 +
linux-user/syscall.c | 5 +++++
5 files changed, 22 insertions(+)
diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
index 7bd6e94b8e8..3ebace1e833 100644
--- a/accel/tcg/user-exec.c
+++ b/accel/tcg/user-exec.c
@@ -1307,3 +1307,13 @@ void qemu_cpu_kick(CPUState *cpu)
{
cpu_exit(cpu);
}
+
+void cpu_enter_syscall(CPUState *cs)
+{
+ cs->in_syscall = true;
+}
+
+void cpu_exit_syscall(CPUState *cs)
+{
+ cs->in_syscall = false;
+}
diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c
index c2849d43223..9f54345e11b 100644
--- a/bsd-user/freebsd/os-syscall.c
+++ b/bsd-user/freebsd/os-syscall.c
@@ -936,6 +936,8 @@ abi_long do_freebsd_syscall(void *cpu_env, int num,
abi_long arg1,
{
abi_long ret;
+ cpu_enter_syscall(env_cpu(cpu_env));
+
bql_unlock();
if (do_strace) {
@@ -951,6 +953,8 @@ abi_long do_freebsd_syscall(void *cpu_env, int num,
abi_long arg1,
bql_lock();
+ cpu_exit_syscall(env_cpu(cpu_env));
+
return ret;
}
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index 4a7b43f9aa3..32bd3cad83f 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -228,6 +228,8 @@ G_NORETURN void cpu_loop_exit_restore(CPUState *cpu,
uintptr_t pc);
int cpu_exec(CPUState *cpu);
/* accel/tcg/user-exec.c */
int cpu_exec_user(CPUState *cs);
+void cpu_enter_syscall(CPUState *cs);
+void cpu_exit_syscall(CPUState *cs);
/**
* env_archcpu(env)
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 1c9c775df65..d073a79731b 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -475,6 +475,7 @@ struct CPUState {
bool created;
bool stop;
bool stopped;
+ bool in_syscall;
/* Should CPU start in powered-off state? */
bool start_powered_off;
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index ff34ae11340..344c2e65234 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -13771,6 +13771,8 @@ abi_long do_syscall(CPUArchState *cpu_env, int num,
abi_long arg1,
}
#endif
+ cpu_enter_syscall(cpu);
+
record_syscall_start(cpu, num, arg1,
arg2, arg3, arg4, arg5, arg6, arg7, arg8);
@@ -13791,5 +13793,8 @@ abi_long do_syscall(CPUArchState *cpu_env, int num,
abi_long arg1,
bql_lock();
record_syscall_return(cpu, num, ret);
+
+ cpu_exit_syscall(cpu);
+
return ret;
}
--
2.46.0
- [PATCH 00/18] Stop all qemu-cpu threads on a breakpoint, Ilya Leoshkevich, 2024/09/23
- [PATCH 03/18] gdbstub: Move gdb_syscall_mode to GDBSyscallState, Ilya Leoshkevich, 2024/09/23
- [PATCH 02/18] gdbstub: Move phy_memory_mode to GDBSystemState, Ilya Leoshkevich, 2024/09/23
- [PATCH 04/18] gdbstub: Factor out gdb_try_stop(), Ilya Leoshkevich, 2024/09/23
- [PATCH 08/18] replay: Add replay_mutex_{lock, unlock}() stubs for qemu-user, Ilya Leoshkevich, 2024/09/23
- [PATCH 10/18] cpu: Use BQL in qemu-user, Ilya Leoshkevich, 2024/09/23
- [PATCH 16/18] cpu: Allow pausing and resuming CPUs in qemu-user, Ilya Leoshkevich, 2024/09/23
- [PATCH 05/18] accel/tcg: Factor out cpu_exec_user(), Ilya Leoshkevich, 2024/09/23
- [PATCH 15/18] cpu: Set current_cpu early in qemu-user, Ilya Leoshkevich, 2024/09/23
- [PATCH 14/18] cpu: Introduce cpu_is_paused(), Ilya Leoshkevich, 2024/09/23
- [PATCH 12/18] cpu: Track CPUs executing syscalls,
Ilya Leoshkevich <=
- [PATCH 01/18] gdbstub: Make gdb_get_char() static, Ilya Leoshkevich, 2024/09/23
- [PATCH 09/18] qemu-timer: Provide qemu_clock_enable() stub for qemu-user, Ilya Leoshkevich, 2024/09/23
- [PATCH 06/18] qemu-thread: Introduce QEMU_MUTEX_INITIALIZER, Ilya Leoshkevich, 2024/09/23
- [PATCH 18/18] tests/tcg: Stress test thread breakpoints, Ilya Leoshkevich, 2024/09/23
- [PATCH 13/18] cpu: Implement cpu_thread_is_idle() for qemu-user, Ilya Leoshkevich, 2024/09/23
- [PATCH 07/18] qemu-thread: Introduce QEMU_COND_INITIALIZER, Ilya Leoshkevich, 2024/09/23
- [PATCH 11/18] accel/tcg: Unify user implementations of qemu_cpu_kick(), Ilya Leoshkevich, 2024/09/23
- [PATCH 17/18] gdbstub: Pause all CPUs before sending stop replies, Ilya Leoshkevich, 2024/09/23
- Re: [PATCH 00/18] Stop all qemu-cpu threads on a breakpoint, Ilya Leoshkevich, 2024/09/23
- Re: [PATCH 00/18] Stop all qemu-cpu threads on a breakpoint, Richard Henderson, 2024/09/25