Module Name:    src
Committed By:   riastradh
Date:           Thu Apr 30 19:34:37 UTC 2020

Modified Files:
        src/sys/kern: kern_entropy.c

Log Message:
curlwp may not be available early enough for kern_entropy.c.

Fortunately, we're just using it to print helpful diagnostic messages
in kasserts here, so while we're still cold just use (void *)1 for
now until someone figures out how to make curlwp available earlier on
x86.

(All of the curcpu_available() business is a provisional crock here
and it would be better to get rid of it.)


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/kern/kern_entropy.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_entropy.c
diff -u src/sys/kern/kern_entropy.c:1.5 src/sys/kern/kern_entropy.c:1.6
--- src/sys/kern/kern_entropy.c:1.5	Thu Apr 30 17:16:00 2020
+++ src/sys/kern/kern_entropy.c	Thu Apr 30 19:34:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.5 2020/04/30 17:16:00 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.6 2020/04/30 19:34:37 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.5 2020/04/30 17:16:00 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.6 2020/04/30 19:34:37 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -1566,7 +1566,7 @@ rnd_trylock_sources(void)
 
 	if (E->sourcelock)
 		return false;
-	E->sourcelock = curlwp;
+	E->sourcelock = (curcpu_available() ? (void *)1 : curlwp);
 	return true;
 }
 
@@ -1582,8 +1582,9 @@ rnd_unlock_sources(void)
 
 	KASSERT(E->stage == ENTROPY_COLD || mutex_owned(&E->lock));
 
-	KASSERTMSG(E->sourcelock == curlwp, "lwp %p releasing lock held by %p",
-	    curlwp, E->sourcelock);
+	KASSERTMSG(E->sourcelock == (curcpu_available() ? (void *)1 : curlwp),
+	    "lwp %p releasing lock held by %p",
+	    (curcpu_available() ? (void *)1 : curlwp), E->sourcelock);
 	E->sourcelock = NULL;
 	if (E->stage >= ENTROPY_WARM)
 		cv_broadcast(&E->cv);
@@ -1599,7 +1600,7 @@ static bool
 rnd_sources_locked(void)
 {
 
-	return E->sourcelock == curlwp;
+	return E->sourcelock == (curcpu_available() ? (void *)1 : curlwp);
 }
 
 /*

Reply via email to