diff options
author | Harald Freudenberger <freude@linux.vnet.ibm.com> | 2017-10-27 09:53:49 -0400 |
---|---|---|
committer | Heiko Carstens <heiko.carstens@de.ibm.com> | 2017-11-08 03:47:51 -0500 |
commit | f44fa88745eda1530083b361e300e1ca4e15a6c5 (patch) | |
tree | e71acb270f3b118f2a3d70b5e8d69f4c2395fd6c | |
parent | 48070c73058be6de9c0d754d441ed7092dfc8f12 (diff) |
s390/archrandom: Reconsider s390 arch random implementation
The reworked version of the random device driver now calls
the arch_get_random_* functions on a very high frequency.
It does about 100.000 calls to arch_get_random_long for
providing 10 MB via /dev/urandom. Each invocation was
fetching entropy from the hardware random generator which
has a rate limit of about 4 MB/s. As the trng invocation
waits until enough entropy is gathered, the random device
driver is slowed down dramatically.
The s390 true random generator is not designed for such
a high rate. The TRNG is more designed to be used together
with the arch_get_random_seed_* functions. This is similar
to the way how powerpc has implemented their arch random
functionality.
This patch removes the invocations of the s390 TRNG for
arch_get_random_long() and arch_get_random_int() but leaving
the invocations for arch_get_random_seed_long() and
arch_get_random_seed_int(). So the s390 arch random
implementation now contributes high quality entropy to
the kernel random device for reseeding.
Signed-off-by: Harald Freudenberger <freude@linux.vnet.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
-rw-r--r-- | arch/s390/include/asm/archrandom.h | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/arch/s390/include/asm/archrandom.h b/arch/s390/include/asm/archrandom.h index 6033901a40b2..9695f8d09edf 100644 --- a/arch/s390/include/asm/archrandom.h +++ b/arch/s390/include/asm/archrandom.h | |||
@@ -27,42 +27,42 @@ static void s390_arch_random_generate(u8 *buf, unsigned int nbytes) | |||
27 | 27 | ||
28 | static inline bool arch_has_random(void) | 28 | static inline bool arch_has_random(void) |
29 | { | 29 | { |
30 | if (static_branch_likely(&s390_arch_random_available)) | ||
31 | return true; | ||
32 | return false; | 30 | return false; |
33 | } | 31 | } |
34 | 32 | ||
35 | static inline bool arch_has_random_seed(void) | 33 | static inline bool arch_has_random_seed(void) |
36 | { | 34 | { |
37 | return arch_has_random(); | 35 | if (static_branch_likely(&s390_arch_random_available)) |
36 | return true; | ||
37 | return false; | ||
38 | } | 38 | } |
39 | 39 | ||
40 | static inline bool arch_get_random_long(unsigned long *v) | 40 | static inline bool arch_get_random_long(unsigned long *v) |
41 | { | 41 | { |
42 | if (static_branch_likely(&s390_arch_random_available)) { | ||
43 | s390_arch_random_generate((u8 *)v, sizeof(*v)); | ||
44 | return true; | ||
45 | } | ||
46 | return false; | 42 | return false; |
47 | } | 43 | } |
48 | 44 | ||
49 | static inline bool arch_get_random_int(unsigned int *v) | 45 | static inline bool arch_get_random_int(unsigned int *v) |
50 | { | 46 | { |
51 | if (static_branch_likely(&s390_arch_random_available)) { | ||
52 | s390_arch_random_generate((u8 *)v, sizeof(*v)); | ||
53 | return true; | ||
54 | } | ||
55 | return false; | 47 | return false; |
56 | } | 48 | } |
57 | 49 | ||
58 | static inline bool arch_get_random_seed_long(unsigned long *v) | 50 | static inline bool arch_get_random_seed_long(unsigned long *v) |
59 | { | 51 | { |
60 | return arch_get_random_long(v); | 52 | if (static_branch_likely(&s390_arch_random_available)) { |
53 | s390_arch_random_generate((u8 *)v, sizeof(*v)); | ||
54 | return true; | ||
55 | } | ||
56 | return false; | ||
61 | } | 57 | } |
62 | 58 | ||
63 | static inline bool arch_get_random_seed_int(unsigned int *v) | 59 | static inline bool arch_get_random_seed_int(unsigned int *v) |
64 | { | 60 | { |
65 | return arch_get_random_int(v); | 61 | if (static_branch_likely(&s390_arch_random_available)) { |
62 | s390_arch_random_generate((u8 *)v, sizeof(*v)); | ||
63 | return true; | ||
64 | } | ||
65 | return false; | ||
66 | } | 66 | } |
67 | 67 | ||
68 | #endif /* CONFIG_ARCH_RANDOM */ | 68 | #endif /* CONFIG_ARCH_RANDOM */ |