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 ;-).
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;
This is basically the same issue than the following one:
https://lists.linux-foundation.org/pipermail/virtualization/2008-May/010946.html
but introduced in a more subtle way in this commit:
commit bb347d98079a547e80bd4722dee1de61e4dca0e8
Author: Ian Molton <[email protected]>
Date: Tue Dec 1 15:26:33 2009 +0800
hwrng: virtio-rng - Convert to new API
This patch converts virtio-rng to the new hw_rng API.
In the process it fixes a previously untriggered buffering bug where the
buffer is not drained correctly if it has a non-multiple-of-4 length.
Performance has improved under qemu-kvm testing also.
Signed-off-by: Ian Molton <[email protected]>
Acked-by: Matt Mackall <[email protected]>
Acked-by: Rusty Russell <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
I basically see three possible way of fixing that:
- prevent rng_core to be built as a module;
- use an intermediary kmalloced buffer in virtio-rng passed to virtio
functions, followed by a memcpy to get the data in the rng core
buffer;
- use a kmalloc buffer in rng_core instead of vmalloc one.
What would be best way to fix that? Did I miss another way?
Thanks,
Aurelien
--
Aurelien Jarno GPG: 1024D/F1BCDB73
[email protected] http://www.aurel32.net
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html