Skip to content

Commit acd7750

Browse files
committed
Merge tag 'random_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random
Pull random changes from Ted Ts'o: "Change /dev/random so that it uses the CRNG and only blocking if the CRNG hasn't initialized, instead of the old blocking pool. Also clean up archrandom.h, and some other miscellaneous cleanups" * tag 'random_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random: (24 commits) s390x: Mark archrandom.h functions __must_check powerpc: Mark archrandom.h functions __must_check powerpc: Use bool in archrandom.h x86: Mark archrandom.h functions __must_check linux/random.h: Mark CONFIG_ARCH_RANDOM functions __must_check linux/random.h: Use false with bool linux/random.h: Remove arch_has_random, arch_has_random_seed s390: Remove arch_has_random, arch_has_random_seed powerpc: Remove arch_has_random, arch_has_random_seed x86: Remove arch_has_random, arch_has_random_seed random: remove some dead code of poolinfo random: fix typo in add_timer_randomness() random: Add and use pr_fmt() random: convert to ENTROPY_BITS for better code readability random: remove unnecessary unlikely() random: remove kernel.random.read_wakeup_threshold random: delete code to pull data into pools random: remove the blocking pool random: make /dev/random be almost like /dev/urandom random: ignore GRND_RANDOM in getentropy(2) ...
2 parents 26dca6d + 4cb760b commit acd7750

File tree

6 files changed

+89
-330
lines changed

6 files changed

+89
-330
lines changed

arch/powerpc/include/asm/archrandom.h

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,35 @@
66

77
#include <asm/machdep.h>
88

9-
static inline int arch_get_random_long(unsigned long *v)
9+
static inline bool __must_check arch_get_random_long(unsigned long *v)
1010
{
11-
return 0;
11+
return false;
1212
}
1313

14-
static inline int arch_get_random_int(unsigned int *v)
14+
static inline bool __must_check arch_get_random_int(unsigned int *v)
1515
{
16-
return 0;
16+
return false;
1717
}
1818

19-
static inline int arch_get_random_seed_long(unsigned long *v)
19+
static inline bool __must_check arch_get_random_seed_long(unsigned long *v)
2020
{
2121
if (ppc_md.get_random_seed)
2222
return ppc_md.get_random_seed(v);
2323

24-
return 0;
24+
return false;
2525
}
26-
static inline int arch_get_random_seed_int(unsigned int *v)
26+
27+
static inline bool __must_check arch_get_random_seed_int(unsigned int *v)
2728
{
2829
unsigned long val;
29-
int rc;
30+
bool rc;
3031

3132
rc = arch_get_random_seed_long(&val);
3233
if (rc)
3334
*v = val;
3435

3536
return rc;
3637
}
37-
38-
static inline int arch_has_random(void)
39-
{
40-
return 0;
41-
}
42-
43-
static inline int arch_has_random_seed(void)
44-
{
45-
return !!ppc_md.get_random_seed;
46-
}
4738
#endif /* CONFIG_ARCH_RANDOM */
4839

4940
#ifdef CONFIG_PPC_POWERNV

arch/s390/include/asm/archrandom.h

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,25 @@ extern atomic64_t s390_arch_random_counter;
2121

2222
bool s390_arch_random_generate(u8 *buf, unsigned int nbytes);
2323

24-
static inline bool arch_has_random(void)
24+
static inline bool __must_check arch_get_random_long(unsigned long *v)
2525
{
2626
return false;
2727
}
2828

29-
static inline bool arch_has_random_seed(void)
29+
static inline bool __must_check arch_get_random_int(unsigned int *v)
3030
{
31-
if (static_branch_likely(&s390_arch_random_available))
32-
return true;
3331
return false;
3432
}
3533

36-
static inline bool arch_get_random_long(unsigned long *v)
37-
{
38-
return false;
39-
}
40-
41-
static inline bool arch_get_random_int(unsigned int *v)
42-
{
43-
return false;
44-
}
45-
46-
static inline bool arch_get_random_seed_long(unsigned long *v)
34+
static inline bool __must_check arch_get_random_seed_long(unsigned long *v)
4735
{
4836
if (static_branch_likely(&s390_arch_random_available)) {
4937
return s390_arch_random_generate((u8 *)v, sizeof(*v));
5038
}
5139
return false;
5240
}
5341

