Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern curlwp may not be available early enough for kern_e...



details:   https://anonhg.NetBSD.org/src/rev/9ee113a25a6c
branches:  trunk
changeset: 1009696:9ee113a25a6c
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Thu Apr 30 19:34:37 2020 +0000

description:
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.)

diffstat:

 sys/kern/kern_entropy.c |  13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diffs (48 lines):

diff -r db42082fd91a -r 9ee113a25a6c sys/kern/kern_entropy.c
--- a/sys/kern/kern_entropy.c   Thu Apr 30 17:36:06 2020 +0000
+++ b/sys/kern/kern_entropy.c   Thu Apr 30 19:34:37 2020 +0000
@@ -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 @@
 
        if (E->sourcelock)
                return false;
-       E->sourcelock = curlwp;
+       E->sourcelock = (curcpu_available() ? (void *)1 : curlwp);
        return true;
 }
 
@@ -1582,8 +1582,9 @@
 
        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 @@
 rnd_sources_locked(void)
 {
 
-       return E->sourcelock == curlwp;
+       return E->sourcelock == (curcpu_available() ? (void *)1 : curlwp);
 }
 
 /*



Home | Main Index | Thread Index | Old Index