Re: hw_random fixes

From: Matt Mackall
Date: Wed Nov 25 2009 - 14:28:05 EST


[cc:ing to linux-kernel, finally]

On Wed, 2009-11-25 at 10:16 +0000, Ian Molton wrote:
> Rusty Russell wrote:
>
> > Make that:
> >
> > ssize_t (*get_rng_data)(void *buf, size_t max, bool wait);
> >
> > Then, if driver supplies that hook, use it exclusively. Otherwise, use old
> > ones. We can convert them gradually that way.
>
> This doesn't quite solve things neatly, because it means one of:
>
> 1) The core has to wait until there is nothing left before requesting
> more data, because it doesnt know the alignment requirements of the driver.

Hmm, this seems to imply you'd be calling get_rng_data multiple times
with different offsets into buf to accumulate data. I think that's more
complex than is needed. Just use buf as a nicely aligned scratch buffer
and empty it completely into the final output buffer before the next
driver request. If you end up with 1 byte of data hanging around until
the next read, that's not a problem - the next read might be 5 bytes.

You'll probably want to use cacheline alignment on buf to make Via
Padlock happy, if anything needs larger alignment (ie page) it should
handle it internally.

--
http://selenic.com : development and support for Mercurial and Linux


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/