summaryrefslogtreecommitdiff
path: root/sys/arch/landisk
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2020-05-31 06:23:59 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2020-05-31 06:23:59 +0000
commit25b4125b327f17225a5de582ccfd640025bb27d3 (patch)
treeee95f79a0d69f6e2f59cafc1268e14b289657fb1 /sys/arch/landisk
parentb53b5d52307ccca87e152ec67a8c103119b09eb3 (diff)
introduce "cpu_rnd_messybits" for use instead of nanotime in dev/rnd.c.
rnd.c uses nanotime to get access to some bits that change quickly between events that it can mix into the entropy pool. it doesn't use nanotime to get a monotonically increasing set or ordered and accurate timestamps, it just wants something with bits that change. there's been discussions for years about letting rnd use a clock that's super fast to read, but not necessarily accurate, but it wasn't until recently that i figured out it wasn't interested in time at all, so things like keeping a fast clock coherent between cpu cores or correct according to ntp is unecessary. this means we can just let rnd read the cycle counters on cpus and things will be fine. cpus with cycle counters that vary in their speed and arent kept consistent between cores may even be desirable in this context. so this is the first step in converting rnd.c to reading cycle counter. it copies the nanotime backend to each arch, and they can replace it with something MD as a second step later on. djm@ suggested rnd_messybytes, but we landed on cpu_rnd_messybits. thanks to visa for his eyes. ok deraadt@ visa@ deraadt@ says he will help handle any MD fallout that occurs.
Diffstat (limited to 'sys/arch/landisk')
-rw-r--r--sys/arch/landisk/landisk/machdep.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/sys/arch/landisk/landisk/machdep.c b/sys/arch/landisk/landisk/machdep.c
index 48de8c85ee4..d5ea8df1740 100644
--- a/sys/arch/landisk/landisk/machdep.c
+++ b/sys/arch/landisk/landisk/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.47 2019/04/01 07:00:52 tedu Exp $ */
+/* $OpenBSD: machdep.c,v 1.48 2020/05/31 06:23:57 dlg Exp $ */
/* $NetBSD: machdep.c,v 1.1 2006/09/01 21:26:18 uwe Exp $ */
/*-
@@ -509,3 +509,12 @@ blink_led(void *whatever)
timeout_add(&blink_tmo,
((averunnable.ldavg[0] + FSCALE) * hz) >> FSHIFT);
}
+
+unsigned int
+cpu_rnd_messybits(void)
+{
+ struct timespec ts;
+
+ nanotime(&ts);
+ return (ts.tv_nsec ^ (ts.tv_sec << 20));
+}