Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/crypto/cprng_fast Count cprng_fast reseed events.
details: https://anonhg.NetBSD.org/src/rev/b311100065b5
branches: trunk
changeset: 971623:b311100065b5
user: riastradh <riastradh%NetBSD.org@localhost>
date: Thu Apr 30 03:29:45 2020 +0000
description:
Count cprng_fast reseed events.
diffstat:
sys/crypto/cprng_fast/cprng_fast.c | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
diffs (74 lines):
diff -r 6370e8383feb -r b311100065b5 sys/crypto/cprng_fast/cprng_fast.c
--- a/sys/crypto/cprng_fast/cprng_fast.c Thu Apr 30 03:29:35 2020 +0000
+++ b/sys/crypto/cprng_fast/cprng_fast.c Thu Apr 30 03:29:45 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cprng_fast.c,v 1.14 2020/04/30 03:29:35 riastradh Exp $ */
+/* $NetBSD: cprng_fast.c,v 1.15 2020/04/30 03:29:45 riastradh Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cprng_fast.c,v 1.14 2020/04/30 03:29:35 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cprng_fast.c,v 1.15 2020/04/30 03:29:45 riastradh Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -38,7 +38,9 @@
#include <sys/cprng.h>
#include <sys/cpu.h>
#include <sys/entropy.h>
+#include <sys/evcnt.h>
#include <sys/intr.h>
+#include <sys/kmem.h>
#include <sys/percpu.h>
/* ChaCha core */
@@ -198,6 +200,7 @@
uint32_t buffer[crypto_core_OUTPUTWORDS];
uint32_t key[crypto_core_KEYWORDS];
uint32_t nonce[crypto_core_INPUTWORDS];
+ struct evcnt *reseed_evcnt;
unsigned epoch;
};
@@ -221,14 +224,14 @@
{
crypto_core_selftest();
- cprng_fast_percpu = percpu_alloc(sizeof(struct cprng_fast));
- percpu_foreach(cprng_fast_percpu, &cprng_fast_init_cpu, NULL);
+ cprng_fast_percpu = percpu_create(sizeof(struct cprng_fast),
+ cprng_fast_init_cpu, NULL, NULL);
cprng_fast_softint = softint_establish(SOFTINT_SERIAL|SOFTINT_MPSAFE,
&cprng_fast_intr, NULL);
}
static void
-cprng_fast_init_cpu(void *p, void *arg __unused, struct cpu_info *ci __unused)
+cprng_fast_init_cpu(void *p, void *arg __unused, struct cpu_info *ci)
{
struct cprng_fast *const cprng = p;
uint8_t seed[CPRNG_FAST_SEED_BYTES];
@@ -237,6 +240,11 @@
cprng_strong(kern_cprng, seed, sizeof seed, 0);
cprng_fast_seed(cprng, seed);
(void)explicit_memset(seed, 0, sizeof seed);
+
+ cprng->reseed_evcnt = kmem_alloc(sizeof(*cprng->reseed_evcnt),
+ KM_SLEEP);
+ evcnt_attach_dynamic(cprng->reseed_evcnt, EVCNT_TYPE_MISC, NULL,
+ ci->ci_cpuname, "cprng_fast reseed");
}
static inline int
@@ -285,6 +293,7 @@
s = splvm();
cprng_fast_seed(cprng, seed);
cprng->epoch = epoch;
+ cprng->reseed_evcnt->ev_count++;
splx(s);
percpu_putref(cprng_fast_percpu);
Home |
Main Index |
Thread Index |
Old Index