[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 26/30] bsd-user/signal.c: tswap_siginfo
|
From: |
Warner Losh |
|
Subject: |
[PATCH 26/30] bsd-user/signal.c: tswap_siginfo |
|
Date: |
Sun, 9 Jan 2022 09:19:19 -0700 |
Convert siginfo from targer to host.
Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Kyle Evans <kevans@freebsd.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
bsd-user/signal.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/bsd-user/signal.c b/bsd-user/signal.c
index 934528d5fb0..c954d0f4f37 100644
--- a/bsd-user/signal.c
+++ b/bsd-user/signal.c
@@ -197,6 +197,40 @@ static inline void
host_to_target_siginfo_noswap(target_siginfo_t *tinfo,
}
}
+static void tswap_siginfo(target_siginfo_t *tinfo, const target_siginfo_t
*info)
+{
+ int sig, code;
+
+ sig = info->si_signo;
+ code = info->si_code;
+ tinfo->si_signo = tswap32(sig);
+ tinfo->si_errno = tswap32(info->si_errno);
+ tinfo->si_code = tswap32(info->si_code);
+ tinfo->si_pid = tswap32(info->si_pid);
+ tinfo->si_uid = tswap32(info->si_uid);
+ tinfo->si_status = tswap32(info->si_status);
+ tinfo->si_addr = tswapal(info->si_addr);
+ /*
+ * Unswapped, because we passed it through mostly untouched. si_value is
+ * opaque to the kernel, so we didn't bother with potentially wasting
cycles
+ * to swap it into host byte order.
+ */
+ tinfo->si_value.sival_ptr = info->si_value.sival_ptr;
+ if (SIGILL == sig || SIGFPE == sig || SIGSEGV == sig || SIGBUS == sig ||
+ SIGTRAP == sig) {
+ tinfo->_reason._fault._trapno = tswap32(info->_reason._fault._trapno);
+ }
+#ifdef SIGPOLL
+ if (SIGPOLL == sig) {
+ tinfo->_reason._poll._band = tswap32(info->_reason._poll._band);
+ }
+#endif
+ if (SI_TIMER == code) {
+ tinfo->_reason._timer._timerid =
tswap32(info->_reason._timer._timerid);
+ tinfo->_reason._timer._overrun =
tswap32(info->_reason._timer._overrun);
+ }
+}
+
/* Returns 1 if given signal should dump core if not handled. */
static int core_dump_signal(int sig)
{
--
2.33.1
[PATCH 26/30] bsd-user/signal.c: tswap_siginfo,
Warner Losh <=
[PATCH 28/30] bsd-user/signal.c: implement do_sigreturn, Warner Losh, 2022/01/09
[PATCH 29/30] bsd-user/signal.c: implement do_sigaction, Warner Losh, 2022/01/09
[PATCH 27/30] bsd-user/signal.c: process_pending_signals, Warner Losh, 2022/01/09
[PATCH 30/30] bsd-user/signal.c: do_sigaltstack, Warner Losh, 2022/01/09