[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 33/40] bsd-user/signal.c: tswap_siginfo
From: |
Warner Losh |
Subject: |
[PATCH v3 33/40] bsd-user/signal.c: tswap_siginfo |
Date: |
Fri, 28 Jan 2022 16:27:58 -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>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
bsd-user/signal.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/bsd-user/signal.c b/bsd-user/signal.c
index 366e047cccc..34e8c811ad6 100644
--- a/bsd-user/signal.c
+++ b/bsd-user/signal.c
@@ -256,6 +256,59 @@ static inline void
host_to_target_siginfo_noswap(target_siginfo_t *tinfo,
tinfo->si_code = deposit32(si_code, 24, 8, si_type);
}
+static void tswap_siginfo(target_siginfo_t *tinfo, const target_siginfo_t
*info)
+{
+ int si_type = extract32(info->si_code, 24, 8);
+ int si_code = sextract32(info->si_code, 0, 24);
+
+ __put_user(info->si_signo, &tinfo->si_signo);
+ __put_user(info->si_errno, &tinfo->si_errno);
+ __put_user(si_code, &tinfo->si_code); /* Zero out si_type, it's internal */
+ __put_user(info->si_pid, &tinfo->si_pid);
+ __put_user(info->si_uid, &tinfo->si_uid);
+ __put_user(info->si_status, &tinfo->si_status);
+ __put_user(info->si_addr, &tinfo->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;
+
+ /*
+ * We can use our internal marker of which fields in the structure
+ * are valid, rather than duplicating the guesswork of
+ * host_to_target_siginfo_noswap() here.
+ */
+ switch (si_type) {
+ case QEMU_SI_NOINFO: /* No additional info */
+ break;
+ case QEMU_SI_FAULT:
+ __put_user(info->_reason._fault._trapno,
+ &tinfo->_reason._fault._trapno);
+ break;
+ case QEMU_SI_TIMER:
+ __put_user(info->_reason._timer._timerid,
+ &tinfo->_reason._timer._timerid);
+ __put_user(info->_reason._timer._overrun,
+ &tinfo->_reason._timer._overrun);
+ break;
+ case QEMU_SI_MESGQ:
+ __put_user(info->_reason._mesgq._mqd, &tinfo->_reason._mesgq._mqd);
+ break;
+ case QEMU_SI_POLL:
+ /* Note: Not generated on FreeBSD */
+ __put_user(info->_reason._poll._band, &tinfo->_reason._poll._band);
+ break;
+ case QEMU_SI_CAPSICUM:
+ __put_user(info->_reason._capsicum._syscall,
+ &tinfo->_reason._capsicum._syscall);
+ break;
+ default:
+ g_assert_not_reached();
+ }
+}
+
/* Returns 1 if given signal should dump core if not handled. */
static int core_dump_signal(int sig)
{
--
2.33.1
- [PATCH v3 28/40] bsd-user/signal.c: Implement dump_core_and_abort, (continued)
- [PATCH v3 28/40] bsd-user/signal.c: Implement dump_core_and_abort, Warner Losh, 2022/01/28
- [PATCH v3 32/40] bsd-user/signal.c: handle_pending_signal, Warner Losh, 2022/01/28
- [PATCH v3 40/40] bsd-user/freebsd/target_os_ucontext.h: Prefer env as arg name for CPUArchState args, Warner Losh, 2022/01/28
- [PATCH v3 39/40] bsd-user: Rename arg name for target_cpu_reset to env, Warner Losh, 2022/01/28
- [PATCH v3 30/40] bsd-user/signal.c: sigset manipulation routines., Warner Losh, 2022/01/28
- [PATCH v3 37/40] bsd-user/signal.c: do_sigaltstack, Warner Losh, 2022/01/28
- [PATCH v3 19/40] bsd-user/host/arm/host-signal.h: Implement host_signal_*, Warner Losh, 2022/01/28
- [PATCH v3 29/40] bsd-user/signal.c: Fill in queue_signal, Warner Losh, 2022/01/28
- [PATCH v3 31/40] bsd-user/signal.c: setup_frame, Warner Losh, 2022/01/28
- [PATCH v3 27/40] bsd-user/strace.c: print_taken_signal, Warner Losh, 2022/01/28
- [PATCH v3 33/40] bsd-user/signal.c: tswap_siginfo,
Warner Losh <=
- [PATCH v3 34/40] bsd-user/signal.c: process_pending_signals, Warner Losh, 2022/01/28
- [PATCH v3 38/40] MAINTAINERS: Add tests/vm/*bsd to the list to get reviews on, Warner Losh, 2022/01/28