Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat/netbsd32 Belatedly catch up with kern_sig.c rev 1...



details:   https://anonhg.NetBSD.org/src/rev/fd95273f0077
branches:  trunk
changeset: 1004878:fd95273f0077
user:      rin <rin%NetBSD.org@localhost>
date:      Mon Nov 18 04:09:53 2019 +0000

description:
Belatedly catch up with kern_sig.c rev 1.358:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/kern_sig.c#rev1.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.

XXX
pullup to netbsd-9

diffstat:

 sys/compat/netbsd32/netbsd32.h        |   23 ++---
 sys/compat/netbsd32/netbsd32_conv.h   |    6 +-
 sys/compat/netbsd32/netbsd32_ioctl.c  |   42 ++++++++++-
 sys/compat/netbsd32/netbsd32_ioctl.h  |    7 +-
 sys/compat/netbsd32/netbsd32_signal.c |  122 +++++++++++----------------------
 5 files changed, 97 insertions(+), 103 deletions(-)

diffs (truncated from 409 to 300 lines):

diff -r ac27653720e0 -r fd95273f0077 sys/compat/netbsd32/netbsd32.h
--- a/sys/compat/netbsd32/netbsd32.h    Mon Nov 18 03:17:51 2019 +0000
+++ b/sys/compat/netbsd32/netbsd32.h    Mon Nov 18 04:09:53 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32.h,v 1.128 2019/11/07 15:21:55 rin Exp $       */
+/*     $NetBSD: netbsd32.h,v 1.129 2019/11/18 04:09:53 rin Exp $       */
 
 /*
  * Copyright (c) 1998, 2001, 2008, 2015 Matthew R. Green
@@ -37,6 +37,7 @@
  */
 
 #include <sys/param.h> /* precautionary upon removal from ucred.h */
+#include <sys/types.h>
 #include <sys/systm.h>
 #include <sys/mount.h>
 #include <sys/stat.h>
@@ -72,7 +73,11 @@
 typedef int32_t netbsd32_intptr_t;
 typedef uint32_t netbsd32_uintptr_t;
 
-/* netbsd32_[u]int64 are machine dependent and defined below */
+/*
+ * netbsd32_[u]int64 are machine dependent and defined in <sys/types.h>:
+ * 64 bit integers only have 4-byte alignment on some 32 bit ports,
+ * but always have 8-byte alignment on 64 bit systems.
+ */
 
 /*
  * machine dependant section; must define:
@@ -154,15 +159,6 @@
 #undef NETBSD32_POINTER_TYPE
 
 /*
- * 64 bit integers only have 4-byte alignment on some 32 bit ports,
- * but always have 8-byte alignment on 64 bit systems.
- * NETBSD32_INT64_ALIGN may be __attribute__((__aligned__(4)))
- */
-typedef int64_t netbsd32_int64 NETBSD32_INT64_ALIGN;
-typedef uint64_t netbsd32_uint64 NETBSD32_INT64_ALIGN;
-#undef NETBSD32_INT64_ALIGN
-
-/*
  * all pointers are netbsd32_pointer_t (defined in <machine/netbsd32_machdep.h>)
  */
 
@@ -212,14 +208,13 @@
 
 /* from <sys/time.h> */
 typedef int32_t netbsd32_timer_t;
-typedef        int32_t netbsd32_time50_t;
 typedef        netbsd32_int64 netbsd32_time_t;
 typedef netbsd32_pointer_t netbsd32_timerp_t;
 typedef netbsd32_pointer_t netbsd32_clockidp_t;
 
 typedef netbsd32_pointer_t netbsd32_timespec50p_t;
 struct netbsd32_timespec50 {
-       netbsd32_time50_t tv_sec;                       /* seconds */
+       int32_t         tv_sec;                 /* seconds */
        netbsd32_long   tv_nsec;        /* and nanoseconds */
 };
 
@@ -231,7 +226,7 @@
 
 typedef netbsd32_pointer_t netbsd32_timeval50p_t;
 struct netbsd32_timeval50 {
-       netbsd32_time50_t       tv_sec;         /* seconds */
+       netbsd32_long           tv_sec;         /* seconds */
        netbsd32_long           tv_usec;        /* and microseconds */
 };
 
