]> Pileus Git - ~andy/linux/blobdiff - drivers/char/random.c
Merge branch 'akpm' (Andrew's patch-bomb)
[~andy/linux] / drivers / char / random.c
index 6035ab8d5ef7e25e6eae89fbfdc53476f248de8b..54ca8b23cde3f1aa5550d2806087300227531070 100644 (file)
@@ -387,7 +387,7 @@ static DECLARE_WAIT_QUEUE_HEAD(random_write_wait);
 static struct fasync_struct *fasync;
 
 #if 0
-static int debug;
+static bool debug;
 module_param(debug, bool, 0644);
 #define DEBUG_ENT(fmt, arg...) do { \
        if (debug) \
@@ -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));
 
@@ -961,6 +965,7 @@ EXPORT_SYMBOL(get_random_bytes);
  */
 static void init_std_data(struct entropy_store *r)
 {
+       int i;
        ktime_t now;
        unsigned long flags;
 
@@ -970,6 +975,11 @@ static void init_std_data(struct entropy_store *r)
 
        now = ktime_get_real();
        mix_pool_bytes(r, &now, sizeof(now));
+       for (i = r->poolinfo->POOLBYTES; i > 0; i -= sizeof flags) {
+               if (!arch_get_random_long(&flags))
+                       break;
+               mix_pool_bytes(r, &flags, sizeof(flags));
+       }
        mix_pool_bytes(r, utsname(), sizeof(*(utsname())));
 }