summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-01-06 15:02:00 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-06 15:02:00 -0800
commit7a222156bcf010dbf77fe7d803c375bcc4a51160 (patch)
tree2689bf892bd9de873ac3887fbd6ff59bb811da38
parent2c364faabb8ef400e4632bb989287bcd7c0a9148 (diff)
parentcf833d0b9937874b50ef2867c4e8badfd64948ce (diff)
Merge branch 'x86-rdrand-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
* 'x86-rdrand-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: random: Use arch_get_random_int instead of cycle counter if avail
-rw-r--r--drivers/char/random.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 6035ab8d5ef7..85da8740586b 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -624,8 +624,8 @@ static struct timer_rand_state input_timer_state;
static void add_timer_randomness(struct timer_rand_state *state, unsigned num)
{
struct {
- cycles_t cycles;
long jiffies;
+ unsigned cycles;
unsigned num;
} sample;
long delta, delta2, delta3;
@@ -637,7 +637,11 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num)
goto out;
sample.jiffies = jiffies;
- sample.cycles = get_cycles();
+
+ /* Use arch random value, fall back to cycles */
+ if (!arch_get_random_int(&sample.cycles))
+ sample.cycles = get_cycles();
+
sample.num = num;
mix_pool_bytes(&input_pool, &sample, sizeof(sample));