Module Name:    src
Committed By:   martin
Date:           Mon Jan 22 12:30:20 UTC 2018

Modified Files:
        src/sys/kern [netbsd-8]: kern_softint.c subr_pserialize.c subr_psref.c
        src/sys/rump/librump/rumpkern [netbsd-8]: rump.c

Log Message:
Pull up following revision(s) (requested by jdolecek in ticket #506):
        sys/kern/kern_softint.c: revision 1.45
        sys/rump/librump/rumpkern/rump.c: revision 1.331
        sys/kern/subr_pserialize.c: revision 1.10
        sys/kern/subr_psref.c: revision 1.10
Prevent panic or hangup in softint_disestablish(), pserialize_perform() or
psref_target_destroy() while mp_online == false.
 See http://mail-index.netbsd.org/tech-kern/2017/12/25/msg022829.html
Set mp_online = true. This change might fix PR#52886.


To generate a diff of this commit:
cvs rdiff -u -r1.43.10.1 -r1.43.10.2 src/sys/kern/kern_softint.c
cvs rdiff -u -r1.8.10.1 -r1.8.10.2 src/sys/kern/subr_pserialize.c
cvs rdiff -u -r1.7.2.1 -r1.7.2.2 src/sys/kern/subr_psref.c
cvs rdiff -u -r1.329.10.1 -r1.329.10.2 src/sys/rump/librump/rumpkern/rump.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/kern/kern_softint.c
diff -u src/sys/kern/kern_softint.c:1.43.10.1 src/sys/kern/kern_softint.c:1.43.10.2
--- src/sys/kern/kern_softint.c:1.43.10.1	Thu Nov 23 13:40:22 2017
+++ src/sys/kern/kern_softint.c	Mon Jan 22 12:30:20 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_softint.c,v 1.43.10.1 2017/11/23 13:40:22 martin Exp $	*/
+/*	$NetBSD: kern_softint.c,v 1.43.10.2 2018/01/22 12:30:20 martin Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
@@ -170,13 +170,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.43.10.1 2017/11/23 13:40:22 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.43.10.2 2018/01/22 12:30:20 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
 #include <sys/intr.h>
 #include <sys/ipi.h>
 #include <sys/mutex.h>
+#include <sys/kernel.h>
 #include <sys/kthread.h>
 #include <sys/evcnt.h>
 #include <sys/cpu.h>
@@ -430,8 +431,10 @@ softint_disestablish(void *arg)
 	 * it again.  So, we are only looking for handler records with
 	 * SOFTINT_ACTIVE already set.
 	 */
-	where = xc_broadcast(0, (xcfunc_t)nullop, NULL, NULL);
-	xc_wait(where);
+	if (__predict_true(mp_online)) {
+		where = xc_broadcast(0, (xcfunc_t)nullop, NULL, NULL);
+		xc_wait(where);
+	}
 
 	for (;;) {
 		/* Collect flag values from each CPU. */

Index: src/sys/kern/subr_pserialize.c
diff -u src/sys/kern/subr_pserialize.c:1.8.10.1 src/sys/kern/subr_pserialize.c:1.8.10.2
--- src/sys/kern/subr_pserialize.c:1.8.10.1	Thu Nov 30 14:40:46 2017
+++ src/sys/kern/subr_pserialize.c	Mon Jan 22 12:30:20 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_pserialize.c,v 1.8.10.1 2017/11/30 14:40:46 martin Exp $	*/
+/*	$NetBSD: subr_pserialize.c,v 1.8.10.2 2018/01/22 12:30:20 martin Exp $	*/
 
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_pserialize.c,v 1.8.10.1 2017/11/30 14:40:46 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pserialize.c,v 1.8.10.2 2018/01/22 12:30:20 martin Exp $");
 
 #include <sys/param.h>
 
@@ -157,6 +157,11 @@ pserialize_perform(pserialize_t psz)
 	KASSERT(psz->psz_owner == NULL);
 	KASSERT(ncpu > 0);
 
+	if (__predict_false(mp_online == false)) {
+		psz_ev_excl.ev_count++;
+		return;
+	}
+
 	/*
 	 * Set up the object and put it onto the queue.  The lock
 	 * activity here provides the necessary memory barrier to

Index: src/sys/kern/subr_psref.c
diff -u src/sys/kern/subr_psref.c:1.7.2.1 src/sys/kern/subr_psref.c:1.7.2.2
--- src/sys/kern/subr_psref.c:1.7.2.1	Tue Jan  2 10:36:12 2018
+++ src/sys/kern/subr_psref.c	Mon Jan 22 12:30:20 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_psref.c,v 1.7.2.1 2018/01/02 10:36:12 snj Exp $	*/
+/*	$NetBSD: subr_psref.c,v 1.7.2.2 2018/01/22 12:30:20 martin Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_psref.c,v 1.7.2.1 2018/01/02 10:36:12 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_psref.c,v 1.7.2.2 2018/01/22 12:30:20 martin Exp $");
 
 #include <sys/types.h>
 #include <sys/condvar.h>
@@ -429,8 +429,14 @@ psreffed_p(struct psref_target *target, 
 		.ret = false,
 	};
 
-	/* Ask all CPUs to say whether they hold a psref to the target.  */
-	xc_wait(xc_broadcast(0, &psreffed_p_xc, &P, NULL));
+	if (__predict_true(mp_online)) {
+		/*
+		 * Ask all CPUs to say whether they hold a psref to the
+		 * target.
+		 */
+		xc_wait(xc_broadcast(0, &psreffed_p_xc, &P, NULL));
+	} else
+		psreffed_p_xc(&P, NULL);
 
 	return P.ret;
 }

Index: src/sys/rump/librump/rumpkern/rump.c
diff -u src/sys/rump/librump/rumpkern/rump.c:1.329.10.1 src/sys/rump/librump/rumpkern/rump.c:1.329.10.2
--- src/sys/rump/librump/rumpkern/rump.c:1.329.10.1	Thu Nov 30 14:40:46 2017
+++ src/sys/rump/librump/rumpkern/rump.c	Mon Jan 22 12:30:20 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: rump.c,v 1.329.10.1 2017/11/30 14:40:46 martin Exp $	*/
+/*	$NetBSD: rump.c,v 1.329.10.2 2018/01/22 12:30:20 martin Exp $	*/
 
 /*
  * Copyright (c) 2007-2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.329.10.1 2017/11/30 14:40:46 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.329.10.2 2018/01/22 12:30:20 martin Exp $");
 
 #include <sys/systm.h>
 #define ELFSIZE ARCH_ELFSIZE
@@ -392,6 +392,8 @@ rump_init(void)
 	/* Once all CPUs are detected, initialize the per-CPU cprng_fast.  */
 	cprng_fast_init();
 
+	mp_online = true;
+
 	/* CPUs are up.  allow kernel threads to run */
 	rump_thread_allow(NULL);
 

Reply via email to