diff -r ac27653720e0 -r fd95273f0077 sys/compat/netbsd32/netbsd32_conv.h
--- a/sys/compat/netbsd32/netbsd32_conv.h       Mon Nov 18 03:17:51 2019 +0000
+++ b/sys/compat/netbsd32/netbsd32_conv.h       Mon Nov 18 04:09:53 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_conv.h,v 1.40 2019/10/03 22:16:53 kamil Exp $ */
+/*     $NetBSD: netbsd32_conv.h,v 1.41 2019/11/18 04:09:53 rin Exp $   */
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -58,7 +58,7 @@
     struct netbsd32_timeval50 *tv32)
 {
 
-       tv32->tv_sec = (netbsd32_time50_t)tv->tv_sec;
+       tv32->tv_sec = (netbsd32_long)tv->tv_sec;
        tv32->tv_usec = (netbsd32_long)tv->tv_usec;
 }
 
@@ -152,7 +152,7 @@
     struct netbsd32_timespec50 *s32p)
 {
 
-       s32p->tv_sec = (netbsd32_time50_t)p->tv_sec;
+       s32p->tv_sec = (int32_t)p->tv_sec;
        s32p->tv_nsec = (netbsd32_long)p->tv_nsec;
 }
 
diff -r ac27653720e0 -r fd95273f0077 sys/compat/netbsd32/netbsd32_ioctl.c
--- a/sys/compat/netbsd32/netbsd32_ioctl.c      Mon Nov 18 03:17:51 2019 +0000
+++ b/sys/compat/netbsd32/netbsd32_ioctl.c      Mon Nov 18 04:09:53 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_ioctl.c,v 1.104 2019/08/20 09:32:21 christos Exp $    */
+/*     $NetBSD: netbsd32_ioctl.c,v 1.105 2019/11/18 04:09:53 rin Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.104 2019/08/20 09:32:21 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.105 2019/11/18 04:09:53 rin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ntp.h"
@@ -1066,6 +1066,30 @@
 }
 #endif
 
+#ifdef COMPAT_50
+static void
+netbsd32_ioctl_to_timeval50(
+    const struct netbsd32_timeval50 *s32p,
+    struct timeval50 *p,
+    u_long cmd)
+{
+
+       p->tv_sec = s32p->tv_sec;
+       p->tv_usec = s32p->tv_usec;
+}
+
+static void
+netbsd32_ioctl_from_timeval50(
+    const struct timeval50 *p,
+    struct netbsd32_timeval50 *s32p,
+    u_long cmd)
+{
+
+       s32p->tv_sec = (netbsd32_long)p->tv_sec;
+       s32p->tv_usec = (netbsd32_long)p->tv_usec;
+}
+#endif
+
 /*
  * main ioctl syscall.
  *
@@ -1403,16 +1427,28 @@
 
        case BIOCSETF32:
                IOCTL_STRUCT_CONV_TO(BIOCSETF, bpf_program);
+#ifdef COMPAT_50
+#define netbsd32_to_timeval50 netbsd32_ioctl_to_timeval50
+#define netbsd32_from_timeval50 netbsd32_ioctl_from_timeval50
+       case BIOCSORTIMEOUT32:
+               IOCTL_STRUCT_CONV_TO(BIOCSORTIMEOUT, timeval50);
+       case BIOCGORTIMEOUT32:
+               IOCTL_STRUCT_CONV_TO(BIOCGORTIMEOUT, timeval50);
+#undef netbsd32_to_timeval50
+#undef netbsd32_from_timeval50
+#endif
        case BIOCSTCPF32:
                IOCTL_STRUCT_CONV_TO(BIOCSTCPF, bpf_program);
        case BIOCSUDPF32:
                IOCTL_STRUCT_CONV_TO(BIOCSUDPF, bpf_program);
        case BIOCGDLTLIST32:
                IOCTL_STRUCT_CONV_TO(BIOCGDLTLIST, bpf_dltlist);
-       case BIOCSRTIMEOUT32:
 #define netbsd32_to_timeval(s32p, p, cmd) netbsd32_to_timeval(s32p, p)
 #define netbsd32_from_timeval(p, s32p, cmd) netbsd32_from_timeval(p, s32p)
+       case BIOCSRTIMEOUT32:
                IOCTL_STRUCT_CONV_TO(BIOCSRTIMEOUT, timeval);
+       case BIOCGRTIMEOUT32:
+               IOCTL_STRUCT_CONV_TO(BIOCGRTIMEOUT, timeval);
 #undef netbsd32_to_timeval
 #undef netbsd32_from_timeval
 
diff -r ac27653720e0 -r fd95273f0077 sys/compat/netbsd32/netbsd32_ioctl.h
--- a/sys/compat/netbsd32/netbsd32_ioctl.h      Mon Nov 18 03:17:51 2019 +0000
+++ b/sys/compat/netbsd32/netbsd32_ioctl.h      Mon Nov 18 04:09:53 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_ioctl.h,v 1.68 2019/08/20 09:32:21 christos Exp $     */
+/*     $NetBSD: netbsd32_ioctl.h,v 1.69 2019/11/18 04:09:53 rin Exp $  */
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -116,10 +116,15 @@
 };
 
 #define        BIOCSETF32      _IOW('B',103, struct netbsd32_bpf_program)
