Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Try to help embedded systems a _little_ bit: stir i...



details:   https://anonhg.NetBSD.org/src/rev/8250c8e80e6d
branches:  trunk
changeset: 781423:8250c8e80e6d
user:      tls <tls%NetBSD.org@localhost>
date:      Wed Sep 05 18:06:52 2012 +0000

description:
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.

diffstat:

 sys/kern/kern_rndq.c |  14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diffs (37 lines):

diff -r d36657f26d20 -r 8250c8e80e6d sys/kern/kern_rndq.c
--- a/sys/kern/kern_rndq.c      Wed Sep 05 08:25:53 2012 +0000
+++ b/sys/kern/kern_rndq.c      Wed Sep 05 18:06:52 2012 +0000
@@ -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 @@
 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



Home | Main Index | Thread Index | Old Index