m68k: Add infrastructure for machine-specific random_get_entropy()
Geert Uytterhoeven
maintainerPATCH v2 1/2 m68k: Add infrastructure for machine-specific random_get_entropy()
On m68k, get_cycles() (the default implementation for random_get_entropy()) always returns zero, providing no entropy for the random driver.
Add a hook where platforms can provide their own implementation, and wire it up in the infrastructure provided by commit 61875f30daf60305712e25b209ef41ced2635bad ("random: allow architectures to optionally define random_get_entropy()").
---
v2:
- Hook for random_get_entropy() instead of get_cycles()
arch/m68k/include/asm/timex.h | 10 ++++++++++ arch/m68k/kernel/time.c | 4 ++++ 2 files changed, 14 insertions(+)
arch/m68k/include/asm/timex.h +10 -0
@@ -28,4 +28,14 @@ static inline cycles_t get_cycles(void) return 0; } +extern unsigned long (*mach_random_get_entropy)(void ); + +static inline unsigned long random_get_entropy (void ) +{ +if (mach_random_get_entropy) +return mach_random_get_entropy (); +return 0 ; +} +#define random_get_entropy random_get_entropy +#endif
arch/m68k/kernel/time.c +4 -0
@@ -28,6 +28,10 @@#include <linux/timex.h> #include <linux/profile.h> + +unsigned long (*mach_random_get_entropy)(void ); + +/* * timer_interrupt() needs to keep up the real-time clock, * as well as call the "xtime_update()" routine every clocktick
Signature · 1 line
1.7.9.5
Geert Uytterhoeven
maintainerPATCH v2 2/2 m68k/amiga: Provide mach_random_get_entropy()
Use the beam position registers, which provide at least 17 bits of data changing at 1.79 MHz.
---
v2:
- Use beam position registers (which provide a faster rate but less bits) instead of 24-bit Time-Of-Day clock in CIA B running at HSYNC.
arch/m68k/amiga/config.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/m68k/amiga/config.c +10 -0
@@ -354,6 +354,14 @@ static void __init amiga_identify(void)#undef AMIGAHW_ANNOUNCE } + +static unsigned long amiga_random_get_entropy (void ) +{ +/* VPOSR/VHPOSR provide at least 17 bits of data changing at 1.79 MHz */ +return *(unsigned long *)&amiga_custom.vposr; +} + +/* * Setup the Amiga configuration info */
@@ -391,6 +399,8 @@ void __init config_amiga(void) mach_heartbeat = amiga_heartbeat;#endif + mach_random_get_entropy = amiga_random_get_entropy; +/* Fill in the clock value (based on the 700 kHz E-Clock) */ amiga_colorclock =5 *amiga_eclock;/* 3.5 MHz */
Signature · 1 line
1.7.9.5
Geert Uytterhoeven
maintainerPATCH v2 2/2 m68k/amiga: Provide mach_random_get_entropy()
In reply to Geert UytterhoevenUse the beam position registers, which provide at least 17 bits of data changing at 1.79 MHz.
---
v2:
- Use beam position registers (which provide a faster rate but less bits) instead of 24-bit Time-Of-Day clock in CIA B running at HSYNC.
arch/m68k/amiga/config.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/m68k/amiga/config.c +10 -0
@@ -354,6 +354,14 @@ static void __init amiga_identify(void)#undef AMIGAHW_ANNOUNCE } + +static unsigned long amiga_random_get_entropy (void ) +{ +/* VPOSR/VHPOSR provide at least 17 bits of data changing at 1.79 MHz */ +return *(unsigned long *)&amiga_custom.vposr; +} + +/* * Setup the Amiga configuration info */
@@ -391,6 +399,8 @@ void __init config_amiga(void) mach_heartbeat = amiga_heartbeat;#endif + mach_random_get_entropy = amiga_random_get_entropy; +/* Fill in the clock value (based on the 700 kHz E-Clock) */ amiga_colorclock =5 *amiga_eclock;/* 3.5 MHz */
Signature · 1 line
1.7.9.5