summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorjmcneill <jmcneill@NetBSD.org>2011-12-26 22:04:35 +0000
committerjmcneill <jmcneill@NetBSD.org>2011-12-26 22:04:35 +0000
commita4cac6069cbe299dc2f85145c6da47a7c71fcff8 (patch)
treed1e5af7cefd47936ebd4b52ad6d468f97c65e8cc /sys
parentbb4ffbccfda5a9357353d870e4fe82e0d8f952ba (diff)
make sure the sigio signal handler runs on the alternate signal stack,
fixes random SIGILLs seen recently
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/usermode/include/intr.h5
-rw-r--r--sys/arch/usermode/usermode/intr.c14
-rw-r--r--sys/arch/usermode/usermode/trap.c20
3 files changed, 18 insertions, 21 deletions
diff --git a/sys/arch/usermode/include/intr.h b/sys/arch/usermode/include/intr.h
index f733777c6c7..946c1e6b460 100644
--- a/sys/arch/usermode/include/intr.h
+++ b/sys/arch/usermode/include/intr.h
@@ -1,4 +1,4 @@
-/* $NetBSD: intr.h,v 1.5 2011/12/26 12:29:39 jmcneill Exp $ */
+/* $NetBSD: intr.h,v 1.6 2011/12/26 22:04:35 jmcneill Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca>
@@ -30,8 +30,9 @@
#define _ARCH_USERMODE_INCLUDE_INTR_H
#include <machine/intrdefs.h>
+#include <sys/siginfo.h>
-void sigio_intr_init(void);
+void sigio_signal_handler(int, siginfo_t *, void *);
void * sigio_intr_establish(int (*)(void *), void *);
void splinit(void);
diff --git a/sys/arch/usermode/usermode/intr.c b/sys/arch/usermode/usermode/intr.c
index 5b3f5cf55d0..d39261a28c7 100644
--- a/sys/arch/usermode/usermode/intr.c
+++ b/sys/arch/usermode/usermode/intr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: intr.c,v 1.10 2011/12/26 12:29:39 jmcneill Exp $ */
+/* $NetBSD: intr.c,v 1.11 2011/12/26 22:04:35 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.10 2011/12/26 12:29:39 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.11 2011/12/26 22:04:35 jmcneill Exp $");
#include <sys/types.h>
@@ -144,8 +144,8 @@ spllower(int x)
#endif
}
-static void
-sigio_signal_handler(int sig)
+void
+sigio_signal_handler(int sig, siginfo_t *info, void *ctx)
{
struct intr_handler *sih;
unsigned int n;
@@ -157,12 +157,6 @@ sigio_signal_handler(int sig)
}
}
-void
-sigio_intr_init(void)
-{
- thunk_signal(SIGIO, sigio_signal_handler);
-}
-
void *
sigio_intr_establish(int (*func)(void *), void *arg)
{
diff --git a/sys/arch/usermode/usermode/trap.c b/sys/arch/usermode/usermode/trap.c
index 37a3cab965c..7006b64ac5d 100644
--- a/sys/arch/usermode/usermode/trap.c
+++ b/sys/arch/usermode/usermode/trap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.47 2011/12/26 12:29:39 jmcneill Exp $ */
+/* $NetBSD: trap.c,v 1.48 2011/12/26 22:04:35 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Reinoud Zandijk <reinoud@netbsd.org>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.47 2011/12/26 12:29:39 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.48 2011/12/26 22:04:35 jmcneill Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -76,27 +76,29 @@ setup_signal_handlers(void)
sigstk.ss_size = SIGSTKSZ;
sigstk.ss_flags = 0;
if (thunk_sigaltstack(&sigstk, 0) < 0)
- panic("can't set alternate stacksize : %d",
+ panic("can't set alternate stacksize: %d",
thunk_geterrno());
sa.sa_flags = SA_RESTART | SA_SIGINFO | SA_ONSTACK;
sa.sa_sigaction = mem_access_handler;
thunk_sigemptyset(&sa.sa_mask);
-// thunk_sigaddset(&sa.sa_mask, SIGALRM);
if (thunk_sigaction(SIGSEGV, &sa, NULL) == -1)
- panic("couldn't register SIGSEGV handler : %d",
+ panic("couldn't register SIGSEGV handler: %d",
thunk_geterrno());
if (thunk_sigaction(SIGBUS, &sa, NULL) == -1)
- panic("couldn't register SIGBUS handler : %d", thunk_geterrno());
+ panic("couldn't register SIGBUS handler: %d", thunk_geterrno());
sa.sa_flags = SA_RESTART | SA_SIGINFO | SA_ONSTACK;
sa.sa_sigaction = illegal_instruction_handler;
thunk_sigemptyset(&sa.sa_mask);
-// thunk_sigaddset(&sa.sa_mask, SIGALRM);
if (thunk_sigaction(SIGILL, &sa, NULL) == -1)
- panic("couldn't register SIGILL handler : %d", thunk_geterrno());
+ panic("couldn't register SIGILL handler: %d", thunk_geterrno());
- sigio_intr_init();
+ sa.sa_flags = SA_RESTART | SA_SIGINFO | SA_ONSTACK;
+ sa.sa_sigaction = sigio_signal_handler;
+ thunk_sigemptyset(&sa.sa_mask);
+ if (thunk_sigaction(SIGIO, &sa, NULL) == -1)
+ panic("couldn't register SIGIO handler: %d", thunk_geterrno());
}