Skip to content

Commit

Permalink
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/gi…
Browse files Browse the repository at this point in the history
…t/crng/random.git
  • Loading branch information
Mark Brown committed Feb 23, 2022
2 parents 9b45d9a + 7afcebf commit a911f73
Show file tree
Hide file tree
Showing 9 changed files with 1,242 additions and 1,948 deletions.
16 changes: 5 additions & 11 deletions Documentation/admin-guide/sysctl/kernel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -985,23 +985,17 @@ This is a directory, with the following entries:
* ``poolsize``: the entropy pool size, in bits;

* ``urandom_min_reseed_secs``: obsolete (used to determine the minimum
number of seconds between urandom pool reseeding).
number of seconds between urandom pool reseeding). This file is
writable for compatibility purposes, but writing to it has no effect
on any RNG behavior.

* ``uuid``: a UUID generated every time this is retrieved (this can
thus be used to generate UUIDs at will);

* ``write_wakeup_threshold``: when the entropy count drops below this
(as a number of bits), processes waiting to write to ``/dev/random``
are woken up.

If ``drivers/char/random.c`` is built with ``ADD_INTERRUPT_BENCH``
defined, these additional entries are present:

* ``add_interrupt_avg_cycles``: the average number of cycles between
interrupts used to feed the pool;

* ``add_interrupt_avg_deviation``: the standard deviation seen on the
number of cycles between interrupts used to feed the pool.
are woken up. This file is writable for compatibility purposes, but
writing to it has no effect on any RNG behavior.


randomize_va_space
Expand Down
1 change: 1 addition & 0 deletions drivers/char/hw_random/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <linux/err.h>
#include <linux/fs.h>
#include <linux/hw_random.h>
#include <linux/random.h>
#include <linux/kernel.h>
#include <linux/kthread.h>
#include <linux/sched/signal.h>
Expand Down
2,900 changes: 1,210 additions & 1,690 deletions drivers/char/random.c

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions include/linux/cpuhotplug.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ enum cpuhp_state {
CPUHP_AP_ARM_CACHE_B15_RAC_DEAD,
CPUHP_PADATA_DEAD,
CPUHP_AP_DTPM_CPU_DEAD,
CPUHP_RANDOM_PREPARE,
CPUHP_WORKQUEUE_PREP,
CPUHP_POWER_NUMA_PREPARE,
CPUHP_HRTIMERS_PREPARE,
Expand Down Expand Up @@ -240,6 +241,7 @@ enum cpuhp_state {
CPUHP_AP_PERF_CSKY_ONLINE,
CPUHP_AP_WATCHDOG_ONLINE,
CPUHP_AP_WORKQUEUE_ONLINE,
CPUHP_AP_RANDOM_ONLINE,
CPUHP_AP_RCUTREE_ONLINE,
CPUHP_AP_BASE_CACHEINFO_ONLINE,
CPUHP_AP_ONLINE_DYN,
Expand Down
2 changes: 0 additions & 2 deletions include/linux/hw_random.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,5 @@ extern int devm_hwrng_register(struct device *dev, struct hwrng *rng);
/** Unregister a Hardware Random Number Generator driver. */
extern void hwrng_unregister(struct hwrng *rng);
extern void devm_hwrng_unregister(struct device *dve, struct hwrng *rng);
/** Feed random bits into the pool. */
extern void add_hwgenerator_randomness(const char *buffer, size_t count, size_t entropy);

#endif /* LINUX_HWRANDOM_H_ */
23 changes: 13 additions & 10 deletions include/linux/random.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* include/linux/random.h
*
* Include file for the random number generator.
*/

#ifndef _LINUX_RANDOM_H
#define _LINUX_RANDOM_H

Expand All @@ -20,8 +16,8 @@ struct random_ready_callback {
struct module *owner;
};

extern void add_device_randomness(const void *, unsigned int);
extern void add_bootloader_randomness(const void *, unsigned int);
extern void add_device_randomness(const void *, size_t);
extern void add_bootloader_randomness(const void *, size_t);

#if defined(LATENT_ENTROPY_PLUGIN) && !defined(__CHECKER__)
static inline void add_latent_entropy(void)
Expand All @@ -36,14 +32,16 @@ static inline void add_latent_entropy(void) {}
extern void add_input_randomness(unsigned int type, unsigned int code,
unsigned int value) __latent_entropy;
extern void add_interrupt_randomness(int irq) __latent_entropy;
extern void add_hwgenerator_randomness(const void *buffer, size_t count,
size_t entropy);

extern void get_random_bytes(void *buf, int nbytes);
extern void get_random_bytes(void *buf, size_t nbytes);
extern int wait_for_random_bytes(void);
extern int __init rand_initialize(void);
extern bool rng_is_initialized(void);
extern int add_random_ready_callback(struct random_ready_callback *rdy);
extern void del_random_ready_callback(struct random_ready_callback *rdy);
extern int __must_check get_random_bytes_arch(void *buf, int nbytes);
extern size_t __must_check get_random_bytes_arch(void *buf, size_t nbytes);

#ifndef MODULE
extern const struct file_operations random_fops, urandom_fops;
Expand Down Expand Up @@ -87,7 +85,7 @@ static inline unsigned long get_random_canary(void)

/* Calls wait_for_random_bytes() and then calls get_random_bytes(buf, nbytes).
* Returns the result of the call to wait_for_random_bytes. */
static inline int get_random_bytes_wait(void *buf, int nbytes)
static inline int get_random_bytes_wait(void *buf, size_t nbytes)
{
int ret = wait_for_random_bytes();
get_random_bytes(buf, nbytes);
Expand Down Expand Up @@ -158,4 +156,9 @@ static inline bool __init arch_get_random_long_early(unsigned long *v)
}
#endif

#ifdef CONFIG_SMP
extern int random_prepare_cpu(unsigned int cpu);
extern int random_online_cpu(unsigned int cpu);
#endif

#endif /* _LINUX_RANDOM_H */
233 changes: 0 additions & 233 deletions include/trace/events/random.h

This file was deleted.

11 changes: 11 additions & 0 deletions kernel/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <linux/scs.h>
#include <linux/percpu-rwsem.h>
#include <linux/cpuset.h>
#include <linux/random.h>

#include <trace/events/power.h>
#define CREATE_TRACE_POINTS
Expand Down Expand Up @@ -1659,6 +1660,11 @@ static struct cpuhp_step cpuhp_hp_states[] = {
.startup.single = perf_event_init_cpu,
.teardown.single = perf_event_exit_cpu,
},
[CPUHP_RANDOM_PREPARE] = {
.name = "random:prepare",
.startup.single = random_prepare_cpu,
.teardown.single = NULL,
},
[CPUHP_WORKQUEUE_PREP] = {
.name = "workqueue:prepare",
.startup.single = workqueue_prepare_cpu,
Expand Down Expand Up @@ -1782,6 +1788,11 @@ static struct cpuhp_step cpuhp_hp_states[] = {
.startup.single = workqueue_online_cpu,
.teardown.single = workqueue_offline_cpu,
},
[CPUHP_AP_RANDOM_ONLINE] = {
.name = "random:online",
.startup.single = random_online_cpu,
.teardown.single = NULL,
},
[CPUHP_AP_RCUTREE_ONLINE] = {
.name = "RCU/tree:online",
.startup.single = rcutree_online_cpu,
Expand Down
Loading

0 comments on commit a911f73

Please sign in to comment.