Module Name:    src
Committed By:   jmcneill
Date:           Mon Sep  5 18:17:08 UTC 2011

Modified Files:
        src/sys/arch/usermode/dev: clock.c ld_thunkbus.c

Log Message:
use sigaltstack


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/usermode/dev/clock.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/usermode/dev/ld_thunkbus.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/dev/clock.c
diff -u src/sys/arch/usermode/dev/clock.c:1.12 src/sys/arch/usermode/dev/clock.c:1.13
--- src/sys/arch/usermode/dev/clock.c:1.12	Tue Aug 23 21:56:02 2011
+++ src/sys/arch/usermode/dev/clock.c	Mon Sep  5 18:17:08 2011
@@ -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 <[email protected]>
@@ -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++;
 

Index: src/sys/arch/usermode/dev/ld_thunkbus.c
diff -u src/sys/arch/usermode/dev/ld_thunkbus.c:1.11 src/sys/arch/usermode/dev/ld_thunkbus.c:1.12
--- src/sys/arch/usermode/dev/ld_thunkbus.c:1.11	Mon Sep  5 11:25:29 2011
+++ src/sys/arch/usermode/dev/ld_thunkbus.c	Mon Sep  5 18:17:08 2011
@@ -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 <[email protected]>
@@ -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)

Reply via email to