WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] generate random numbers

On Fri, 2010-02-12 at 17:42 -0500, michele.paolino wrote:
> Ok, thanks! this is enought to get started. 
> but how can I read a random number from /dev/urandom? 

open(), read().
Just try a cat | hexdump on the cli, it's really that simple.

> is Xend the deamon that you talk me about?

I think George was rather suggesting a standalone daemon. It would be
better done just writing a background task in dom0. 

Establish a ring buffer on a page shared with xen. Xen consumes bits
from the buffer and advances a consumer pointer. Your daemon reads bits
from /dev/urandom and forwards them to the ring, advancing a producer
pointer. 

A lot of communications in Xen is shared memory in the exact same
fashion. Copy xen/include/public/io/console.h and study some of the
pointer offset and barrier stuff in ring.h.

If you're stuck, see related code for samples, about any PV driver deals
with this kind of interface, the console code probably being the most
simple one.

Advanced flow control: You will come across event channels anyway. But
for the bandwith you're indicating, you will most likely find polling
works okay.

It's just about the ideal project to get started with basic Xen hacking.

Daniel 


> Thanks
> Michele
> 
> 
> On Fri, Feb 12, 2010 at 1:15 PM, George Dunlap
> <George.Dunlap@xxxxxxxxxxxxx> wrote:
>         I think the short answer is, Xen does not have a mechanism to
>         collect
>         true randomness at the moment.  I'm not an expert in random
>         numbers,
>         so the bitrate doesn't mean anything to me.  A couple of
>         possible
>         solutions come to mind:
>         * Use pseudo-random numbers to start out with and test your
>         theories,
>         while working on getting truly random numbers in.
>         * Punt the problem to dom0: Have a daemon in dom0 to
>         read /dev/urandom
>         and "upload" values into a ring read by Xen.  If the ring is
>         empty,
>         use pseudo-random numbers seeded by old values in the ring
>         (?).
>         * Add entropy-collection to Xen.
>         * If interrupted by a timer that's longer than 1ms, just take
>         a TSC
>         and lop off the lower 10 bits.  If you haven't been
>         interrupted by a
>         timer, use pseudorandom numbers seeded by the lower 10 bits of
>         the
>         last TSC.
>         
>         As I said, I'm not an expert in collecting entropy, so some of
>         these
>         may be obviously brain-dead ideas.  But it might give you
>         enough to
>         get started.
>         
>          -George
>         
>         
>         On Fri, Feb 12, 2010 at 8:32 AM, michele.paolino
>         <michele.paolino@xxxxxxxxxxxxxxx> wrote:
>         > I need less than 10 bits at rate of 10 milliseconds. With a
>         random number I
>         > will select the next VCPU to schedule.
>         >
>         > Michele
>         >
>         > On Fri, Feb 12, 2010 at 2:51 AM, James Harper
>         > <james.harper@xxxxxxxxxxxxxxxx> wrote:
>         >>
>         >> >
>         >> > Hi!
>         >> > I am interested in writing a scheduler for Xen for
>         academic purposes.
>         >> I need
>         >> > to generate random numbers.
>         >> > Is it possible to generate random numbers in xen
>         hypervisor
>         >> developement?If
>         >> > this is possible, how can I do it?
>         >> >
>         >>
>         >> How many bits do you random numbers need to be?
>         >>
>         >> At what rate do you need them? (10/second?,
>         1000000/second?)
>         >>
>         >> Would pseudo-random numbers do? If so, what repeat interval
>         is
>         >> sufficient?
>         >>
>         >> James
>         >
>         >
>         
>         
>         > _______________________________________________
>         > Xen-devel mailing list
>         > Xen-devel@xxxxxxxxxxxxxxxxxxx
>         > http://lists.xensource.com/xen-devel
>         >
>         >
>         
> 



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel