Module Name: src Committed By: tls Date: Wed Sep 5 18:06:52 UTC 2012
Modified Files: src/sys/kern: kern_rndq.c Log Message: Try to help embedded systems a _little_ bit: stir in the system boot time as early as possible. On systems with no cycle counter (or very very predictable cycle counts early in boot) at least this will cause some difference across boots. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/kern/kern_rndq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/kern_rndq.c diff -u src/sys/kern/kern_rndq.c:1.3 src/sys/kern/kern_rndq.c:1.4 --- src/sys/kern/kern_rndq.c:1.3 Tue Apr 17 02:50:38 2012 +++ src/sys/kern/kern_rndq.c Wed Sep 5 18:06:52 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_rndq.c,v 1.3 2012/04/17 02:50:38 tls Exp $ */ +/* $NetBSD: kern_rndq.c,v 1.4 2012/09/05 18:06:52 tls Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.3 2012/04/17 02:50:38 tls Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.4 2012/09/05 18:06:52 tls Exp $"); #include <sys/param.h> #include <sys/ioctl.h> @@ -904,9 +904,17 @@ rnd_timeout(void *arg) u_int32_t rnd_extract_data_locked(void *p, u_int32_t len, u_int32_t flags) { + static int timed_in; KASSERT(mutex_owned(&rndpool_mtx)); - if (!rnd_have_entropy) { + if (__predict_false(!timed_in)) { + if (boottime.tv_sec) { + rndpool_add_data(&rnd_pool, &boottime, + sizeof(boottime), 0); + } + timed_in++; + } + if (__predict_false(!rnd_have_entropy)) { u_int32_t c; #ifdef RND_VERBOSE