Source-Changes-HG archive

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

[src/pgoyette-compat]: src/sys/arch/sparc64 Split sparc64/netbsd32_machdep.c ...



details:   https://anonhg.NetBSD.org/src/rev/aef0bbade1ba
branches:  pgoyette-compat
changeset: 830843:aef0bbade1ba
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Sun Sep 30 00:17:54 2018 +0000

description:
Split sparc64/netbsd32_machdep.c into pieces specific to versions _13
and _16

XXX Somehow this has broken compat_sunos - must investigate further

diffstat:

 sys/arch/sparc64/conf/files.sparc64            |   10 +-
 sys/arch/sparc64/sparc64/netbsd32_machdep.c    |  375 ++----------------------
 sys/arch/sparc64/sparc64/netbsd32_machdep_13.c |  184 ++++++++++++
 sys/arch/sparc64/sparc64/netbsd32_machdep_16.c |  370 ++++++++++++++++++++++++
 4 files changed, 596 insertions(+), 343 deletions(-)

diffs (truncated from 1034 to 300 lines):

diff -r a601471e3178 -r aef0bbade1ba sys/arch/sparc64/conf/files.sparc64
--- a/sys/arch/sparc64/conf/files.sparc64       Sat Sep 29 21:36:13 2018 +0000
+++ b/sys/arch/sparc64/conf/files.sparc64       Sun Sep 30 00:17:54 2018 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.sparc64,v 1.154 2017/12/19 14:34:08 nakayama Exp $
+#      $NetBSD: files.sparc64,v 1.154.2.1 2018/09/30 00:17:54 pgoyette Exp $
 
 # @(#)files.sparc64    8.1 (Berkeley) 7/19/93
 # sparc64-specific configuration info
@@ -288,8 +288,12 @@
 
 # NetBSD/sparc 32-bit Binary compatibility (COMPAT_NETBSD32)
 include "compat/netbsd32/files.netbsd32"
-file   arch/sparc64/sparc64/netbsd32_machdep.c compat_netbsd32
-file   arch/sparc64/sparc64/netbsd32_sigcode.s compat_netbsd32
+file   arch/sparc64/sparc64/netbsd32_machdep.c         compat_netbsd32
+file   arch/sparc64/sparc64/netbsd32_machdep_13.c      compat_netbsd32 &
+                                                       compat_13
+file   arch/sparc64/sparc64/netbsd32_machdep_16.c      compat_netbsd32 &
+                                                       compat_16
+file   arch/sparc64/sparc64/netbsd32_sigcode.s         compat_netbsd32
 
 # SVR4 Binary Compatibility (COMPAT_SVR4)
 include "compat/svr4/files.svr4"
diff -r a601471e3178 -r aef0bbade1ba sys/arch/sparc64/sparc64/netbsd32_machdep.c
--- a/sys/arch/sparc64/sparc64/netbsd32_machdep.c       Sat Sep 29 21:36:13 2018 +0000
+++ b/sys/arch/sparc64/sparc64/netbsd32_machdep.c       Sun Sep 30 00:17:54 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_machdep.c,v 1.110 2016/10/19 09:44:01 skrll Exp $     */
+/*     $NetBSD: netbsd32_machdep.c,v 1.110.14.1 2018/09/30 00:17:55 pgoyette Exp $     */
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,13 +27,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.110 2016/10/19 09:44:01 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.110.14.1 2018/09/30 00:17:55 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
 #include "opt_compat_sunos.h"
 #include "opt_modular.h"
 #include "opt_execfmt.h"
+#include "opt_coredump.h"
 #include "firm_events.h"
 #endif
 
@@ -88,6 +89,8 @@
 const char     machine32[] = "sparc";  
 const char     machine_arch32[] = "sparc";     
 
+int netbsd32_sendsig_siginfo(const ksiginfo_t *, const sigset_t *);
+
 #if NFIRM_EVENTS > 0
 static int ev_out32(struct firm_event *, int, struct uio *);
 #endif
@@ -150,166 +153,12 @@
        tf->tf_out[7] = 0;
 }
 
