summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorJasper Lievisse Adriaanse <jasper@cvs.openbsd.org>2018-04-28 15:45:00 +0000
committerJasper Lievisse Adriaanse <jasper@cvs.openbsd.org>2018-04-28 15:45:00 +0000
commitd2aaab80e37b4e76e5cd539983916e5d7dbaf773 (patch)
treee0d12c3bee51150c5e294631e23df47429d120d4 /sys/dev
parent88c894b365edc9ba3d99f1dba14020c90bf81e72 (diff)
replace add_*_randomness with enqueue_randomness()
this gets rid of the source annotation which doesn't really add anything other than adding complexitiy. randomess is generally good enough that the few extra bits that the source type would add are not worth it. ok mikeb@ deraadt@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/acpi/acpihve.c4
-rw-r--r--sys/dev/fdt/bcm2835_rng.c4
-rw-r--r--sys/dev/fdt/mvrng.c10
-rw-r--r--sys/dev/ic/ccp.c4
-rw-r--r--sys/dev/pci/amdpm.c4
-rw-r--r--sys/dev/pci/bktr/bktr_core.c6
-rw-r--r--sys/dev/pci/hifn7751.c8
-rw-r--r--sys/dev/pci/safe.c4
-rw-r--r--sys/dev/pci/ubsec.c4
-rw-r--r--sys/dev/pv/viornd.c4
-rw-r--r--sys/dev/pv/vmt.c10
-rw-r--r--sys/dev/rnd.c23
-rw-r--r--sys/dev/rndvar.h23
-rw-r--r--sys/dev/usb/uonerng.c4
-rw-r--r--sys/dev/usb/urng.c4
-rw-r--r--sys/dev/wscons/wsmouse.c4
16 files changed, 47 insertions, 73 deletions
diff --git a/sys/dev/acpi/acpihve.c b/sys/dev/acpi/acpihve.c
index 6b573a837e6..037e82a35e3 100644
--- a/sys/dev/acpi/acpihve.c
+++ b/sys/dev/acpi/acpihve.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpihve.c,v 1.1 2017/01/10 08:54:14 jsg Exp $ */
+/* $OpenBSD: acpihve.c,v 1.2 2018/04/28 15:44:59 jasper Exp $ */
/*
* Copyright (c) 2017 Jonathan Gray <jsg@openbsd.org>
@@ -83,7 +83,7 @@ acpihve_attach(struct device *parent, struct device *self, void *aux)
/* 64 bytes of entropy from OEM0 table */
for (i = 0; i < nitems(oem0->entropy); i++)
- add_true_randomness(oem0->entropy[i]);
+ enqueue_randomness(oem0->entropy[i]);
printf("\n");
}
diff --git a/sys/dev/fdt/bcm2835_rng.c b/sys/dev/fdt/bcm2835_rng.c
index 4712e835375..91305fe7a53 100644
--- a/sys/dev/fdt/bcm2835_rng.c
+++ b/sys/dev/fdt/bcm2835_rng.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcm2835_rng.c,v 1.1 2018/02/24 13:46:22 kettenis Exp $ */
+/* $OpenBSD: bcm2835_rng.c,v 1.2 2018/04/28 15:44:59 jasper Exp $ */
/*
* Copyright (c) 2018 Mark Kettenis <kettenis@openbsd.org>
*
@@ -107,7 +107,7 @@ bcmrng_rnd(void *arg)
count = MIN(4, RNG_STATUS_COUNT(status));
for (i = 0; i < count; i++) {
data = HREAD4(sc, RNG_DATA);
- add_true_randomness(data);
+ enqueue_randomness(data);
}
timeout_add_sec(&sc->sc_to, 1);
diff --git a/sys/dev/fdt/mvrng.c b/sys/dev/fdt/mvrng.c
index 9b12e65b824..2169c0a9c23 100644
--- a/sys/dev/fdt/mvrng.c
+++ b/sys/dev/fdt/mvrng.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mvrng.c,v 1.1 2018/04/02 21:40:59 kettenis Exp $ */
+/* $OpenBSD: mvrng.c,v 1.2 2018/04/28 15:44:59 jasper Exp $ */
/*
* Copyright (c) 2018 Mark Kettenis <kettenis@openbsd.org>
*
@@ -136,10 +136,10 @@ mvrng_rnd(void *arg)
HWRITE4(sc, RNG_STATUS, RNG_STATUS_SHUTDOWN);
}
if (status & RNG_STATUS_READY) {
- add_true_randomness(HREAD4(sc, RNG_OUTPUT0));
- add_true_randomness(HREAD4(sc, RNG_OUTPUT1));
- add_true_randomness(HREAD4(sc, RNG_OUTPUT2));
- add_true_randomness(HREAD4(sc, RNG_OUTPUT3));
+ enqueue_randomness(HREAD4(sc, RNG_OUTPUT0));
+ enqueue_randomness(HREAD4(sc, RNG_OUTPUT1));
+ enqueue_randomness(HREAD4(sc, RNG_OUTPUT2));
+ enqueue_randomness(HREAD4(sc, RNG_OUTPUT3));
HWRITE4(sc, RNG_STATUS, RNG_STATUS_READY);
}
diff --git a/sys/dev/ic/ccp.c b/sys/dev/ic/ccp.c
index 76bce67d254..360e24938f4 100644
--- a/sys/dev/ic/ccp.c
+++ b/sys/dev/ic/ccp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ccp.c,v 1.1 2018/04/20 04:37:21 dlg Exp $ */
+/* $OpenBSD: ccp.c,v 1.2 2018/04/28 15:44:59 jasper Exp $ */
/*
* Copyright (c) 2018 David Gwynne <dlg@openbsd.org>
@@ -57,7 +57,7 @@ ccp_rng(void *arg)
trng = bus_space_read_4(sc->sc_iot, sc->sc_ioh, CCP_REG_TRNG);
if (trng != 0)
- add_true_randomness(trng);
+ enqueue_randomness(trng);
timeout_add_msec(&sc->sc_tick, 100);
}
diff --git a/sys/dev/pci/amdpm.c b/sys/dev/pci/amdpm.c
index 310a719f2af..7a0cff54547 100644
--- a/sys/dev/pci/amdpm.c
+++ b/sys/dev/pci/amdpm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: amdpm.c,v 1.32 2013/12/06 21:03:03 deraadt Exp $ */
+/* $OpenBSD: amdpm.c,v 1.33 2018/04/28 15:44:59 jasper Exp $ */
/*
* Copyright (c) 2006 Alexander Yurchenko <grange@openbsd.org>
@@ -344,7 +344,7 @@ amdpm_rnd_callout(void *v)
if ((bus_space_read_4(sc->sc_iot, sc->sc_ioh, AMDPM_RNGSTAT) &
AMDPM_RNGDONE) != 0) {
reg = bus_space_read_4(sc->sc_iot, sc->sc_ioh, AMDPM_RNGDATA);
- add_true_randomness(reg);
+ enqueue_randomness(reg);
}
timeout_add(&sc->sc_rnd_ch, 1);
}
diff --git a/sys/dev/pci/bktr/bktr_core.c b/sys/dev/pci/bktr/bktr_core.c
index 40f3359e336..130f83448b9 100644
--- a/sys/dev/pci/bktr/bktr_core.c
+++ b/sys/dev/pci/bktr/bktr_core.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bktr_core.c,v 1.38 2016/03/14 23:08:06 krw Exp $ */
+/* $OpenBSD: bktr_core.c,v 1.39 2018/04/28 15:44:59 jasper Exp $ */
/* $FreeBSD: src/sys/dev/bktr/bktr_core.c,v 1.114 2000/10/31 13:09:56 roger Exp $ */
/*
@@ -608,7 +608,7 @@ common_bktr_intr( void *arg )
OUTB(bktr, BKTR_CAP_CTL, bktr->bktr_cap_ctl);
- add_video_randomness(tdec_save);
+ enqueue_randomness(tdec_save);
return 1;
}
@@ -622,7 +622,7 @@ common_bktr_intr( void *arg )
bktr_status, dstatus, INL(bktr, BKTR_RISC_COUNT) );
*/
- add_video_randomness(INL(bktr, BKTR_RISC_COUNT));
+ enqueue_randomness(INL(bktr, BKTR_RISC_COUNT));
/*
* Disable future interrupts if a capture mode is not selected.
diff --git a/sys/dev/pci/hifn7751.c b/sys/dev/pci/hifn7751.c
index 6f55e6783e5..4712a678dc0 100644
--- a/sys/dev/pci/hifn7751.c
+++ b/sys/dev/pci/hifn7751.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hifn7751.c,v 1.177 2017/02/07 17:25:46 patrick Exp $ */
+/* $OpenBSD: hifn7751.c,v 1.178 2018/04/28 15:44:59 jasper Exp $ */
/*
* Invertex AEON / Hifn 7751 driver
@@ -420,8 +420,8 @@ hifn_rng(void *vsc)
if (sc->sc_rngfirst)
sc->sc_rngfirst = 0;
else {
- add_true_randomness(num1);
- add_true_randomness(num2);
+ enqueue_randomness(num1);
+ enqueue_randomness(num2);
}
}
} else {
@@ -430,7 +430,7 @@ hifn_rng(void *vsc)
if (sc->sc_rngfirst)
sc->sc_rngfirst = 0;
else
- add_true_randomness(num1);
+ enqueue_randomness(num1);
}
timeout_add(&sc->sc_rngto, sc->sc_rnghz);
diff --git a/sys/dev/pci/safe.c b/sys/dev/pci/safe.c
index 0a4c0de75a5..801e982455f 100644
--- a/sys/dev/pci/safe.c
+++ b/sys/dev/pci/safe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: safe.c,v 1.42 2017/02/07 17:25:46 patrick Exp $ */
+/* $OpenBSD: safe.c,v 1.43 2018/04/28 15:44:59 jasper Exp $ */
/*-
* Copyright (c) 2003 Sam Leffler, Errno Consulting
@@ -1236,7 +1236,7 @@ retry:
WRITE_REG(sc, SAFE_RNG_ALM_CNT, 0);
for (i = 0; i < maxwords; i++)
- add_true_randomness(buf[i]);
+ enqueue_randomness(buf[i]);
timeout_add_sec(&sc->sc_rngto, safe_rnginterval);
}
diff --git a/sys/dev/pci/ubsec.c b/sys/dev/pci/ubsec.c
index 70517670e7b..b7015fd33c5 100644
--- a/sys/dev/pci/ubsec.c
+++ b/sys/dev/pci/ubsec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ubsec.c,v 1.163 2017/02/07 17:25:46 patrick Exp $ */
+/* $OpenBSD: ubsec.c,v 1.164 2018/04/28 15:44:59 jasper Exp $ */
/*
* Copyright (c) 2000 Jason L. Wright (jason@thought.net)
@@ -1453,7 +1453,7 @@ ubsec_callback2(struct ubsec_softc *sc, struct ubsec_q2 *q)
rng->rng_buf.dma_map->dm_mapsize, BUS_DMASYNC_POSTREAD);
p = (u_int32_t *)rng->rng_buf.dma_vaddr;
for (i = 0; i < UBSEC_RNG_BUFSIZ; p++, i++)
- add_true_randomness(*p);
+ enqueue_randomness(*p);
rng->rng_used = 0;
timeout_add(&sc->sc_rngto, sc->sc_rnghz);
break;
diff --git a/sys/dev/pv/viornd.c b/sys/dev/pv/viornd.c
index dc0a43738b7..9d1e8c60938 100644
--- a/sys/dev/pv/viornd.c
+++ b/sys/dev/pv/viornd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: viornd.c,v 1.1 2017/01/21 11:22:48 reyk Exp $ */
+/* $OpenBSD: viornd.c,v 1.2 2018/04/28 15:44:59 jasper Exp $ */
/*
* Copyright (c) 2014 Stefan Fritsch <sf@sfritsch.de>
@@ -172,7 +172,7 @@ viornd_vq_done(struct virtqueue *vq)
printf("%s: got %d bytes of entropy\n", __func__, len);
#endif
for (i = 0; (i + 1) * sizeof(int) <= len; i++)
- add_true_randomness(sc->sc_buf[i]);
+ enqueue_randomness(sc->sc_buf[i]);
if (sc->sc_interval)
timeout_add_sec(&sc->sc_tick, sc->sc_interval);
diff --git a/sys/dev/pv/vmt.c b/sys/dev/pv/vmt.c
index 6e74ad65a97..179136a3ba2 100644
--- a/sys/dev/pv/vmt.c
+++ b/sys/dev/pv/vmt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmt.c,v 1.14 2018/03/08 05:33:56 jmatthew Exp $ */
+/* $OpenBSD: vmt.c,v 1.15 2018/04/28 15:44:59 jasper Exp $ */
/*
* Copyright (c) 2007 David Crawshaw <david@zentus.com>
@@ -479,10 +479,10 @@ vmt_resume(void)
vm_cmd(&frame);
rdrand(NULL);
- add_true_randomness(frame.eax.word);
- add_true_randomness(frame.esi.word);
- add_true_randomness(frame.edx.word);
- add_true_randomness(frame.ebx.word);
+ enqueue_randomness(frame.eax.word);
+ enqueue_randomness(frame.esi.word);
+ enqueue_randomness(frame.edx.word);
+ enqueue_randomness(frame.ebx.word);
resume_randomness(NULL, 0);
}
diff --git a/sys/dev/rnd.c b/sys/dev/rnd.c
index e33cb5fd7c0..1ed87557db3 100644
--- a/sys/dev/rnd.c
+++ b/sys/dev/rnd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rnd.c,v 1.198 2018/02/09 03:01:24 deraadt Exp $ */
+/* $OpenBSD: rnd.c,v 1.199 2018/04/28 15:44:59 jasper Exp $ */
/*
* Copyright (c) 2011 Theo de Raadt.
@@ -199,7 +199,7 @@
/*
* Raw entropy collection from device drivers; at interrupt context or not.
- * add_*_randomness() provide data which is put into the entropy queue.
+ * enqueue_randomness() provide data which is put into the entropy queue.
*/
#define QEVLEN 128 /* must be a power of 2 */
@@ -284,22 +284,15 @@ rnd_qlen(void)
* are for keyboard scan codes, 256 and upwards - for interrupts.
*/
void
-enqueue_randomness(u_int state, u_int val)
+enqueue_randomness(u_int val)
{
struct rand_event *rep;
struct timespec ts;
u_int qlen;
-#ifdef DIAGNOSTIC
- if (state >= RND_SRC_NUM)
- return;
-#endif
-
if (timeout_initialized(&rnd_timeout))
nanotime(&ts);
- val += state << 13;
-
mtx_enter(&rnd_enqlck);
rep = rnd_put();
rep->re_time += ts.tv_nsec ^ (ts.tv_sec << 20);
@@ -417,7 +410,7 @@ extract_entropy(u_int8_t *buf)
memcpy(buf, digest, EBUFSIZE);
/* Modify pool so next hash will produce different results */
- add_timer_randomness(EBUFSIZE);
+ enqueue_randomness(EBUFSIZE);
dequeue_randomness(NULL);
/* Wipe data from memory */
@@ -447,8 +440,8 @@ suspend_randomness(void)
struct timespec ts;
getnanotime(&ts);
- add_true_randomness(ts.tv_sec);
- add_true_randomness(ts.tv_nsec);
+ enqueue_randomness(ts.tv_sec);
+ enqueue_randomness(ts.tv_nsec);
dequeue_randomness(NULL);
rs_count = 0;
@@ -463,8 +456,8 @@ resume_randomness(char *buf, size_t buflen)
if (buf && buflen)
_rs_seed(buf, buflen);
getnanotime(&ts);
- add_true_randomness(ts.tv_sec);
- add_true_randomness(ts.tv_nsec);
+ enqueue_randomness(ts.tv_sec);
+ enqueue_randomness(ts.tv_nsec);
dequeue_randomness(NULL);
rs_count = 0;
diff --git a/sys/dev/rndvar.h b/sys/dev/rndvar.h
index 98b70e8919a..e5cc8c16117 100644
--- a/sys/dev/rndvar.h
+++ b/sys/dev/rndvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rndvar.h,v 1.38 2016/05/23 15:48:59 deraadt Exp $ */
+/* $OpenBSD: rndvar.h,v 1.39 2018/04/28 15:44:59 jasper Exp $ */
/*
* Copyright (c) 1996,2000 Michael Shalayeff.
@@ -31,29 +31,10 @@
#ifndef __RNDVAR_H__
#define __RNDVAR_H__
-#define RND_SRC_TRUE 0
-#define RND_SRC_TIMER 1
-#define RND_SRC_MOUSE 2
-#define RND_SRC_TTY 3
-#define RND_SRC_DISK 4
-#define RND_SRC_NET 5
-#define RND_SRC_AUDIO 6
-#define RND_SRC_VIDEO 7
-#define RND_SRC_NUM 8
-
#ifdef _KERNEL
-#define add_true_randomness(d) enqueue_randomness(RND_SRC_TRUE, (int)(d))
-#define add_timer_randomness(d) enqueue_randomness(RND_SRC_TIMER, (int)(d))
-#define add_mouse_randomness(d) enqueue_randomness(RND_SRC_MOUSE, (int)(d))
-#define add_tty_randomness(d) enqueue_randomness(RND_SRC_TTY, (int)(d))
-#define add_disk_randomness(d) enqueue_randomness(RND_SRC_DISK, (int)(d))
-#define add_net_randomness(d) enqueue_randomness(RND_SRC_NET, (int)(d))
-#define add_audio_randomness(d) enqueue_randomness(RND_SRC_AUDIO, (int)(d))
-#define add_video_randomness(d) enqueue_randomness(RND_SRC_VIDEO, (int)(d))
-
void random_start(void);
-void enqueue_randomness(unsigned int, unsigned int);
+void enqueue_randomness(unsigned int);
void suspend_randomness(void);
void resume_randomness(char *, size_t);
diff --git a/sys/dev/usb/uonerng.c b/sys/dev/usb/uonerng.c
index a9f81810b73..9e59988a187 100644
--- a/sys/dev/usb/uonerng.c
+++ b/sys/dev/usb/uonerng.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uonerng.c,v 1.2 2016/09/02 09:14:59 mpi Exp $ */
+/* $OpenBSD: uonerng.c,v 1.3 2018/04/28 15:44:59 jasper Exp $ */
/*
* Copyright (C) 2015 Devin Reade <gdr@gno.org>
* Copyright (C) 2015 Sean Levy <attila@stalphonsos.com>
@@ -424,7 +424,7 @@ uonerng_task(void *arg)
int_count = len / sizeof(int);
for (i = 0; i < int_count; i++) {
- add_true_randomness(sc->sc_buf[i]);
+ enqueue_randomness(sc->sc_buf[i]);
}
bail:
diff --git a/sys/dev/usb/urng.c b/sys/dev/usb/urng.c
index 81403da7774..a221c978fab 100644
--- a/sys/dev/usb/urng.c
+++ b/sys/dev/usb/urng.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: urng.c,v 1.7 2017/09/12 19:14:35 jasper Exp $ */
+/* $OpenBSD: urng.c,v 1.8 2018/04/28 15:44:59 jasper Exp $ */
/*
* Copyright (c) 2017 Jasper Lievisse Adriaanse <jasper@openbsd.org>
@@ -280,7 +280,7 @@ urng_task(void *arg)
len /= sizeof(int);
for (i = 0; i < len; i++) {
- add_true_randomness(sc->sc_buf[i]);
+ enqueue_randomness(sc->sc_buf[i]);
}
bail:
#ifdef URNG_MEASURE_RATE
diff --git a/sys/dev/wscons/wsmouse.c b/sys/dev/wscons/wsmouse.c
index 78ad9e110d4..0b0f654c395 100644
--- a/sys/dev/wscons/wsmouse.c
+++ b/sys/dev/wscons/wsmouse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsmouse.c,v 1.43 2018/01/13 11:54:01 bru Exp $ */
+/* $OpenBSD: wsmouse.c,v 1.44 2018/04/28 15:44:59 jasper Exp $ */
/* $NetBSD: wsmouse.c,v 1.35 2005/02/27 00:27:52 perry Exp $ */
/*
@@ -1106,7 +1106,7 @@ wsmouse_input_sync(struct device *sc)
evq.result = EVQ_RESULT_NONE;
getnanotime(&evq.ts);
- add_mouse_randomness(input->btn.buttons
+ enqueue_randomness(input->btn.buttons
^ input->motion.dx ^ input->motion.dy
^ input->motion.pos.x ^ input->motion.pos.y
^ input->motion.dz ^ input->motion.dw);