Module Name: src
Committed By: jmcneill
Date: Mon Dec 26 22:04:35 UTC 2011
Modified Files:
src/sys/arch/usermode/include: intr.h
src/sys/arch/usermode/usermode: intr.c trap.c
Log Message:
make sure the sigio signal handler runs on the alternate signal stack,
fixes random SIGILLs seen recently
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/usermode/include/intr.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/usermode/usermode/intr.c
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/usermode/usermode/trap.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/usermode/include/intr.h
diff -u src/sys/arch/usermode/include/intr.h:1.5 src/sys/arch/usermode/include/intr.h:1.6
--- src/sys/arch/usermode/include/intr.h:1.5 Mon Dec 26 12:29:39 2011
+++ src/sys/arch/usermode/include/intr.h Mon Dec 26 22:04:35 2011
@@ -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 <[email protected]>
@@ -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);
Index: src/sys/arch/usermode/usermode/intr.c
diff -u src/sys/arch/usermode/usermode/intr.c:1.10 src/sys/arch/usermode/usermode/intr.c:1.11
--- src/sys/arch/usermode/usermode/intr.c:1.10 Mon Dec 26 12:29:39 2011
+++ src/sys/arch/usermode/usermode/intr.c Mon Dec 26 22:04:35 2011
@@ -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 <[email protected]>
@@ -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)
{
Index: src/sys/arch/usermode/usermode/trap.c
diff -u src/sys/arch/usermode/usermode/trap.c:1.47 src/sys/arch/usermode/usermode/trap.c:1.48
--- src/sys/arch/usermode/usermode/trap.c:1.47 Mon Dec 26 12:29:39 2011
+++ src/sys/arch/usermode/usermode/trap.c Mon Dec 26 22:04:35 2011
@@ -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 <[email protected]>
@@ -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());
}