Source-Changes-HG archive

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

[src/trunk]: src/sys/kern autoconf(9): Enter more timing samples into entropy...



details:   https://anonhg.NetBSD.org/src/rev/8c5e2b1b1b1a
branches:  trunk
changeset: 364405:8c5e2b1b1b1a
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Mar 21 22:20:32 2022 +0000

description:
autoconf(9): Enter more timing samples into entropy pool.

Previously, we sampled the time of each _failed_ config_search.  I'm
not sure why -- there was no explanation in the comment or the commit
message introducing this in rev. 1.230.2.1 on tls-earlyentropy.

With this change, we sample the time of _every_ search including the
successful ones -- and also measure the time to attach which often
includes things like probing device registers, triggering device
reset and waiting for it to post, &c.

diffstat:

 sys/kern/subr_autoconf.c |  14 ++++----------
 1 files changed, 4 insertions(+), 10 deletions(-)

diffs (49 lines):

diff -r 20e4681f2fe0 -r 8c5e2b1b1b1a sys/kern/subr_autoconf.c
--- a/sys/kern/subr_autoconf.c  Mon Mar 21 09:20:04 2022 +0000
+++ b/sys/kern/subr_autoconf.c  Mon Mar 21 22:20:32 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.296 2022/03/12 19:26:33 riastradh Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.297 2022/03/21 22:20:32 riastradh Exp $ */
 
 /*
  * Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.296 2022/03/12 19:26:33 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.297 2022/03/21 22:20:32 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -1184,6 +1184,7 @@
                                mapply(&m, cf);
                }
        }
+       rnd_add_uint32(&rnd_autoconf_source, 0);
        return m.match;
 }
 
@@ -1270,14 +1271,6 @@
                aprint_normal("%s", msgs[pret]);
        }
 
-       /*
-        * This has the effect of mixing in a single timestamp to the
-        * entropy pool.  Experiments indicate the estimator will almost
-        * always attribute one bit of entropy to this sample; analysis
-        * of device attach/detach timestamps on FreeBSD indicates 4
-        * bits of entropy/sample so this seems appropriately conservative.
-        */
-       rnd_add_uint32(&rnd_autoconf_source, 0);
        return NULL;
 }
 
@@ -1771,6 +1764,7 @@
        config_process_deferred(&deferred_config_queue, dev);
 
        device_register_post_config(dev, aux);
+       rnd_add_uint32(&rnd_autoconf_source, 0);
        return dev;
 }
 



Home | Main Index | Thread Index | Old Index