Index: rnd.c =================================================================== RCS file: /cvs/src/sys/dev/rnd.c,v retrieving revision 1.212 diff -u -p -r1.212 rnd.c --- rnd.c 16 May 2020 19:07:04 -0000 1.212 +++ rnd.c 18 May 2020 04:24:15 -0000 @@ -138,8 +138,6 @@ u_int rnd_event_prod; struct mutex rnd_enqlck = MUTEX_INITIALIZER(IPL_HIGH); struct mutex rnd_deqlck = MUTEX_INITIALIZER(IPL_HIGH); -struct timeout rnd_timeout; - static u_int32_t entropy_pool[POOLWORDS]; u_int32_t entropy_pool0[POOLWORDS] __attribute__((section(".openbsd.randomdata"))); @@ -148,6 +146,8 @@ void add_entropy_words(const u_int32_t * void extract_entropy(u_int8_t *) __attribute__((__bounded__(__minbytes__,1,EBUFSIZE))); +struct timeout rnd_timeout = TIMEOUT_INITIALIZER(dequeue_randomness, NULL); + int filt_randomread(struct knote *, long); void filt_randomdetach(struct knote *); int filt_randomwrite(struct knote *, long); @@ -209,9 +209,7 @@ enqueue_randomness(u_int val) struct timespec ts; u_int qlen; - timespecclear(&ts); - if (timeout_initialized(&rnd_timeout)) - nanotime(&ts); + nanotime(&ts); mtx_enter(&rnd_enqlck); rep = rnd_put(); @@ -220,8 +218,7 @@ enqueue_randomness(u_int val) qlen = rnd_qlen(); mtx_leave(&rnd_enqlck); - if (qlen > QEVSLOW/2 && timeout_initialized(&rnd_timeout) && - !timeout_pending(&rnd_timeout)) + if (qlen > QEVSLOW/2 && !timeout_pending(&rnd_timeout)) timeout_add(&rnd_timeout, 1); } @@ -277,8 +274,7 @@ dequeue_randomness(void *v) struct rand_event *rep; u_int32_t buf[2]; - if (timeout_initialized(&rnd_timeout)) - timeout_del(&rnd_timeout); + timeout_del(&rnd_timeout); mtx_enter(&rnd_deqlck); while ((rep = rnd_get())) { @@ -337,7 +333,7 @@ void rnd_reinit(void *v); /* timeout to void rnd_init(void *); /* actually do the reinit */ struct mutex rndlock = MUTEX_INITIALIZER(IPL_HIGH); -struct timeout rndreinit_timeout; +struct timeout rndreinit_timeout = TIMEOUT_INITIALIZER(rnd_reinit, NULL); struct task rnd_task = TASK_INITIALIZER(rnd_init, NULL); static chacha_ctx rs; /* chacha context for random keystream */ @@ -674,9 +670,7 @@ random_start(void) dequeue_randomness(NULL); rnd_init(NULL); - timeout_set(&rndreinit_timeout, rnd_reinit, NULL); rnd_reinit(NULL); - timeout_set(&rnd_timeout, dequeue_randomness, NULL); } int