Source-Changes-HG archive

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

[src/trunk]: src/sys/kern entropy(9): Forbid entropy_extract in hard interrup...



details:   https://anonhg.NetBSD.org/src/rev/3e1b55562c84
branches:  trunk
changeset: 363935:3e1b55562c84
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed Mar 16 23:56:55 2022 +0000

description:
entropy(9): Forbid entropy_extract in hard interrupt context.

With a little additional work, this will let us reduce the global
entropy pool lock so it never blocks interrupts.

diffstat:

 sys/kern/kern_entropy.c |  14 +++++---------
 1 files changed, 5 insertions(+), 9 deletions(-)

diffs (46 lines):

diff -r 719b7427005c -r 3e1b55562c84 sys/kern/kern_entropy.c
--- a/sys/kern/kern_entropy.c   Wed Mar 16 23:56:33 2022 +0000
+++ b/sys/kern/kern_entropy.c   Wed Mar 16 23:56:55 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_entropy.c,v 1.34 2022/03/04 21:12:03 andvar Exp $ */
+/*     $NetBSD: kern_entropy.c,v 1.35 2022/03/16 23:56:55 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.34 2022/03/04 21:12:03 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.35 2022/03/16 23:56:55 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -211,9 +211,6 @@
 static struct evcnt entropy_consolidate_evcnt =
     EVCNT_INITIALIZER(EVCNT_TYPE_MISC, NULL, "entropy", "consolidate");
 EVCNT_ATTACH_STATIC(entropy_consolidate_evcnt);
-static struct evcnt entropy_extract_intr_evcnt =
-    EVCNT_INITIALIZER(EVCNT_TYPE_MISC, NULL, "entropy", "extract intr");
-EVCNT_ATTACH_STATIC(entropy_extract_intr_evcnt);
 static struct evcnt entropy_extract_fail_evcnt =
     EVCNT_INITIALIZER(EVCNT_TYPE_MISC, NULL, "entropy", "extract fail");
 EVCNT_ATTACH_STATIC(entropy_extract_fail_evcnt);
@@ -1278,14 +1275,13 @@
                    "can't wait for entropy until warm");
        }
 
+       /* Refuse to operate in interrupt context.  */
+       KASSERT(!cpu_intr_p());
+
        /* Acquire the global lock to get at the global pool.  */
        if (E->stage >= ENTROPY_WARM)
                mutex_enter(&E->lock);
 
-       /* Count up request for entropy in interrupt context.  */
-       if (cpu_intr_p())
-               entropy_extract_intr_evcnt.ev_count++;
-
        /* Wait until there is enough entropy in the system.  */
        error = 0;
        while (E->needed) {



Home | Main Index | Thread Index | Old Index