Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/irix reworked signal handling:
details: https://anonhg.NetBSD.org/src/rev/077ba6307f70
branches: trunk
changeset: 522341:077ba6307f70
user: manu <manu%NetBSD.org@localhost>
date: Sun Feb 17 20:50:06 2002 +0000
description:
reworked signal handling:
- do not save/and restore registers that should not be saved and restore
- do give an accurate sigcontext pointer to the signal handler
- do use the struct sigreturna from IRIX.
This eliminates panics and hangs in certain circonstances
Also some cosmetic changes with tabs usage
diffstat:
sys/compat/irix/irix_signal.c | 284 ++++++++++++++++++------------------
sys/compat/irix/irix_signal.h | 15 +-
sys/compat/irix/irix_syscall.h | 6 +-
sys/compat/irix/irix_syscallargs.h | 6 +-
sys/compat/irix/irix_syscalls.c | 6 +-
sys/compat/irix/irix_sysent.c | 6 +-
sys/compat/irix/syscalls.master | 4 +-
7 files changed, 167 insertions(+), 160 deletions(-)
diffs (truncated from 551 to 300 lines):
diff -r 3050b0f7a90d -r 077ba6307f70 sys/compat/irix/irix_signal.c
--- a/sys/compat/irix/irix_signal.c Sun Feb 17 20:44:17 2002 +0000
+++ b/sys/compat/irix/irix_signal.c Sun Feb 17 20:50:06 2002 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: irix_signal.c,v 1.3 2001/12/26 11:04:20 manu Exp $ */
+/* $NetBSD: irix_signal.c,v 1.4 2002/02/17 20:50:06 manu Exp $ */
/*-
- * Copyright (c) 1994, 2001 The NetBSD Foundation, Inc.
+ * Copyright (c) 1994, 2001-2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: irix_signal.c,v 1.3 2001/12/26 11:04:20 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: irix_signal.c,v 1.4 2002/02/17 20:50:06 manu Exp $");
#include <sys/types.h>
#include <sys/signal.h>
@@ -64,8 +64,8 @@
static int irix_setinfo __P((struct proc *, int, irix_irix5_siginfo_t *));
-#define irix_sigmask(n) (1 << (((n) - 1) & 31))
-#define irix_sigword(n) (((n) - 1) >> 5)
+#define irix_sigmask(n) (1 << (((n) - 1) & 31))
+#define irix_sigword(n) (((n) - 1) >> 5)
#define irix_sigemptyset(s) memset((s), 0, sizeof(*(s)))
#define irix_sigismember(s, n) ((s)->bits[irix_sigword(n)] & irix_sigmask(n))
#define irix_sigaddset(s, n) ((s)->bits[irix_sigword(n)] |= irix_sigmask(n))
@@ -79,50 +79,50 @@
int st;
irix_irix5_siginfo_t *s;
{
- irix_irix5_siginfo_t i;
- int sig;
+ irix_irix5_siginfo_t i;
+ int sig;
- memset(&i, 0, sizeof(i));
+ memset(&i, 0, sizeof(i));
- i.isi_signo = SVR4_SIGCHLD;
- i.isi_errno = 0; /* XXX? */
+ i.isi_signo = SVR4_SIGCHLD;
+ i.isi_errno = 0; /* XXX? */
- if (p) {
- i.isi_pid = p->p_pid;
- if (p->p_stat == SZOMB) {
- i.isi_stime = p->p_ru->ru_stime.tv_sec;
- i.isi_utime = p->p_ru->ru_utime.tv_sec;
- }
- else {
- i.isi_stime = p->p_stats->p_ru.ru_stime.tv_sec;
- i.isi_utime = p->p_stats->p_ru.ru_utime.tv_sec;
- }
- }
+ if (p) {
+ i.isi_pid = p->p_pid;
+ if (p->p_stat == SZOMB) {
+ i.isi_stime = p->p_ru->ru_stime.tv_sec;
+ i.isi_utime = p->p_ru->ru_utime.tv_sec;
+ }
+ else {
+ i.isi_stime = p->p_stats->p_ru.ru_stime.tv_sec;
+ i.isi_utime = p->p_stats->p_ru.ru_utime.tv_sec;
+ }
+ }
if (WIFEXITED(st)) {
- i.isi_status = WEXITSTATUS(st);
- i.isi_code = SVR4_CLD_EXITED;
- } else if (WIFSTOPPED(st)) {
- sig = WSTOPSIG(st);
- if (sig >= 0 && sig < NSIG)
- i.isi_status = native_to_svr4_sig[sig];
+ i.isi_status = WEXITSTATUS(st);
+ i.isi_code = SVR4_CLD_EXITED;
+ } else if (WIFSTOPPED(st)) {
+ sig = WSTOPSIG(st);
+ if (sig >= 0 && sig < NSIG)
+ i.isi_status = native_to_svr4_sig[sig];
- if (i.isi_status == SVR4_SIGCONT)
- i.isi_code = SVR4_CLD_CONTINUED;
- else
- i.isi_code = SVR4_CLD_STOPPED;
- } else {
- sig = WTERMSIG(st);
- if (sig >= 0 && sig < NSIG)
- i.isi_status = native_to_svr4_sig[sig];
+ if (i.isi_status == SVR4_SIGCONT)
+ i.isi_code = SVR4_CLD_CONTINUED;
+ else
+ i.isi_code = SVR4_CLD_STOPPED;
+ } else {
+ sig = WTERMSIG(st);
+ if (sig >= 0 && sig < NSIG)
+ i.isi_status = native_to_svr4_sig[sig];
- if (WCOREDUMP(st))
- i.isi_code = SVR4_CLD_DUMPED;
- else
- i.isi_code = SVR4_CLD_KILLED;
- }
+ if (WCOREDUMP(st))
+ i.isi_code = SVR4_CLD_DUMPED;
+ else
+ i.isi_code = SVR4_CLD_KILLED;
+ }
- return copyout(&i, s, sizeof(i));
+ return copyout(&i, s, sizeof(i));
}
@@ -162,113 +162,112 @@
void
irix_sendsig(catcher, sig, mask, code) /* XXX Check me */
- sig_t catcher;
- int sig;
- sigset_t *mask;
- u_long code;
+ sig_t catcher;
+ int sig;
+ sigset_t *mask;
+ u_long code;
{
- struct proc *p = curproc;
- struct irix_sigframe *fp;
- struct frame *f;
- int i,onstack;
- struct irix_sigframe sf;
+ struct proc *p = curproc;
+ struct irix_sigcontext *fp;
+ struct frame *f;
+ int i,onstack;
+ struct irix_sigcontext sc;
#ifdef DEBUG_IRIX
- printf("irix_sendsig()\n");
+ printf("irix_sendsig()\n");
+ printf("catcher = %p, sig = %d, code = 0x%lx\n",
+ (void *)catcher, sig, code);
#endif /* DEBUG_IRIX */
- f = (struct frame *)p->p_md.md_regs;
+ f = (struct frame *)p->p_md.md_regs;
- /*
- * Do we need to jump onto the signal stack?
- */
- onstack =
- (p->p_sigctx.ps_sigstk.ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 &&
- (SIGACTION(p, sig).sa_flags & SA_ONSTACK) != 0;
-
- /*
- * not sure it works yet.
- */
- onstack=0;
+ /*
+ * Do we need to jump onto the signal stack?
+ */
+ onstack =
+ (p->p_sigctx.ps_sigstk.ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 &&
+ (SIGACTION(p, sig).sa_flags & SA_ONSTACK) != 0;
- /*
- * Allocate space for the signal handler context.
- */
- if (onstack)
- fp = (struct irix_sigframe *)
- ((caddr_t)p->p_sigctx.ps_sigstk.ss_sp
- + p->p_sigctx.ps_sigstk.ss_size);
- else
- /* cast for _MIPS_BSD_API == _MIPS_BSD_API_LP32_64CLEAN case */
- fp = (struct irix_sigframe *)(u_int32_t)f->f_regs[SP];
+ /*
+ * not sure it works yet.
+ */
+ onstack=0;
- /*
- * Build stack frame for signal trampoline.
- */
- memset(&sf, 0, sizeof sf);
+ /*
+ * Allocate space for the signal handler context.
+ */
+ if (onstack)
+ fp = (struct irix_sigcontext *)
+ ((caddr_t)p->p_sigctx.ps_sigstk.ss_sp
+ + p->p_sigctx.ps_sigstk.ss_size);
+ else
+ /* cast for _MIPS_BSD_API == _MIPS_BSD_API_LP32_64CLEAN case */
+ fp = (struct irix_sigcontext *)(u_int32_t)f->f_regs[SP];
+
+ /*
+ * Build stack frame for signal trampoline.
+ */
+ memset(&sc, 0, sizeof sc);
- native_to_irix_sigset(mask, &sf.isf_sc.isc_sigset);
- for (i=0; i<32; i++) {
- sf.isf_sc.isc_regs[i] = f->f_regs[i];
- }
- sf.isf_sc.isc_regs[0] = 0;
- sf.isf_sc.isc_fp_rounded_result = 0;
- sf.isf_sc.isc_regmask = ~0x1UL;
- sf.isf_sc.isc_mdhi = f->f_regs[MULHI];
- sf.isf_sc.isc_mdlo = f->f_regs[MULLO];
- sf.isf_sc.isc_pc = f->f_regs[PC];
- sf.isf_sc.isc_status = f->f_regs[SR]; /* XXX */
- sf.isf_sc.isc_cause = f->f_regs[CAUSE];
- sf.isf_sc.isc_badvaddr = f->f_regs[BADVADDR]; /* XXX */
- sf.isf_sc.isc_ownedfp = 0;
- sf.isf_sc.isc_ssflags = 0;
+ native_to_irix_sigset(mask, &sc.isc_sigset);
+ for (i = 1; i < 32; i++) { /* save gpr1 - gpr31 */
+ sc.isc_regs[i] = f->f_regs[i];
+ }
+ sc.isc_regs[0] = 0;
+ sc.isc_fp_rounded_result = 0;
+ sc.isc_regmask = ~0x1UL;
+ sc.isc_mdhi = f->f_regs[MULHI];
+ sc.isc_mdlo = f->f_regs[MULLO];
+ sc.isc_pc = f->f_regs[PC];
+ sc.isc_ownedfp = 0;
+ sc.isc_ssflags = 0;
- /*
- * Save signal stack. XXX broken
- */
- /* kregs.sc_onstack = p->p_sigctx.ps_sigstk.ss_flags & SS_ONSTACK; */
+ /*
+ * Save signal stack. XXX broken
+ */
+ /* kregs.sc_onstack = p->p_sigctx.ps_sigstk.ss_flags & SS_ONSTACK; */
- /*
- * Install the sigframe onto the stack
- */
- fp = (struct irix_sigframe *)((unsigned long)fp
- - sizeof(struct irix_sigframe));
- fp = (struct irix_sigframe *)((unsigned long)fp
+ /*
+ * Install the sigframe onto the stack
+ */
+ fp = (struct irix_sigcontext *)((unsigned long)fp
+ - sizeof(struct irix_sigcontext));
+ fp = (struct irix_sigcontext *)((unsigned long)fp
& ~0xfUL); /* 16 bytes alignement */
- if (copyout(&sf, fp, sizeof(sf)) != 0) {
- /*
- * Process has trashed its stack; give it an illegal
- * instruction to halt it in its tracks.
- */
+ if (copyout(&sc, fp, sizeof(sc)) != 0) {
+ /*
+ * Process has trashed its stack; give it an illegal
+ * instruction to halt it in its tracks.
+ */
#ifdef DEBUG_IRIX
- printf("irix_sendsig: stack trashed\n");
+ printf("irix_sendsig: stack trashed\n");
#endif /* DEBUG_IRIX */
- sigexit(p, SIGILL);
- /* NOTREACHED */
- }
+ sigexit(p, SIGILL);
+ /* NOTREACHED */
+ }
- /* Set up the registers to return to sigcode. */
- f->f_regs[A0] = native_to_svr4_sig[sig];
- f->f_regs[A1] = 0;
- f->f_regs[A2] = (unsigned long)&fp->isf_sc;
+ /* Set up the registers to return to sigcode. */
+ f->f_regs[A0] = native_to_svr4_sig[sig];
+ f->f_regs[A1] = 0;
+ f->f_regs[A2] = (unsigned long)fp;
#ifdef DEBUG_IRIX
- printf("sigcontext is at %p\n", &fp->isf_sc);
+ printf("sigcontext is at %p\n", fp);
#endif /* DEBUG_IRIX */
f->f_regs[RA] = (unsigned long)p->p_sigctx.ps_sigcode;
- f->f_regs[SP] = (unsigned long)fp;
- f->f_regs[T9] = (unsigned long)catcher;
- f->f_regs[A3] = (unsigned long)catcher;
- f->f_regs[PC] = (unsigned long)catcher;
+ f->f_regs[SP] = (unsigned long)fp;
+ f->f_regs[T9] = (unsigned long)catcher;
+ f->f_regs[A3] = (unsigned long)catcher;
+ f->f_regs[PC] = (unsigned long)catcher;
Home |
Main Index |
Thread Index |
Old Index