+#ifdef COMPAT_50
+#define BIOCSORTIMEOUT32 _IOW('B',109, struct netbsd32_timeval50)
+#define BIOCGORTIMEOUT32 _IOR('B',110, struct netbsd32_timeval50)
+#endif
 #define BIOCSTCPF32    _IOW('B',114, struct netbsd32_bpf_program)
 #define BIOCSUDPF32    _IOW('B',115, struct netbsd32_bpf_program)
 #define BIOCGDLTLIST32 _IOWR('B',119, struct netbsd32_bpf_dltlist)
 #define BIOCSRTIMEOUT32        _IOW('B',122, struct netbsd32_timeval)
+#define BIOCGRTIMEOUT32        _IOR('B',123, struct netbsd32_timeval)
 
 
 struct netbsd32_wsdisplay_addscreendata {
diff -r ac27653720e0 -r fd95273f0077 sys/compat/netbsd32/netbsd32_signal.c
--- a/sys/compat/netbsd32/netbsd32_signal.c     Mon Nov 18 03:17:51 2019 +0000
+++ b/sys/compat/netbsd32/netbsd32_signal.c     Mon Nov 18 04:09:53 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.46 2019/11/18 04:09:53 rin 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.46 2019/11/18 04:09:53 rin Exp $");
 
 #if defined(_KERNEL_OPT) 
 #include "opt_ktrace.h"
@@ -188,6 +188,8 @@
 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;
@@ -198,11 +200,24 @@
        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:
+               if (si32->_code != TRAP_SCE && si32->_code != TRAP_SCX)
+                       goto fill_fault;
+               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;
        case SIGALRM:
        case SIGVTALRM:
        case SIGPROF:
@@ -215,6 +230,7 @@
        case SIGCHLD:
                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;
@@ -226,11 +242,11 @@
        }
 }
 
-#ifdef notyet
-#ifdef KTRACE
 static void
 netbsd32_ksi_to_ksi32(struct __ksiginfo32 *si32, const struct _ksiginfo *si)
 {
+       size_t i;
+
        memset(si32, 0, sizeof (*si32));
        si32->_signo = si->_signo;
        si32->_code = si->_code;
@@ -241,11 +257,24 @@
        case SIGBUS:
        case SIGSEGV:
        case SIGFPE:
-       case SIGTRAP:
+fill_fault:
                si32->_reason._fault._addr =
                    NETBSD32PTR32I(si->_reason._fault._addr);
                si32->_reason._fault._trap = si->_reason._fault._trap;
                break;
+       case SIGTRAP:
+               if (si->_code != TRAP_SCE && si->_code != TRAP_SCX)
+                       goto fill_fault;
+               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(si32->_reason._syscall._args); i++)
+                       si32->_reason._syscall._args[i] =
+                           si->_reason._syscall._args[i];
+               break;



Home | Main Index | Thread Index | Old Index