mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-22 22:11:22 +07:00
01c9348c76
The hardware RNG on POWER8 and POWER7+ can be relatively slow, since it can only supply one 64-bit value per microsecond. Currently we read it in arch_get_random_long(), but that slows down reading from /dev/urandom since the code in random.c calls arch_get_random_long() for every longword read from /dev/urandom. Since the hardware RNG supplies high-quality entropy on every read, it matches the semantics of arch_get_random_seed_long() better than those of arch_get_random_long(). Therefore this commit makes the code use the POWER8/7+ hardware RNG only for arch_get_random_seed_{long,int} and not for arch_get_random_{long,int}. This won't affect any other PowerPC-based platforms because none of them currently support a hardware RNG. To make it clear that the ppc_md function pointer is used for arch_get_random_seed_*, we rename it from get_random_long to get_random_seed. Signed-off-by: Paul Mackerras <paulus@samba.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
58 lines
1.1 KiB
C
58 lines
1.1 KiB
C
#ifndef _ASM_POWERPC_ARCHRANDOM_H
|
|
#define _ASM_POWERPC_ARCHRANDOM_H
|
|
|
|
#ifdef CONFIG_ARCH_RANDOM
|
|
|
|
#include <asm/machdep.h>
|
|
|
|
static inline int arch_get_random_long(unsigned long *v)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline int arch_get_random_int(unsigned int *v)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline int arch_get_random_seed_long(unsigned long *v)
|
|
{
|
|
if (ppc_md.get_random_seed)
|
|
return ppc_md.get_random_seed(v);
|
|
|
|
return 0;
|
|
}
|
|
static inline int arch_get_random_seed_int(unsigned int *v)
|
|
{
|
|
unsigned long val;
|
|
int rc;
|
|
|
|
rc = arch_get_random_long(&val);
|
|
if (rc)
|
|
*v = val;
|
|
|
|
return rc;
|
|
}
|
|
|
|
static inline int arch_has_random(void)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline int arch_has_random_seed(void)
|
|
{
|
|
return !!ppc_md.get_random_seed;
|
|
}
|
|
#endif /* CONFIG_ARCH_RANDOM */
|
|
|
|
#ifdef CONFIG_PPC_POWERNV
|
|
int powernv_hwrng_present(void);
|
|
int powernv_get_random_long(unsigned long *v);
|
|
int powernv_get_random_real_mode(unsigned long *v);
|
|
#else
|
|
static inline int powernv_hwrng_present(void) { return 0; }
|
|
static inline int powernv_get_random_real_mode(unsigned long *v) { return 0; }
|
|
#endif
|
|
|
|
#endif /* _ASM_POWERPC_ARCHRANDOM_H */
|