[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 34/40] bsd-user/signal.c: process_pending_signals
|
From: |
Warner Losh |
|
Subject: |
[PULL 34/40] bsd-user/signal.c: process_pending_signals |
|
Date: |
Mon, 31 Jan 2022 12:56:30 -0700 |
Process the currently queued signals.
Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Kyle Evans <kevans@freebsd.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
bsd-user/signal.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 55 insertions(+), 1 deletion(-)
diff --git a/bsd-user/signal.c b/bsd-user/signal.c
index 34e8c811ad6..4b398745f45 100644
--- a/bsd-user/signal.c
+++ b/bsd-user/signal.c
@@ -756,8 +756,62 @@ static void handle_pending_signal(CPUArchState *env, int
sig,
}
}
-void process_pending_signals(CPUArchState *cpu_env)
+void process_pending_signals(CPUArchState *env)
{
+ CPUState *cpu = env_cpu(env);
+ int sig;
+ sigset_t *blocked_set, set;
+ struct emulated_sigtable *k;
+ TaskState *ts = cpu->opaque;
+
+ while (qatomic_read(&ts->signal_pending)) {
+ sigfillset(&set);
+ sigprocmask(SIG_SETMASK, &set, 0);
+
+ restart_scan:
+ sig = ts->sync_signal.pending;
+ if (sig) {
+ /*
+ * Synchronous signals are forced by the emulated CPU in some way.
+ * If they are set to ignore, restore the default handler (see
+ * sys/kern_sig.c trapsignal() and execsigs() for this behavior)
+ * though maybe this is done only when forcing exit for non
SIGCHLD.
+ */
+ if (sigismember(&ts->signal_mask, target_to_host_signal(sig)) ||
+ sigact_table[sig - 1]._sa_handler == TARGET_SIG_IGN) {
+ sigdelset(&ts->signal_mask, target_to_host_signal(sig));
+ sigact_table[sig - 1]._sa_handler = TARGET_SIG_DFL;
+ }
+ handle_pending_signal(env, sig, &ts->sync_signal);
+ }
+
+ k = ts->sigtab;
+ for (sig = 1; sig <= TARGET_NSIG; sig++, k++) {
+ blocked_set = ts->in_sigsuspend ?
+ &ts->sigsuspend_mask : &ts->signal_mask;
+ if (k->pending &&
+ !sigismember(blocked_set, target_to_host_signal(sig))) {
+ handle_pending_signal(env, sig, k);
+ /*
+ * Restart scan from the beginning, as handle_pending_signal
+ * might have resulted in a new synchronous signal (eg
SIGSEGV).
+ */
+ goto restart_scan;
+ }
+ }
+
+ /*
+ * Unblock signals and check one more time. Unblocking signals may
cause
+ * us to take another host signal, which will set signal_pending again.
+ */
+ qatomic_set(&ts->signal_pending, 0);
+ ts->in_sigsuspend = false;
+ set = ts->signal_mask;
+ sigdelset(&set, SIGSEGV);
+ sigdelset(&set, SIGBUS);
+ sigprocmask(SIG_SETMASK, &set, 0);
+ }
+ ts->in_sigsuspend = false;
}
void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr,
--
2.33.1
- [PULL 39/40] bsd-user: Rename arg name for target_cpu_reset to env, (continued)
- [PULL 39/40] bsd-user: Rename arg name for target_cpu_reset to env, Warner Losh, 2022/01/31
- [PULL 26/40] bsd-user/signal.c: Implement host_signal_handler, Warner Losh, 2022/01/31
- [PULL 23/40] bsd-user: Add trace events for bsd-user, Warner Losh, 2022/01/31
- [PULL 31/40] bsd-user/signal.c: setup_frame, Warner Losh, 2022/01/31
- [PULL 17/40] bsd-user/signal.c: Implement signal_init(), Warner Losh, 2022/01/31
- [PULL 20/40] bsd-user/host/i386/host-signal.h: Implement host_signal_*, Warner Losh, 2022/01/31
- [PULL 02/40] bsd-user: Create setup_sigframe_arch to setup sigframe context, Warner Losh, 2022/01/31
- [PULL 15/40] bsd-user/arm/target_arch_cpu.h: Implement data faults, Warner Losh, 2022/01/31
- [PULL 27/40] bsd-user/strace.c: print_taken_signal, Warner Losh, 2022/01/31
- [PULL 28/40] bsd-user/signal.c: Implement dump_core_and_abort, Warner Losh, 2022/01/31
- [PULL 34/40] bsd-user/signal.c: process_pending_signals,
Warner Losh <=
- [PULL 16/40] bsd-user/signal.c: implement abstract target / host signal translation, Warner Losh, 2022/01/31
- [PULL 13/40] bsd-user/arm/target_arch_cpu.h: Correct code pointer, Warner Losh, 2022/01/31
- [PULL 32/40] bsd-user/signal.c: handle_pending_signal, Warner Losh, 2022/01/31
- [PULL 33/40] bsd-user/signal.c: tswap_siginfo, Warner Losh, 2022/01/31
- [PULL 08/40] bsd-user/signal.c: implement force_sig_fault, Warner Losh, 2022/01/31
- [PULL 40/40] bsd-user/freebsd/target_os_ucontext.h: Prefer env as arg name for CPUArchState args, Warner Losh, 2022/01/31
- [PULL 38/40] MAINTAINERS: Add tests/vm/*bsd to the list to get reviews on, Warner Losh, 2022/01/31
- [PULL 18/40] bsd-user/signal.c: Add si_type argument to queue_signal, Warner Losh, 2022/01/31
- [PULL 25/40] bsd-user/signal.c: Implement rewind_if_in_safe_syscall, Warner Losh, 2022/01/31
- [PULL 03/40] bsd-user/arm/signal.c: Implement setup_sigframe_arch for arm, Warner Losh, 2022/01/31