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 Use percpu_foreach instead of manual i...
details: https://anonhg.NetBSD.org/src/rev/492f40cd22e6
branches: trunk
changeset: 801613:492f40cd22e6
user: riastradh <riastradh%NetBSD.org@localhost>
date: Mon Aug 11 13:06:31 2014 +0000
description:
Use percpu_foreach instead of manual iteration.
diffstat:
sys/crypto/cprng_fast/cprng_fast.c | 31 +++++++++++++++----------------
1 files changed, 15 insertions(+), 16 deletions(-)
diffs (66 lines):
diff -r dd8ebffcd41b -r 492f40cd22e6 sys/crypto/cprng_fast/cprng_fast.c
--- a/sys/crypto/cprng_fast/cprng_fast.c Mon Aug 11 13:01:58 2014 +0000
+++ b/sys/crypto/cprng_fast/cprng_fast.c Mon Aug 11 13:06:31 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cprng_fast.c,v 1.7 2014/08/11 13:01:58 riastradh Exp $ */
+/* $NetBSD: cprng_fast.c,v 1.8 2014/08/11 13:06:31 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.7 2014/08/11 13:01:58 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cprng_fast.c,v 1.8 2014/08/11 13:06:31 riastradh Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -203,6 +203,7 @@
__CTASSERT(sizeof ((struct cprng_fast *)0)->key == CPRNG_FAST_SEED_BYTES);
+static void cprng_fast_init_cpu(void *, void *, struct cpu_info *);
static void cprng_fast_schedule_reseed(struct cprng_fast *);
static void cprng_fast_intr(void *);
@@ -218,27 +219,25 @@
void
cprng_fast_init(void)
{
- struct cpu_info *ci;
- CPU_INFO_ITERATOR cii;
crypto_core_selftest();
cprng_fast_percpu = percpu_alloc(sizeof(struct cprng_fast));
- for (CPU_INFO_FOREACH(cii, ci)) {
- struct cprng_fast *cprng;
- uint8_t seed[CPRNG_FAST_SEED_BYTES];
-
- percpu_traverse_enter();
- cprng = percpu_getptr_remote(cprng_fast_percpu, ci);
- cprng_strong(kern_cprng, seed, sizeof(seed), FASYNC);
- /* Can't do anything about it if not full entropy. */
- cprng_fast_seed(cprng, seed);
- explicit_memset(seed, 0, sizeof(seed));
- percpu_traverse_exit();
- }
+ percpu_foreach(cprng_fast_percpu, &cprng_fast_init_cpu, 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)
+{
+ struct cprng_fast *const cprng = p;
+ uint8_t seed[CPRNG_FAST_SEED_BYTES];
+
+ cprng_strong(kern_cprng, seed, sizeof seed, FASYNC);
+ cprng_fast_seed(cprng, seed);
+ (void)explicit_memset(seed, 0, sizeof seed);
+}
+
static inline int
cprng_fast_get(struct cprng_fast **cprngp)
{
Home |
Main Index |
Thread Index |
Old Index