Module Name:    src
Committed By:   reinoud
Date:           Sat Aug  4 14:53:32 UTC 2012

Modified Files:
        src/sys/arch/usermode/usermode: trap.c

Log Message:
Fix IO lockups in NetBSD/usermode.

1) Don't block IO signals since the return path is not garanteed to enable the
signal again.
2) Since signals can get dropped, do a 2nd pass over the routines.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 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/usermode/trap.c
diff -u src/sys/arch/usermode/usermode/trap.c:1.65 src/sys/arch/usermode/usermode/trap.c:1.66
--- src/sys/arch/usermode/usermode/trap.c:1.65	Sat Mar  3 21:29:02 2012
+++ src/sys/arch/usermode/usermode/trap.c	Sat Aug  4 14:53:32 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.65 2012/03/03 21:29:02 reinoud Exp $ */
+/* $NetBSD: trap.c,v 1.66 2012/08/04 14:53:32 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2011 Reinoud Zandijk <rein...@netbsd.org>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.65 2012/03/03 21:29:02 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.66 2012/08/04 14:53:32 reinoud Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -364,10 +364,6 @@ handle_signal(int sig, siginfo_t *info, 
 	thunk_sigemptyset(&jump_ucp.uc_sigmask);
 	jump_ucp.uc_flags = _UC_STACK | _UC_CPU | _UC_SIGMASK;
 
-	/* prevent recursive IO signals */
-	if (sig == SIGIO)
-		thunk_sigaddset(&jump_ucp.uc_sigmask, SIGIO);
-
 	thunk_makecontext(&jump_ucp,
 			(void (*)(void)) f,
 		4, info, (void *) from_userland, (void *) pc, (void *) va);
@@ -612,13 +608,15 @@ sigio(siginfo_t *info, vaddr_t from_user
 	struct lwp *l = curlwp;
 	struct pcb *pcb = lwp_getpcb(l); KASSERT(pcb);
 	struct intr_handler *sih;
-	unsigned int n;
+	unsigned int n, pass;
 
 //	thunk_printf("%s: l %p, pcb %p\n", __func__, l, pcb);
-	for (n = 0; n < SIGIO_MAX_HANDLERS; n++) {
-		sih = &sigio_intr_handler[n];
-		if (sih->func)
-			sih->func(sih->arg);
+	for (pass = 0; pass < 2; pass++) {
+		for (n = 0; n < SIGIO_MAX_HANDLERS; n++) {
+			sih = &sigio_intr_handler[n];
+			if (sih->func)
+				sih->func(sih->arg);
+		}
 	}
 
 	KASSERT(l == curlwp);

Reply via email to