Module Name: src
Committed By: pgoyette
Date: Sat Sep 29 09:45:51 UTC 2018
Modified Files:
src/sys/arch/mips/mips [pgoyette-compat]: netbsd32_machdep.c
Log Message:
Put netbsd32_sendsig_siginfo() here, where it belongs.
To generate a diff of this commit:
cvs rdiff -u -r1.15.2.4 -r1.15.2.5 src/sys/arch/mips/mips/netbsd32_machdep.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/mips/mips/netbsd32_machdep.c
diff -u src/sys/arch/mips/mips/netbsd32_machdep.c:1.15.2.4 src/sys/arch/mips/mips/netbsd32_machdep.c:1.15.2.5
--- src/sys/arch/mips/mips/netbsd32_machdep.c:1.15.2.4 Sat Sep 29 08:38:45 2018
+++ src/sys/arch/mips/mips/netbsd32_machdep.c Sat Sep 29 09:45:51 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_machdep.c,v 1.15.2.4 2018/09/29 08:38:45 pgoyette Exp $ */
+/* $NetBSD: netbsd32_machdep.c,v 1.15.2.5 2018/09/29 09:45:51 pgoyette Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.15.2.4 2018/09/29 08:38:45 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.15.2.5 2018/09/29 09:45:51 pgoyette Exp $");
#include "opt_compat_netbsd.h"
#include "opt_coredump.h"
@@ -75,6 +75,92 @@ netbsd32_cpu_upcall
netbsd32_vm_default_addr
#endif
+static int netbsd32_sendsig_siginfo(const ksiginfo_t *, const sigset_t *);
+
+struct sigframe_siginfo32 {
+ siginfo32_t sf_si;
+ ucontext32_t sf_uc;
+};
+
+/*
+ * Send a signal to process.
+ */
+static int
+netbsd32_sendsig_siginfo(const ksiginfo_t *ksi, const sigset_t *mask)
+{
+ struct lwp * const l = curlwp;
+ struct proc * const p = l->l_proc;
+ struct sigacts * const ps = p->p_sigacts;
+ int onstack, error;
+ int sig = ksi->ksi_signo;
+ struct sigframe_siginfo32 *sfp = getframe(l, sig, &onstack);
+ struct sigframe_siginfo32 sf;
+ struct trapframe * const tf = l->l_md.md_utf;
+ size_t sfsz;
+ sig_t catcher = SIGACTION(p, sig).sa_handler;
+
+ sfp--;
+
+ netbsd32_si_to_si32(&sf.sf_si, (const siginfo_t *)&ksi->ksi_info);
+
+ /* Build stack frame for signal trampoline. */
+ switch (ps->sa_sigdesc[sig].sd_vers) {
+ case 0: /* handled by sendsig_sigcontext */
+ case 1: /* handled by sendsig_sigcontext */
+ default: /* unknown version */
+ printf("sendsig_siginfo: bad version %d\n",
+ ps->sa_sigdesc[sig].sd_vers);
+ sigexit(l, SIGILL);
+ case 2:
+ break;
+ }
+
+ sf.sf_uc.uc_flags = _UC_SIGMASK
+ | ((l->l_sigstk.ss_flags & SS_ONSTACK)
+ ? _UC_SETSTACK : _UC_CLRSTACK);
+ sf.sf_uc.uc_sigmask = *mask;
+ sf.sf_uc.uc_link = (intptr_t)l->l_ctxlink;
+ memset(&sf.sf_uc.uc_stack, 0, sizeof(sf.sf_uc.uc_stack));
+ sfsz = offsetof(struct sigframe_siginfo32, sf_uc.uc_mcontext);
+ if (p->p_md.md_abi == _MIPS_BSD_API_O32)
+ sfsz += sizeof(mcontext_o32_t);
+ else
+ sfsz += sizeof(mcontext32_t);
+ sendsig_reset(l, sig);
+ mutex_exit(p->p_lock);
+ cpu_getmcontext32(l, &sf.sf_uc.uc_mcontext, &sf.sf_uc.uc_flags);
+ error = copyout(&sf, sfp, sfsz);
+ mutex_enter(p->p_lock);
+ if (error != 0) {
+ /*
+ * Process has trashed its stack; give it an illegal
+ * instruction to halt it in its tracks.
+ */
+ sigexit(l, SIGILL);
+ /* NOTREACHED */
+ }
+
+ /*
+ * Set up the registers to directly invoke the signal
+ * handler. The return address will be set up to point
+ * to the signal trampoline to bounce us back.
+ */
+ tf->tf_regs[_R_A0] = sig;
+ tf->tf_regs[_R_A1] = (intptr_t)&sfp->sf_si;
+ tf->tf_regs[_R_A2] = (intptr_t)&sfp->sf_uc;
+
+ tf->tf_regs[_R_PC] = (intptr_t)catcher;
+ tf->tf_regs[_R_T9] = (intptr_t)catcher;
+ tf->tf_regs[_R_SP] = (intptr_t)sfp;
+ tf->tf_regs[_R_RA] = (intptr_t)ps->sa_sigdesc[sig].sd_tramp;
+
+ /* Remember that we're now on the signal stack. */
+ if (onstack)
+ l->l_sigstk.ss_flags |= SS_ONSTACK;
+
+ return 0;
+}
+
int
netbsd32_sysarch(struct lwp *l, const struct netbsd32_sysarch_args *uap,
register_t *retval)
@@ -124,12 +210,6 @@ netbsd32_vm_default_addr(struct proc *p,
return VM_DEFAULT_ADDRESS32_BOTTOMUP(base, size);
}
-
-struct sigframe_siginfo32 {
- siginfo32_t sf_si;
- ucontext32_t sf_uc;
-};
-
void
cpu_getmcontext32(struct lwp *l, mcontext32_t *mc32, unsigned int *flagsp)
{