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): Shuffle some assertions around.
details: https://anonhg.NetBSD.org/src/rev/4780f06c0129
branches: trunk
changeset: 364386:4780f06c0129
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Mar 20 13:17:44 2022 +0000
description:
entropy(9): Shuffle some assertions around.
Tripped over (diff || E->pending == ENTROPY_CAPACITY*NBBY), not sure
why yet, printing values will help.
No functional change intended.
diffstat:
sys/kern/kern_entropy.c | 26 ++++++++++++++++++--------
1 files changed, 18 insertions(+), 8 deletions(-)
diffs (59 lines):
diff -r 40b4c94a2b4a -r 4780f06c0129 sys/kern/kern_entropy.c
--- a/sys/kern/kern_entropy.c Sun Mar 20 13:17:32 2022 +0000
+++ b/sys/kern/kern_entropy.c Sun Mar 20 13:17:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_entropy.c,v 1.44 2022/03/20 13:17:32 riastradh Exp $ */
+/* $NetBSD: kern_entropy.c,v 1.45 2022/03/20 13:17:44 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.44 2022/03/20 13:17:32 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.45 2022/03/20 13:17:44 riastradh Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -771,17 +771,26 @@
entropy_notify();
entropy_immediate_evcnt.ev_count++;
} else {
- /* Record how much we can add to the global pool. */
+ /* Determine how much we can add to the global pool. */
+ KASSERTMSG(E->pending <= ENTROPY_CAPACITY*NBBY,
+ "E->pending=%u", E->pending);
diff = MIN(ec->ec_pending, ENTROPY_CAPACITY*NBBY - E->pending);
- E->pending += diff;
- atomic_store_relaxed(&ec->ec_pending, ec->ec_pending - diff);
/*
- * This should have made a difference unless we were
- * already saturated.
+ * This should make a difference unless we are already
+ * saturated.
*/
- KASSERT(diff || E->pending == ENTROPY_CAPACITY*NBBY);
+ KASSERTMSG(diff || E->pending == ENTROPY_CAPACITY*NBBY,
+ "diff=%u E->pending=%u ec->ec_pending=%u cap=%u",
+ diff, E->pending, ec->ec_pending,
+ (unsigned)ENTROPY_CAPACITY*NBBY);
+
+ /* Add to the global, subtract from the local. */
+ E->pending += diff;
KASSERT(E->pending);
+ KASSERTMSG(E->pending <= ENTROPY_CAPACITY*NBBY,
+ "E->pending=%u", E->pending);
+ atomic_store_relaxed(&ec->ec_pending, ec->ec_pending - diff);
if (E->needed <= E->pending) {
/*
@@ -907,6 +916,7 @@
uint32_t pending;
void *sih;
+ KASSERT(cpu_intr_p());
KASSERTMSG(howmany(nbits, NBBY) <= len,
"impossible entropy rate: %u bits in %zu-byte string", nbits, len);
Home |
Main Index |
Thread Index |
Old Index