Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/usermode/dev use sigaltstack
details: https://anonhg.NetBSD.org/src/rev/88390e4444a6
branches: trunk
changeset: 769280:88390e4444a6
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Mon Sep 05 18:17:08 2011 +0000
description:
use sigaltstack
diffstat:
sys/arch/usermode/dev/clock.c | 22 ++++++++++++++++++----
sys/arch/usermode/dev/ld_thunkbus.c | 15 ++++++++++++---
2 files changed, 30 insertions(+), 7 deletions(-)
diffs (101 lines):
diff -r 972c3b170f88 -r 88390e4444a6 sys/arch/usermode/dev/clock.c
--- a/sys/arch/usermode/dev/clock.c Mon Sep 05 18:16:34 2011 +0000
+++ b/sys/arch/usermode/dev/clock.c Mon Sep 05 18:17:08 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: clock.c,v 1.12 2011/08/23 21:56:02 jmcneill Exp $ */
+/* $NetBSD: clock.c,v 1.13 2011/09/05 18:17:08 jmcneill Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.12 2011/08/23 21:56:02 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.13 2011/09/05 18:17:08 jmcneill Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -88,6 +88,8 @@
{
clock_softc_t *sc = device_private(self);
struct thunk_itimerval itimer;
+ struct sigaction sa;
+ stack_t ss;
long tcres;
aprint_naive("\n");
@@ -102,7 +104,19 @@
sc->sc_todr.todr_gettime = clock_todr_gettime;
todr_attach(&sc->sc_todr);
- thunk_signal(SIGALRM, clock_signal);
+ ss.ss_sp = thunk_malloc(SIGSTKSZ);
+ if (ss.ss_sp == NULL)
+ panic("%s: couldn't allocate signal stack", __func__);
+ ss.ss_size = SIGSTKSZ;
+ ss.ss_flags = 0;
+ if (thunk_sigaltstack(&ss, NULL) == -1)
+ panic("%s: couldn't setup signal stack", __func__);
+
+ memset(&sa, 0, sizeof(sa));
+ sigfillset(&sa.sa_mask);
+ sa.sa_handler = clock_signal;
+ sa.sa_flags = SA_ONSTACK;
+ thunk_sigaction(SIGALRM, &sa, NULL);
itimer.it_interval.tv_sec = 0;
itimer.it_interval.tv_usec = 10000;
@@ -118,7 +132,7 @@
}
static void
-clock_signal(int notused)
+clock_signal(int sig)
{
curcpu()->ci_idepth++;
diff -r 972c3b170f88 -r 88390e4444a6 sys/arch/usermode/dev/ld_thunkbus.c
--- a/sys/arch/usermode/dev/ld_thunkbus.c Mon Sep 05 18:16:34 2011 +0000
+++ b/sys/arch/usermode/dev/ld_thunkbus.c Mon Sep 05 18:17:08 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ld_thunkbus.c,v 1.11 2011/09/05 11:25:29 reinoud Exp $ */
+/* $NetBSD: ld_thunkbus.c,v 1.12 2011/09/05 18:17:08 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ld_thunkbus.c,v 1.11 2011/09/05 11:25:29 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_thunkbus.c,v 1.12 2011/09/05 18:17:08 jmcneill Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -91,6 +91,7 @@
struct thunkbus_attach_args *taa = opaque;
const char *path = taa->u.diskimage.path;
struct sigaction sa;
+ stack_t ss;
ssize_t size, blksize;
ld->sc_dv = self;
@@ -120,8 +121,16 @@
sc->sc_ih = softint_establish(SOFTINT_BIO,
ld_thunkbus_complete, sc);
+ ss.ss_sp = thunk_malloc(SIGSTKSZ);
+ if (ss.ss_sp == NULL)
+ panic("%s: couldn't allocate signal stack", __func__);
+ ss.ss_size = SIGSTKSZ;
+ ss.ss_flags = 0;
+ if (thunk_sigaltstack(&ss, NULL) == -1)
+ panic("%s: couldn't setup signal stack", __func__);
+
sigemptyset(&sa.sa_mask);
- sa.sa_flags = SA_RESTART | SA_SIGINFO;
+ sa.sa_flags = SA_RESTART | SA_SIGINFO | SA_ONSTACK;
sa.sa_sigaction = ld_thunkbus_sig;
thunk_sigaddset(&sa.sa_mask, SIGALRM);
if (thunk_sigaction(SIGIO, &sa, NULL) == -1)
Home |
Main Index |
Thread Index |
Old Index