diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2012-08-21 20:38:50 +0200 |
---|---|---|
committer | Anders Roxell <anders.roxell@linaro.org> | 2015-06-01 12:03:21 +0200 |
commit | f0d2a5a81c15af47f8b30d41776efe0a5128e825 (patch) | |
tree | 34737c088a80f5658f93e09a68e502ab4a34f6b2 /drivers | |
parent | 398a613f640804afbab2e086edae5df95aa52295 (diff) |
random: Make it work on rt
Delegate the random insertion to the forced threaded interrupt
handler. Store the return IP of the hard interrupt handler in the irq
descriptor and feed it into the random generator as a source of
entropy.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable-rt@vger.kernel.org
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/char/random.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index fb7c0570d461..a8c067286de7 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -832,21 +832,20 @@ EXPORT_SYMBOL_GPL(add_input_randomness); static DEFINE_PER_CPU(struct fast_pool, irq_randomness); -void add_interrupt_randomness(int irq, int irq_flags) +void add_interrupt_randomness(int irq, int irq_flags, __u64 ip) { struct entropy_store *r; struct fast_pool *fast_pool = &__get_cpu_var(irq_randomness); - struct pt_regs *regs = get_irq_regs(); unsigned long now = jiffies; cycles_t cycles = random_get_entropy(); __u32 input[4], c_high, j_high; - __u64 ip; c_high = (sizeof(cycles) > 4) ? cycles >> 32 : 0; j_high = (sizeof(now) > 4) ? now >> 32 : 0; input[0] = cycles ^ j_high ^ irq; input[1] = now ^ c_high; - ip = regs ? instruction_pointer(regs) : _RET_IP_; + if (!ip) + ip = _RET_IP_; input[2] = ip; input[3] = ip >> 32; @@ -858,7 +857,11 @@ void add_interrupt_randomness(int irq, int irq_flags) fast_pool->last = now; r = nonblocking_pool.initialized ? &input_pool : &nonblocking_pool; +#ifndef CONFIG_PREEMPT_RT_FULL __mix_pool_bytes(r, &fast_pool->pool, sizeof(fast_pool->pool), NULL); +#else + mix_pool_bytes(r, &fast_pool->pool, sizeof(fast_pool->pool), NULL); +#endif /* * If we don't have a valid cycle counter, and we see * back-to-back timer interrupts, then skip giving credit for |