]> rtime.felk.cvut.cz Git - zynq/linux.git/blobdiff - drivers/char/random.c
Apply preempt_rt patch-4.9-rt1.patch.xz
[zynq/linux.git] / drivers / char / random.c
index d131e152c8ce6a3e70a7e0fe287275269f0c40c6..0c60b1e54579e0470654760c400dc271137c1035 100644 (file)
@@ -479,8 +479,8 @@ static ssize_t _extract_entropy(struct entropy_store *r, void *buf,
 
 static void crng_reseed(struct crng_state *crng, struct entropy_store *r);
 static void push_to_pool(struct work_struct *work);
-static __u32 input_pool_data[INPUT_POOL_WORDS];
-static __u32 blocking_pool_data[OUTPUT_POOL_WORDS];
+static __u32 input_pool_data[INPUT_POOL_WORDS] __latent_entropy;
+static __u32 blocking_pool_data[OUTPUT_POOL_WORDS] __latent_entropy;
 
 static struct entropy_store input_pool = {
        .poolinfo = &poolinfo_table[0],
@@ -1028,8 +1028,6 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num)
        } sample;
        long delta, delta2, delta3;
 
-       preempt_disable();
-
        sample.jiffies = jiffies;
        sample.cycles = random_get_entropy();
        sample.num = num;
@@ -1070,7 +1068,6 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num)
                 */
                credit_entropy_bits(r, min_t(int, fls(delta>>1), 11));
        }
-       preempt_enable();
 }
 
 void add_input_randomness(unsigned int type, unsigned int code,
@@ -1123,28 +1120,27 @@ static __u32 get_reg(struct fast_pool *f, struct pt_regs *regs)
        return *(ptr + f->reg_idx++);
 }
 
-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 = this_cpu_ptr(&irq_randomness);
-       struct pt_regs          *regs = get_irq_regs();
        unsigned long           now = jiffies;
        cycles_t                cycles = random_get_entropy();
        __u32                   c_high, j_high;
-       __u64                   ip;
        unsigned long           seed;
        int                     credit = 0;
 
        if (cycles == 0)
-               cycles = get_reg(fast_pool, regs);
+               cycles = get_reg(fast_pool, NULL);
        c_high = (sizeof(cycles) > 4) ? cycles >> 32 : 0;
        j_high = (sizeof(now) > 4) ? now >> 32 : 0;
        fast_pool->pool[0] ^= cycles ^ j_high ^ irq;
        fast_pool->pool[1] ^= now ^ c_high;
-       ip = regs ? instruction_pointer(regs) : _RET_IP_;
+       if (!ip)
+               ip = _RET_IP_;
        fast_pool->pool[2] ^= ip;
        fast_pool->pool[3] ^= (sizeof(ip) > 4) ? ip >> 32 :
-               get_reg(fast_pool, regs);
+               get_reg(fast_pool, NULL);
 
        fast_mix(fast_pool);
        add_interrupt_bench(cycles);