From: Aurelien Jarno <aurelien@aurel32.net>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: kvm@vger.kernel.org, Ian Molton <ian.molton@collabora.co.uk>,
Matt Mackall <mpm@selenic.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
Ben Hutchings <ben@decadent.org.uk>, Jens Axboe <axboe@kernel.dk>
Subject: Re: virtio-rng only returns zeros with CONFIG_HW_RANDOM=m
Date: Wed, 27 Feb 2013 11:33:36 +0100 [thread overview]
Message-ID: <20130227103336.GA16559@ohm.aurel32.net> (raw)
In-Reply-To: <8738wifwb2.fsf@rustcorp.com.au>
On Wed, Feb 27, 2013 at 10:43:37AM +1030, Rusty Russell wrote:
> Aurelien Jarno <aurelien@aurel32.net> writes:
> > Hi,
> >
> > I have noticed that virtio-rng only returns zero for kernels >= 2.6.33
> > built with CONFIG_HW_RANDOM=m. This is a bit much too predictable for a
> > random generator ;-).
>
> Wow. Fortunately, all of SLES, RHEL, Ubuntu or Fedora set
> CONFIG_HW_RANDOM=y. What do they know that we don't?
>
> Oops, looks like Debian testing: config-3.2.0-4-amd64:CONFIG_HW_RANDOM=m
>
> > The reason for that is virtio expects guest real addresses, while
> > rng_core.ko (ie when built as a module) is passing a vmalloced buffer
> > to the virtio-rng read function, declared as such:
> >
> > static u8 rng_buffer[SMP_CACHE_BYTES < 32 ? 32 : SMP_CACHE_BYTES]
> > __cacheline_aligned;
>
> Yuck... It would be nice if this has oopsed. Jens, what about this patch?
>
> Cheers,
> Rusty.
>
> Subject: scatterlist: sg_set_buf() argument must be in linear mapping.
>
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
>
> diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
> index 4bd6c06..9365375 100644
> --- a/include/linux/scatterlist.h
> +++ b/include/linux/scatterlist.h
> @@ -111,6 +111,9 @@ static inline struct page *sg_page(struct scatterlist *sg)
> static inline void sg_set_buf(struct scatterlist *sg, const void *buf,
> unsigned int buflen)
> {
> +#ifdef CONFIG_DEBUG_SG
> + BUG_ON(!virt_addr_valid(buf));
> +#endif
> sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf));
> }
>
I confirm this patch catches the issue. Thanks.
Tested-by: Aurelien Jarno <aurelien@aurel32.net>
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
next prev parent reply other threads:[~2013-02-27 10:33 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-24 23:11 virtio-rng only returns zeros with CONFIG_HW_RANDOM=m Aurelien Jarno
2013-02-27 0:13 ` Rusty Russell
2013-02-27 3:40 ` Ben Hutchings
2013-02-27 10:33 ` Aurelien Jarno [this message]
2013-02-27 13:22 ` Jens Axboe
2013-02-28 3:00 ` Rusty Russell
2013-05-30 1:07 ` Rusty Russell
2013-05-30 7:18 ` Jens Axboe
2013-02-27 1:26 ` Rusty Russell
2013-02-27 16:36 ` Aurelien Jarno
2013-02-28 3:04 ` Rusty Russell
2013-03-10 8:26 ` Herbert Xu
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=20130227103336.GA16559@ohm.aurel32.net \
--to=aurelien@aurel32.net \
--cc=axboe@kernel.dk \
--cc=ben@decadent.org.uk \
--cc=herbert@gondor.apana.org.au \
--cc=ian.molton@collabora.co.uk \
--cc=kvm@vger.kernel.org \
--cc=mpm@selenic.com \
--cc=rusty@rustcorp.com.au \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox