All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Stodden <daniel.stodden@citrix.com>
To: "michele.paolino" <michele.paolino@studio.unibo.it>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>,
	"Xen-devel@lists.xensource.com" <Xen-devel@lists.xensource.com>,
	James Harper <james.harper@bendigoit.com.au>
Subject: Re: generate random numbers
Date: Fri, 12 Feb 2010 15:12:50 -0800	[thread overview]
Message-ID: <1266016370.15135.2942.camel@agari.van.xensource.com> (raw)
In-Reply-To: <14f366f91002121442h536a2d03if7d9bdee416a4a23@mail.gmail.com>

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@eu.citrix.com> 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@studio.unibo.it> 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@bendigoit.com.au> 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@lists.xensource.com
>         > http://lists.xensource.com/xen-devel
>         >
>         >
>         
> 

  reply	other threads:[~2010-02-12 23:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-11 20:31 generate random numbers michele.paolino
2010-02-12  1:51 ` James Harper
2010-02-12  8:32   ` michele.paolino
2010-02-12 12:15     ` George Dunlap
2010-02-12 22:42       ` michele.paolino
2010-02-12 23:12         ` Daniel Stodden [this message]
2010-02-25 18:31           ` michele.paolino
2010-02-25 21:25             ` George Dunlap
2010-02-26 17:43               ` michele.paolino
2010-02-26 17:44                 ` George Dunlap
2010-02-26 18:54                   ` michele.paolino
2010-03-01 11:41                     ` George Dunlap
2010-03-01 16:56                       ` michele.paolino
2010-03-02 12:58                         ` George Dunlap
2010-03-03  7:52                           ` michele.paolino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1266016370.15135.2942.camel@agari.van.xensource.com \
    --to=daniel.stodden@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=Xen-devel@lists.xensource.com \
    --cc=james.harper@bendigoit.com.au \
    --cc=michele.paolino@studio.unibo.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.