linux/drivers/char/hw_random
Peter Korsgaard 121daad8fd hwrng: atmel-rng - fix race condition leading to repeated bits
Data valid gets cleared by reading the ISR (status register) and NOT from
reading ODATA (data register). A new data word can become available between
checking ISR and reading ODATA, causing us to reuse the same data word next
time atmel_trng_read() gets called, if that happens before the following
data word is ready.

With this fixed, rngtest no longer complains of 'Continous run' errors.
Before:

rngtest -c 1000 < /dev/hwrng
rngtest 3
Copyright (c) 2004 by Henrique de Moraes Holschuh
This is free software; see the source for copying conditions.  There is NO warr.

rngtest: starting FIPS tests...
rngtest: bits received from input: 20000032
rngtest: FIPS 140-2 successes: 923
rngtest: FIPS 140-2 failures: 77
rngtest: FIPS 140-2(2001-10-10) Monobit: 0
rngtest: FIPS 140-2(2001-10-10) Poker: 0
rngtest: FIPS 140-2(2001-10-10) Runs: 1
rngtest: FIPS 140-2(2001-10-10) Long run: 0
rngtest: FIPS 140-2(2001-10-10) Continuous run: 76
rngtest: input channel speed: (min=721.402; avg=46003.510; max=49321.338)Kibitss
rngtest: FIPS tests speed: (min=11.442; avg=12.714; max=12.801)Mibits/s
rngtest: Program run time: 1931860 microseconds

After:

rngtest -c 1000 < /dev/hwrng
rngtest 3
Copyright (c) 2004 by Henrique de Moraes Holschuh
This is free software; see the source for copying conditions.  There is NO warr.

rngtest: starting FIPS tests...
rngtest: bits received from input: 20000032
rngtest: FIPS 140-2 successes: 1000
rngtest: FIPS 140-2 failures: 0
rngtest: FIPS 140-2(2001-10-10) Monobit: 0
rngtest: FIPS 140-2(2001-10-10) Poker: 0
rngtest: FIPS 140-2(2001-10-10) Runs: 0
rngtest: FIPS 140-2(2001-10-10) Long run: 0
rngtest: FIPS 140-2(2001-10-10) Continuous run: 0
rngtest: input channel speed: (min=777.518; avg=36988.482; max=43115.342)Kibitss
rngtest: FIPS tests speed: (min=11.951; avg=12.715; max=12.887)Mibits/s
rngtest: Program run time: 2035543 microseconds

Cc: stable@vger.kernel.org
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Reported-by: George Pontis <GPontis@z9.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2012-05-31 20:53:08 +10:00
..
Kconfig hwrng: Kconfig - modify default state for atmel-rng driver 2012-04-30 20:00:35 +10:00
Makefile hw_random: add driver for atmel true hardware random number generator 2011-10-10 12:42:49 +02:00
amd-rng.c hwrng: amd - manage resource allocation 2011-05-04 15:13:15 +10:00
atmel-rng.c hwrng: atmel-rng - fix race condition leading to repeated bits 2012-05-31 20:53:08 +10:00
core.c Update my e-mail address 2011-07-07 15:18:01 +02:00
geode-rng.c hwrng: Use PCI_VDEVICE 2009-06-25 13:50:53 +08:00
intel-rng.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
ixp4xx-rng.c [ARM] Move include/asm-arm/arch-* to arch/arm/*/include/mach 2008-08-07 09:55:48 +01:00
mxc-rnga.c i.MX31: Add hw-random for RNGA 2009-05-07 16:17:16 +02:00
n2-asm.S sparc64: Add Niagara2 RNG driver. 2008-07-18 00:46:09 -07:00
n2-drv.c char: hw_random: convert drivers/char/hw_random/* to use module_platform_driver() 2011-11-30 16:12:47 +08:00
n2rng.h n2rng: Attach on Niagara-T3. 2011-07-28 01:26:30 -07:00
nomadik-rng.c ARM: 7362/1: AMBA: Add module_amba_driver() helper macro for amba_driver 2012-03-16 23:32:35 +00:00
octeon-rng.c char: hw_random: convert drivers/char/hw_random/* to use module_platform_driver() 2011-11-30 16:12:47 +08:00
omap-rng.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux 2012-05-15 17:21:26 +10:00
pasemi-rng.c char: hw_random: convert drivers/char/hw_random/* to use module_platform_driver() 2011-11-30 16:12:47 +08:00
picoxcell-rng.c char: hw_random: convert drivers/char/hw_random/* to use module_platform_driver() 2011-11-30 16:12:47 +08:00
ppc4xx-rng.c char: hw_random: convert drivers/char/hw_random/* to use module_platform_driver() 2011-11-30 16:12:47 +08:00
timeriomem-rng.c char: hw_random: convert drivers/char/hw_random/* to use module_platform_driver() 2011-11-30 16:12:47 +08:00
tx4939-rng.c hwrng: tx4939 - use devm_request_and_ioremap 2012-01-13 16:38:40 +11:00
via-rng.c hwrng: via_rng - Fix memory scribbling on some CPUs 2011-01-07 14:55:06 +11:00
virtio-rng.c virtio: rename virtqueue_add_buf_gfp to virtqueue_add_buf 2012-01-12 15:44:42 +10:30