54-
static inline bool arch_get_random_seed_int(unsigned int *v)
42+
static inline bool __must_check arch_get_random_seed_int(unsigned int *v)
5543
{
5644
if (static_branch_likely(&s390_arch_random_available)) {
5745
return s390_arch_random_generate((u8 *)v, sizeof(*v));

arch/x86/include/asm/archrandom.h

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
/* Unconditional execution of RDRAND and RDSEED */
2929

30-
static inline bool rdrand_long(unsigned long *v)
30+
static inline bool __must_check rdrand_long(unsigned long *v)
3131
{
3232
bool ok;
3333
unsigned int retry = RDRAND_RETRY_LOOPS;
@@ -41,7 +41,7 @@ static inline bool rdrand_long(unsigned long *v)
4141
return false;
4242
}
4343

44-
static inline bool rdrand_int(unsigned int *v)
44+
static inline bool __must_check rdrand_int(unsigned int *v)
4545
{
4646
bool ok;
4747
unsigned int retry = RDRAND_RETRY_LOOPS;
@@ -55,7 +55,7 @@ static inline bool rdrand_int(unsigned int *v)
5555
return false;
5656
}
5757

58-
static inline bool rdseed_long(unsigned long *v)
58+
static inline bool __must_check rdseed_long(unsigned long *v)
5959
{
6060
bool ok;
6161
asm volatile(RDSEED_LONG
@@ -64,7 +64,7 @@ static inline bool rdseed_long(unsigned long *v)
6464
return ok;
6565
}
6666

67-
static inline bool rdseed_int(unsigned int *v)
67+
static inline bool __must_check rdseed_int(unsigned int *v)
6868
{
6969
bool ok;
7070
asm volatile(RDSEED_INT
@@ -73,35 +73,31 @@ static inline bool rdseed_int(unsigned int *v)
7373
return ok;
7474
}
7575

76-
/* Conditional execution based on CPU type */
77-
#define arch_has_random() static_cpu_has(X86_FEATURE_RDRAND)
78-
#define arch_has_random_seed() static_cpu_has(X86_FEATURE_RDSEED)
79-
8076
/*
8177
* These are the generic interfaces; they must not be declared if the
8278
* stubs in <linux/random.h> are to be invoked,
8379
* i.e. CONFIG_ARCH_RANDOM is not defined.
8480
*/
8581
#ifdef CONFIG_ARCH_RANDOM
8682

87-
static inline bool arch_get_random_long(unsigned long *v)
83+
static inline bool __must_check arch_get_random_long(unsigned long *v)
8884
{
89-
return arch_has_random() ? rdrand_long(v) : false;
85+
return static_cpu_has(X86_FEATURE_RDRAND) ? rdrand_long(v) : false;
9086
}
9187

92-
static inline bool arch_get_random_int(unsigned int *v)
88+
static inline bool __must_check arch_get_random_int(unsigned int *v)
9389
{
94-
return arch_has_random() ? rdrand_int(v) : false;
90+
return static_cpu_has(X86_FEATURE_RDRAND) ? rdrand_int(v) : false;
9591
}
9692

97-
static inline bool arch_get_random_seed_long(unsigned long *v)
93+
static inline bool __must_check arch_get_random_seed_long(unsigned long *v)
9894
{
99-
return arch_has_random_seed() ? rdseed_long(v) : false;
95+
return static_cpu_has(X86_FEATURE_RDSEED) ? rdseed_long(v) : false;
10096
}
10197

102-
static inline bool arch_get_random_seed_int(unsigned int *v)
98+
static inline bool __must_check arch_get_random_seed_int(unsigned int *v)
10399
{
104-
return arch_has_random_seed() ? rdseed_int(v) : false;
100+
return static_cpu_has(X86_FEATURE_RDSEED) ? rdseed_int(v) : false;
105101
}
106102

107103
extern void x86_init_rdrand(struct cpuinfo_x86 *c);

0 commit comments

Comments
 (0)