Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src/sys/compat/netbsd32 Pull up following revision(s) (reques...
details: https://anonhg.NetBSD.org/src/rev/f3531dd8227c
branches: netbsd-9
changeset: 461233:f3531dd8227c
user: martin <martin%NetBSD.org@localhost>
date: Tue Nov 19 13:33:21 2019 +0000
description:
Pull up following revision(s) (requested by rin in ticket #456):
sys/compat/netbsd32/netbsd32_signal.c: revision 1.46
sys/compat/netbsd32/netbsd32_signal.c: revision 1.47
sys/compat/netbsd32/netbsd32_signal.c: revision 1.48
sys/compat/netbsd32/netbsd32_signal.c: revision 1.49
sys/compat/netbsd32/netbsd32_signal.c: revision 1.50
Belatedly catch up with kern_sig.c rev 1.358:
Provide syscall information with SIGTRAP TRAP_SCE/TRAP_SCX so that
picotrace/truss, for example, works fine on COMPAT_NETBSD32.
With some minor changes:
- Centralize netbsd32_si{,32}_si{32,}() into netbsd32_ksi{,32}_ksi{32,}().
- Provide si_status with SIGCHLD.
- Remove the remaining of SA.
Sort by signal numbers as far as possible, adjust locations of functions.
No functional changes intended.
XXX
pullup to netbsd-9
Provide _ptrace_state for SIGTRAP with TRAP_EXEC, TRAP_CHLD, or TRAP_LWP.
Pointed out by kamil. Thanks!
XXX
pullup to netbsd-9
When converting siginfo, examine si_code at the beginning,
as explained in siginfo(2).
- If it is SI_NOINFO, there's no additional information.
- If it is non-positive, i.e., codes described in siginfo(2),
we need to fill in _rt.
XXX
Description for SA_ASYNCIO in siginfo(2) seems outdated;
neither si_fd nor si_band are filled in with that code.
XXX
pullup to netbsd-9
TRAP_EXEC does not have extra fields to be filled in at the moment.
Explicitly ignore fields for now.
Pointed out by kamil. Thanks!
XXX
pullup to netbsd-9
diffstat:
sys/compat/netbsd32/netbsd32_signal.c | 246 +++++++++++++++++----------------
1 files changed, 127 insertions(+), 119 deletions(-)
diffs (truncated from 320 to 300 lines):
diff -r 41f6da980c36 -r f3531dd8227c sys/compat/netbsd32/netbsd32_signal.c
--- a/sys/compat/netbsd32/netbsd32_signal.c Tue Nov 19 13:22:01 2019 +0000
+++ b/sys/compat/netbsd32/netbsd32_signal.c Tue Nov 19 13:33:21 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_signal.c,v 1.45 2017/12/17 20:59:27 christos Exp $ */
+/* $NetBSD: netbsd32_signal.c,v 1.45.8.1 2019/11/19 13:33:21 martin Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_signal.c,v 1.45 2017/12/17 20:59:27 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_signal.c,v 1.45.8.1 2019/11/19 13:33:21 martin Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ktrace.h"
@@ -188,128 +188,81 @@
void
netbsd32_ksi32_to_ksi(struct _ksiginfo *si, const struct __ksiginfo32 *si32)
{
+ size_t i;
+
memset(si, 0, sizeof (*si));
si->_signo = si32->_signo;
si->_code = si32->_code;
si->_errno = si32->_errno;
+ if (si32->_code == SI_NOINFO)
+ return;
+ else if (si32->_code <= 0) /* codes described in siginfo(2) */
+ goto fill_rt;
+
switch (si32->_signo) {
case SIGILL:
+ case SIGFPE:
case SIGBUS:
case SIGSEGV:
- case SIGFPE:
- case SIGTRAP:
+fill_fault:
si->_reason._fault._addr =
NETBSD32IPTR64(si32->_reason._fault._addr);
si->_reason._fault._trap = si32->_reason._fault._trap;
break;
+ case SIGTRAP:
+ switch (si32->_code) {
+ case TRAP_EXEC:
+ break;
+ case TRAP_CHLD:
+ case TRAP_LWP:
+ si->_reason._ptrace_state._pe_report_event =
+ si32->_reason._ptrace_state._pe_report_event;
+CTASSERT(sizeof(si->_reason._ptrace_state._option._pe_other_pid) ==
+ sizeof(si->_reason._ptrace_state._option._pe_lwp));
+ si->_reason._ptrace_state._option._pe_other_pid =
+ si32->_reason._ptrace_state._option._pe_other_pid;
+ break;
+ case TRAP_SCE:
+ case TRAP_SCX:
+ si->_reason._syscall._sysnum =
+ si32->_reason._syscall._sysnum;
+ si->_reason._syscall._retval[0] =
+ si32->_reason._syscall._retval[0];
+ si->_reason._syscall._retval[1] =
+ si32->_reason._syscall._retval[1];
+ si->_reason._syscall._error =
+ si32->_reason._syscall._error;
+ for (i = 0;
+ i < __arraycount(si->_reason._syscall._args); i++)
+ si->_reason._syscall._args[i] =
+ si32->_reason._syscall._args[i];
+ break;
+ default:
+ goto fill_fault;
+ }
+ break;
case SIGALRM:
case SIGVTALRM:
case SIGPROF:
default: /* see sigqueue() and kill1() */
+fill_rt:
si->_reason._rt._pid = si32->_reason._rt._pid;
si->_reason._rt._uid = si32->_reason._rt._uid;
si->_reason._rt._value.sival_int =
si32->_reason._rt._value.sival_int;
break;
- case SIGCHLD:
- si->_reason._child._pid = si32->_reason._child._pid;
- si->_reason._child._uid = si32->_reason._child._uid;
- si->_reason._child._utime = si32->_reason._child._utime;
- si->_reason._child._stime = si32->_reason._child._stime;
- break;
case SIGURG:
case SIGIO:
si->_reason._poll._band = si32->_reason._poll._band;
si->_reason._poll._fd = si32->_reason._poll._fd;
break;
- }
-}
-
-#ifdef notyet
-#ifdef KTRACE
-static void
-netbsd32_ksi_to_ksi32(struct __ksiginfo32 *si32, const struct _ksiginfo *si)
-{
- memset(si32, 0, sizeof (*si32));
- si32->_signo = si->_signo;
- si32->_code = si->_code;
- si32->_errno = si->_errno;
-
- switch (si->_signo) {
- case SIGILL:
- case SIGBUS:
- case SIGSEGV:
- case SIGFPE:
- case SIGTRAP:
- si32->_reason._fault._addr =
- NETBSD32PTR32I(si->_reason._fault._addr);
- si32->_reason._fault._trap = si->_reason._fault._trap;
- break;
- case SIGALRM:
- case SIGVTALRM:
- case SIGPROF:
- default: /* see sigqueue() and kill1() */
- si32->_reason._rt._pid = si->_reason._rt._pid;
- si32->_reason._rt._uid = si->_reason._rt._uid;
- si32->_reason._rt._value.sival_int =
- si->_reason._rt._value.sival_int;
- break;
case SIGCHLD:
- si32->_reason._child._pid = si->_reason._child._pid;
- si32->_reason._child._uid = si->_reason._child._uid;
- si32->_reason._child._utime = si->_reason._child._utime;
- si32->_reason._child._stime = si->_reason._child._stime;
- break;
- case SIGURG:
- case SIGIO:
- si32->_reason._poll._band = si->_reason._poll._band;
- si32->_reason._poll._fd = si->_reason._poll._fd;
- break;
- }
-}
-#endif
-#endif
-
-void
-netbsd32_si_to_si32(siginfo32_t *si32, const siginfo_t *si)
-{
- memset(si32, 0, sizeof (*si32));
- si32->si_signo = si->si_signo;
- si32->si_code = si->si_code;
- si32->si_errno = si->si_errno;
-
- switch (si32->si_signo) {
- case 0: /* SA */
- si32->si_value.sival_int = si->si_value.sival_int;
- break;
- case SIGILL:
- case SIGBUS:
- case SIGSEGV:
- case SIGFPE:
- case SIGTRAP:
- si32->si_addr = (uint32_t)(uintptr_t)si->si_addr;
- si32->si_trap = si->si_trap;
- break;
- case SIGALRM:
- case SIGVTALRM:
- case SIGPROF:
- default:
- si32->si_pid = si->si_pid;
- si32->si_uid = si->si_uid;
- si32->si_value.sival_int = si->si_value.sival_int;
- break;
- case SIGCHLD:
- si32->si_pid = si->si_pid;
- si32->si_uid = si->si_uid;
- si32->si_status = si->si_status;
- si32->si_utime = si->si_utime;
- si32->si_stime = si->si_stime;
- break;
- case SIGURG:
- case SIGIO:
- si32->si_band = si->si_band;
- si32->si_fd = si->si_fd;
+ si->_reason._child._pid = si32->_reason._child._pid;
+ si->_reason._child._uid = si32->_reason._child._uid;
+ si->_reason._child._status = si32->_reason._child._status;
+ si->_reason._child._utime = si32->_reason._child._utime;
+ si->_reason._child._stime = si32->_reason._child._stime;
break;
}
}
@@ -317,47 +270,102 @@
void
netbsd32_si32_to_si(siginfo_t *si, const siginfo32_t *si32)
{
+
memset(si, 0, sizeof (*si));
- si->si_signo = si32->si_signo;
- si->si_code = si32->si_code;
- si->si_errno = si32->si_errno;
+ netbsd32_ksi32_to_ksi(&si->_info, &si32->_info);
+}
+
+static void
+netbsd32_ksi_to_ksi32(struct __ksiginfo32 *si32, const struct _ksiginfo *si)
+{
+ size_t i;
- switch (si->si_signo) {
- case 0: /* SA */
- si->si_value.sival_int = si32->si_value.sival_int;
- break;
+ memset(si32, 0, sizeof (*si32));
+ si32->_signo = si->_signo;
+ si32->_code = si->_code;
+ si32->_errno = si->_errno;
+
+ if (si->_code == SI_NOINFO)
+ return;
+ else if (si->_code <= 0) /* codes described in siginfo(2) */
+ goto fill_rt;
+
+ switch (si->_signo) {
case SIGILL:
+ case SIGFPE:
case SIGBUS:
case SIGSEGV:
- case SIGFPE:
+fill_fault:
+ si32->_reason._fault._addr =
+ NETBSD32PTR32I(si->_reason._fault._addr);
+ si32->_reason._fault._trap = si->_reason._fault._trap;
+ break;
case SIGTRAP:
- si->si_addr = (void *)(uintptr_t)si32->si_addr;
- si->si_trap = si32->si_trap;
+ switch (si->_code) {
+ case TRAP_EXEC:
+ break;
+ case TRAP_CHLD:
+ case TRAP_LWP:
+ si32->_reason._ptrace_state._pe_report_event =
+ si->_reason._ptrace_state._pe_report_event;
+CTASSERT(sizeof(si32->_reason._ptrace_state._option._pe_other_pid) ==
+ sizeof(si32->_reason._ptrace_state._option._pe_lwp));
+ si32->_reason._ptrace_state._option._pe_other_pid =
+ si->_reason._ptrace_state._option._pe_other_pid;
+ break;
+ case TRAP_SCE:
+ case TRAP_SCX:
+ si32->_reason._syscall._sysnum =
+ si->_reason._syscall._sysnum;
+ si32->_reason._syscall._retval[0] =
+ si->_reason._syscall._retval[0];
+ si32->_reason._syscall._retval[1] =
+ si->_reason._syscall._retval[1];
+ si32->_reason._syscall._error =
+ si->_reason._syscall._error;
+ for (i = 0;
+ i < __arraycount(si->_reason._syscall._args); i++)
+ si32->_reason._syscall._args[i] =
+ si->_reason._syscall._args[i];
+ break;
+ default:
+ goto fill_fault;
+ }
break;
case SIGALRM:
case SIGVTALRM:
case SIGPROF:
- default:
- si->si_pid = si32->si_pid;
- si->si_uid = si32->si_uid;
- si->si_value.sival_int = si32->si_value.sival_int;
- break;
- case SIGCHLD:
- si->si_pid = si32->si_pid;
- si->si_uid = si32->si_uid;
- si->si_status = si32->si_status;
- si->si_utime = si32->si_utime;
- si->si_stime = si32->si_stime;
+ default: /* see sigqueue() and kill1() */
+fill_rt:
+ si32->_reason._rt._pid = si->_reason._rt._pid;
+ si32->_reason._rt._uid = si->_reason._rt._uid;
+ si32->_reason._rt._value.sival_int =
+ si->_reason._rt._value.sival_int;
break;
case SIGURG:
case SIGIO:
- si->si_band = si32->si_band;
- si->si_fd = si32->si_fd;
+ si32->_reason._poll._band = si->_reason._poll._band;
+ si32->_reason._poll._fd = si->_reason._poll._fd;
+ break;
+ case SIGCHLD:
+ si32->_reason._child._pid = si->_reason._child._pid;
Home |
Main Index |
Thread Index |
Old Index