diff options
Diffstat (limited to 'sys/kern/subr_bus.c')
-rw-r--r-- | sys/kern/subr_bus.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index b3b1852..5c4c329 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$"); #include "opt_bus.h" +#include "opt_random.h" #include <sys/param.h> #include <sys/conf.h> @@ -44,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include <sys/condvar.h> #include <sys/queue.h> #include <machine/bus.h> +#include <sys/random.h> #include <sys/rman.h> #include <sys/selinfo.h> #include <sys/signalvar.h> @@ -55,6 +57,7 @@ __FBSDID("$FreeBSD$"); #include <net/vnet.h> +#include <machine/cpu.h> #include <machine/stdarg.h> #include <vm/uma.h> @@ -2766,6 +2769,7 @@ device_probe_and_attach(device_t dev) int device_attach(device_t dev) { + uint64_t attachtime; int error; if (resource_disabled(dev->driver->name, dev->unit)) { @@ -2778,6 +2782,7 @@ device_attach(device_t dev) device_sysctl_init(dev); if (!device_is_quiet(dev)) device_print_child(dev->parent, dev); + attachtime = get_cyclecount(); dev->state = DS_ATTACHING; if ((error = DEVICE_ATTACH(dev)) != 0) { printf("device_attach: %s%d attach returned %d\n", @@ -2790,6 +2795,17 @@ device_attach(device_t dev) dev->state = DS_NOTPRESENT; return (error); } + attachtime = get_cyclecount() - attachtime; + /* + * 4 bits per device is a reasonable value for desktop and server + * hardware with good get_cyclecount() implementations, but may + * need to be adjusted on other platforms. + */ +#ifdef RANDOM_DEBUG + printf("%s(): feeding %d bit(s) of entropy from %s%d\n", + __func__, 4, dev->driver->name, dev->unit); +#endif + random_harvest(&attachtime, sizeof(attachtime), 4, RANDOM_ATTACH); device_sysctl_update(dev); if (dev->busy) dev->state = DS_BUSY; |