Subject: Re: new MI/MD interface for rnd(4)
To: None <tech-kern@netbsd.org>
From: Colin Wood <cwood@ichips.intel.com>
List: tech-ports
Date: 06/05/2000 17:50:12
Bill Sommerfeld wrote:
> I just committed changes to the i386 port and to the /dev/random
> driver (sys/dev/rnd.c) to let it use a higher-resolution cycle counter
> in the timestamps it uses for randomness collection.
> 
> Here's a slight rephrasing of the commit message:
> 
> If __HAVE_CPU_TIMESTAMP is defined (currently in <machine/types.h>,
> which is a dumping ground for similar options), <machine/rnd.h> exists
> and defines two functions:
>   1)    u_int32_t cpu_timestamp(void);
> returns the 32 low order bits of a reasonably high frequency counter.
>   2)    int cpu_havetimestamp(void);
> returns non-zero if cpu_timestamp() actually works.
> 
> The timestamp counter should run at a frequency greater than 1 MHz
> (otherwise, microtime would be sufficient); other than that, the exact
> frequency and origin of the counter are unspecified.
> 
> Let me know you have any comments/questions on this (extremely
> trivial) optional additional interface.  I suspect that other ports
> should be able to use this interface pretty easily.

Is a 32-bit number big enough?  On a sufficiently fast IA32 processor,
that counter (assuming you're using the timestamp counter) can overflow
within a relatively short period of time (4s on currently shipping
processors).  It is forseeable that it could overflow in less than a
second on processors shipping within the next few years. I don't know
enough about how often rnd.c samples, tho, so this might not be a
problem...

-Colin



-- 
Colin Wood                                 cwood@ichips.intel.com
Component Design Engineer - DPG                 Intel Corporation
-----------------------------------------------------------------
I speak only on my own behalf, not for my employer.