-#ifdef COMPAT_16
-/*
- * NB: since this is a 32-bit address world, sf_scp and sf_sc
- *     can't be a pointer since those are 64-bits wide.
- */
-struct sparc32_sigframe {
-       int     sf_signo;               /* signal number */
-       int     sf_code;                /* code */
-       u_int   sf_scp;                 /* SunOS user addr of sigcontext */
-       int     sf_addr;                /* SunOS compat, always 0 for now */
-       struct  netbsd32_sigcontext sf_sc;      /* actual sigcontext */
-};
-
-#undef DEBUG
-#ifdef DEBUG
-extern int sigdebug;
-#endif
-
-static void
-netbsd32_sendsig_sigcontext(const ksiginfo_t *ksi, const sigset_t *mask)
-{
-       int sig = ksi->ksi_signo;
-       struct lwp *l = curlwp;
-       struct proc *p = l->l_proc;
-       struct sparc32_sigframe *fp;
-       struct trapframe64 *tf;
-       int addr, onstack, error;
-       struct rwindow32 *oldsp, *newsp;
-       register32_t sp;
-       sig_t catcher = SIGACTION(p, sig).sa_handler;
-       struct sparc32_sigframe sf;
-       extern char netbsd32_sigcode[], netbsd32_esigcode[];
-#define        szsigcode       (netbsd32_esigcode - netbsd32_sigcode)
-
-       tf = l->l_md.md_tf;
-       /* Need to attempt to zero extend this 32-bit pointer */
-       oldsp = (struct rwindow32 *)(u_long)(u_int)tf->tf_out[6];
-       /* Do we need to jump onto the signal stack? */
-       onstack =
-           (l->l_sigstk.ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 &&
-           (SIGACTION(p, sig).sa_flags & SA_ONSTACK) != 0;
-       if (onstack) {
-               fp = (struct sparc32_sigframe *)((char *)l->l_sigstk.ss_sp +
-                                       l->l_sigstk.ss_size);
-               l->l_sigstk.ss_flags |= SS_ONSTACK;
-       } else
-               fp = (struct sparc32_sigframe *)oldsp;
-       fp = (struct sparc32_sigframe *)((u_long)(fp - 1) & ~7);
-
-#ifdef DEBUG
-       sigpid = p->p_pid;
-       if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) {
-               printf("sendsig: %s[%d] sig %d newusp %p scp %p oldsp %p\n",
-                   p->p_comm, p->p_pid, sig, fp, &fp->sf_sc, oldsp);
-               if (sigdebug & SDB_DDB) Debugger();
-       }
-#endif
-       /*
-        * Now set up the signal frame.  We build it in kernel space
-        * and then copy it out.  We probably ought to just build it
-        * directly in user space....
-        */
-       sf.sf_signo = sig;
-       sf.sf_code = (u_int)ksi->ksi_trap;
-#if defined(COMPAT_SUNOS) || defined(MODULAR)
-       sf.sf_scp = (u_long)&fp->sf_sc;
-#endif
-       sf.sf_addr = 0;                 /* XXX */
-
-       /*
-        * Build the signal context to be used by sigreturn.
-        */
-       sf.sf_sc.sc_onstack = onstack;
-       sf.sf_sc.sc_mask = *mask;
-       sf.sf_sc.sc_sp = (u_long)oldsp;
-       sf.sf_sc.sc_pc = tf->tf_pc;
-       sf.sf_sc.sc_npc = tf->tf_npc;
-       sf.sf_sc.sc_psr = TSTATECCR_TO_PSR(tf->tf_tstate); /* XXX */
-       sf.sf_sc.sc_g1 = tf->tf_global[1];
-       sf.sf_sc.sc_o0 = tf->tf_out[0];
-
-       /*
-        * Put the stack in a consistent state before we whack away
-        * at it.  Note that write_user_windows may just dump the
-        * registers into the pcb; we need them in the process's memory.
-        * We also need to make sure that when we start the signal handler,
-        * its %i6 (%fp), which is loaded from the newly allocated stack area,
-        * joins seamlessly with the frame it was in when the signal occurred,
-        * so that the debugger and _longjmp code can back up through it.
-        */
-       sendsig_reset(l, sig);
-       mutex_exit(p->p_lock);
-       newsp = (struct rwindow32 *)((long)fp - sizeof(struct rwindow32));
-       write_user_windows();
-#ifdef DEBUG
-       if ((sigdebug & SDB_KSTACK))
-           printf("sendsig: saving sf to %p, setting stack pointer %p to %p\n",
-                  fp, &(((struct rwindow32 *)newsp)->rw_in[6]), oldsp);
-#endif
-       sp = NETBSD32PTR32I(oldsp);
-       error = (rwindow_save(l) || 
-           copyout(&sf, fp, sizeof sf) || 
-           copyout(&sp, &(((struct rwindow32 *)newsp)->rw_in[6]),
-               sizeof(sp)));
-       mutex_enter(p->p_lock);
-       if (error) {
-               /*
-                * Process has trashed its stack; give it an illegal
-                * instruction to halt it in its tracks.
-                */
-#ifdef DEBUG
-               mutex_exit(p->p_lock);
-               if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)
-                       printf("sendsig: window save or copyout error\n");
-               printf("sendsig: stack was trashed trying to send sig %d, sending SIGILL\n", sig);
-               if (sigdebug & SDB_DDB) Debugger();
-               mutex_enter(p->p_lock);
-#endif
-               sigexit(l, SIGILL);
-               /* NOTREACHED */
-       }
-
-#ifdef DEBUG
-       if (sigdebug & SDB_FOLLOW) {
-               printf("sendsig: %s[%d] sig %d scp %p\n",
-                      p->p_comm, p->p_pid, sig, &fp->sf_sc);
-       }
-#endif
-       /*
-        * Arrange to continue execution at the code copied out in exec().
-        * It needs the function to call in %g1, and a new stack pointer.
-        */
-       addr = p->p_psstrp - szsigcode;
-       tf->tf_global[1] = (long)catcher;
-       tf->tf_pc = addr;
-       tf->tf_npc = addr + 4;
-       tf->tf_out[6] = (uint64_t)(u_int)(u_long)newsp;
-
-       /* Remember that we're now on the signal stack. */
-       if (onstack)
-               l->l_sigstk.ss_flags |= SS_ONSTACK;
-
-#ifdef DEBUG
-       if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) {
-               mutex_exit(p->p_lock);
-               printf("sendsig: about to return to catcher %p thru %p\n", 
-                      catcher, addr);
-               if (sigdebug & SDB_DDB) Debugger();
-               mutex_enter(p->p_lock);
-       }
-#endif
-}
-#endif
-
 struct sparc32_sigframe_siginfo {
        siginfo32_t sf_si;
        ucontext32_t sf_uc;
 };
 
