[Cerowrt-devel] getting more randomness by improving MIPS get_cycles()

Stephen Hemminger stephen at networkplumber.org
Mon Sep 9 11:16:45 EDT 2013


On Sun, 8 Sep 2013 12:04:27 -0700
Dave Taht <dave.taht at bufferbloat.net> wrote:

> In light of the whole nsa hoo-ra (stuff like this)
> 
> https://plus.google.com/u/0/117091380454742934025/posts/SDcoemc9V3J
> 
> Ted Tso has pointed out to me that apparently mips' does not have a working 
> generic get_cycles() call,  but instead returns 0 in all cases.
> 
> e.g: In arch/mips/include/asm/timex.h:
> 
> typedef unsigned int cycles_t;
> 
> static inline cycles_t get_cycles(void)
> {
>         return 0;
> }
> 
> Um.....
> 
> get_cycles() is used in innumerable places in random.c.
> 
> This is double plus ungood... I am REALLY hoping I'm merely misreading 
> the code...
> 
> An example:
> 
> (see drivers/char/random.c for how often it is used)
> 
> /*
>  * Add device- or boot-specific data to the input and nonblocking
>  * pools to help initialize them to unique values.
>  *
>  * None of this adds any entropy, it is meant to avoid the
>  * problem of the nonblocking pool having similar initial state
>  * across largely identical devices.
>  */
> 
> void add_device_randomness(const void *buf, unsigned int size)
> {
>         unsigned long time = get_cycles() ^ jiffies;
> 
> ...
> 
> So, what blocks having a working get_cycles in common mips architectures?

In order to implement get_cycles() a high resolution hardware counter
with quick access is necessary.





More information about the Cerowrt-devel mailing list