Coverage Report

Created: 2017-10-25 09:10

/root/src/xen/xen/common/random.c
Line
Count
Source (jump to first uncovered line)
1
#include <xen/cache.h>
2
#include <xen/init.h>
3
#include <xen/percpu.h>
4
#include <xen/random.h>
5
#include <xen/time.h>
6
#include <asm/random.h>
7
8
static DEFINE_PER_CPU(unsigned int, seed);
9
unsigned int __read_mostly boot_random;
10
11
unsigned int get_random(void)
12
47
{
13
47
    unsigned int next = this_cpu(seed), val = arch_get_random();
14
47
15
47
    if ( unlikely(!next) )
16
4
        next = val ?: NOW();
17
47
18
47
    if ( !val )
19
0
    {
20
0
        unsigned int i;
21
0
22
0
        for ( i = 0; i < sizeof(val) * 8; i += 11 )
23
0
        {
24
0
            next = next * 1103515245 + 12345;
25
0
            val |= ((next >> 16) & 0x7ff) << i;
26
0
        }
27
0
    }
28
47
29
47
    this_cpu(seed) = next;
30
47
31
47
    return val;
32
47
}
33
34
static int __init init_boot_random(void)
35
1
{
36
1
    boot_random = get_random();
37
1
    return 0;
38
1
}
39
__initcall(init_boot_random);