summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorChristian Weisgerber <naddy@cvs.openbsd.org>2020-06-14 20:29:14 +0000
committerChristian Weisgerber <naddy@cvs.openbsd.org>2020-06-14 20:29:14 +0000
commit4a742633d6ac5f37d98d5c4a963fbfd491bc9ecd (patch)
tree4b5cfe286c4a7e08a9700505e8fb87861daf4d8d /sys/arch
parent606873c48d0bd8ce0fdab9b85b4b7ecc84425e14 (diff)
Implement cpu_rnd_messybits() as a read of the cycle counter register.
ok dlg@ deraadt@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/hppa/hppa/machdep.c11
-rw-r--r--sys/arch/hppa/include/cpu.h14
2 files changed, 13 insertions, 12 deletions
diff --git a/sys/arch/hppa/hppa/machdep.c b/sys/arch/hppa/hppa/machdep.c
index f7bb998d53e..6bee297e07d 100644
--- a/sys/arch/hppa/hppa/machdep.c
+++ b/sys/arch/hppa/hppa/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.259 2020/05/31 06:23:57 dlg Exp $ */
+/* $OpenBSD: machdep.c,v 1.260 2020/06/14 20:29:13 naddy Exp $ */
/*
* Copyright (c) 1999-2003 Michael Shalayeff
@@ -1496,12 +1496,3 @@ blink_led_timeout(void *vsc)
t = (((averunnable.ldavg[0] + FSCALE) * hz) >> (FSHIFT + 1));
timeout_add(&sc->bls_to, t);
}
-
-unsigned int
-cpu_rnd_messybits(void)
-{
- struct timespec ts;
-
- nanotime(&ts);
- return (ts.tv_nsec ^ (ts.tv_sec << 20));
-}
diff --git a/sys/arch/hppa/include/cpu.h b/sys/arch/hppa/include/cpu.h
index 902b10e8d6b..dc32d050c00 100644
--- a/sys/arch/hppa/include/cpu.h
+++ b/sys/arch/hppa/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.92 2020/05/31 06:23:57 dlg Exp $ */
+/* $OpenBSD: cpu.h,v 1.93 2020/06/14 20:29:13 naddy Exp $ */
/*
* Copyright (c) 2000-2004 Michael Shalayeff
@@ -54,6 +54,7 @@
#ifdef _KERNEL
#include <machine/trap.h>
#include <machine/frame.h>
+#include <machine/reg.h>
#endif /* _KERNEL */
/*
@@ -237,7 +238,16 @@ int copy_on_fault(void);
void switch_trampoline(void);
int cpu_dumpsize(void);
int cpu_dump(void);
-unsigned int cpu_rnd_messybits(void);
+
+static inline unsigned int
+cpu_rnd_messybits(void)
+{
+ unsigned int __itmr;
+
+ __asm volatile("mfctl %1,%0": "=r" (__itmr) : "i" (CR_ITMR));
+
+ return (__itmr);
+}
#ifdef MULTIPROCESSOR
void cpu_boot_secondary_processors(void);