From 4a742633d6ac5f37d98d5c4a963fbfd491bc9ecd Mon Sep 17 00:00:00 2001 From: Christian Weisgerber Date: Sun, 14 Jun 2020 20:29:14 +0000 Subject: Implement cpu_rnd_messybits() as a read of the cycle counter register. ok dlg@ deraadt@ --- sys/arch/hppa/hppa/machdep.c | 11 +---------- sys/arch/hppa/include/cpu.h | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 12 deletions(-) (limited to 'sys/arch') 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 #include +#include #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); -- cgit v1.2.3