-static void
+int
 netbsd32_sendsig_siginfo(const ksiginfo_t *ksi, const sigset_t *mask)
 {
        struct lwp *l = curlwp;
@@ -407,198 +256,27 @@
        /* Remember that we're now on the signal stack. */
        if (onstack)
                l->l_sigstk.ss_flags |= SS_ONSTACK;
+
+       return 0;
 }
 
+struct netbsd32_sendsig_hook_t netbsd32_sendsig_hook;
+        
+MODULE_CALL_HOOK_DECL(netbsd32_sendsig_hook, f,
+    (const ksiginfo_t *ksi, const sigset_t *mask));  
+MODULE_CALL_HOOK(netbsd32_sendsig_hook, f,
+    (const ksiginfo_t *ksi, const sigset_t *mask), (ksi, mask),
+    netbsd32_sendsig_siginfo(ksi, mask));
+
 void
 netbsd32_sendsig(const ksiginfo_t *ksi, const sigset_t *mask)
 {
-#ifdef COMPAT_16
-       if (curproc->p_sigacts->sa_sigdesc[ksi->ksi_signo].sd_vers < 2)
-               netbsd32_sendsig_sigcontext(ksi, mask);
-       else
-#endif
-               netbsd32_sendsig_siginfo(ksi, mask);
+
+       netbsd32_sendsig_hook_f_call(ksi, mask);
 }
 
 #undef DEBUG
 
-#ifdef COMPAT_13
-int
-compat_13_netbsd32_sigreturn(struct lwp *l, const struct compat_13_netbsd32_sigreturn_args *uap, register_t *retval)
-{
-       /* {
-               syscallarg(struct netbsd32_sigcontext13 *) sigcntxp;
-       } */
-       struct netbsd32_sigcontext13 *scp;
-       struct netbsd32_sigcontext13 sc;
-       struct trapframe64 *tf;
-       struct proc *p = l->l_proc;
-       sigset_t mask;
-
-       /* First ensure consistent stack state (see sendsig). */
-       write_user_windows();
-       if (rwindow_save(l)) {
-#ifdef DEBUG
-               printf("compat_13_netbsd32_sigreturn: rwindow_save(%p) failed, sending SIGILL\n", p);
-               Debugger();
-#endif
-               mutex_enter(p->p_lock);
-               sigexit(l, SIGILL);
-       }
-#ifdef DEBUG
-       if (sigdebug & SDB_FOLLOW) {
-               printf("compat_13_netbsd32_sigreturn: %s[%d], sigcntxp %p\n",
-                   p->p_comm, p->p_pid, SCARG(uap, sigcntxp));
-               if (sigdebug & SDB_DDB) Debugger();
-       }
-#endif
-       scp = (struct netbsd32_sigcontext13 *)(u_long)SCARG(uap, sigcntxp);
-       if ((vaddr_t)scp & 3 || (copyin((void *)scp, &sc, sizeof sc) != 0))
-       {
-#ifdef DEBUG
-               printf("compat_13_netbsd32_sigreturn: copyin failed\n");
-               Debugger();
-#endif
-               return (EINVAL);
-       }
-       scp = &sc;
-
-       tf = l->l_md.md_tf;
-       /*



Home | Main Index | Thread Index | Old Index