Skip to content

: RNG support v2

Patrick McHardy linux-crypto lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 7 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3: move status polling loop to data_present callbacksdrivers/char/hw_random/amd-rng.c drivers/char/hw_random/core.c drivers/char/hw_random/geode-rng.c +5 more+73 -380 replies
2/3: Improve PLL initializationdrivers/crypto/hifn_795x.c+108 -20 replies
3/3: Add support for using the random number generatordrivers/crypto/hifn_795x.c+81 -10 replies

Reviews trailers per patch

None of the 3 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchMichael Buesch
SeriesA-b
1/3
2/3
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [HIFN 00/03]: RNG support v2

These patches add support for using the HIFN rng.

The first patch changes the hwrng API to move waiting for availability of new random into the drivers. This allows to use driver-specific delays instead of the constant 10us delay used previously, increasing the HIFN speed from 2.5mbit to almost 15mbit, which is nearly the theoretical maximum.

The second patch improves the PLL initialization by making the reference clock configurable and its speed known to the driver, which is needed to calculate the amount of time to wait between two RNG reads. Since there is no way to find out the frequency reliably (especially for the external clock), it adds some sane looking defaults and a module parameter to override it. It also changes the PLL initialization to follow the procedure described in the HIFN documentation.

The third patch adds hw_random support. To use the rng, the HW_RANDOM config option has to be enabled.

Running rngtest on the random number generator indicates that it works properly, with an average failure ratio of about 1:1000 at ~15mbit:

rngtest: bits received from input: 3155000032
rngtest: FIPS 140-2 successes: 157621
rngtest: FIPS 140-2 failures: 129
rngtest: FIPS 140-2(2001-10-10) Monobit: 20
rngtest: FIPS 140-2(2001-10-10) Poker: 13
rngtest: FIPS 140-2(2001-10-10) Runs: 54
rngtest: FIPS 140-2(2001-10-10) Long run: 43
rngtest: FIPS 140-2(2001-10-10) Continuous run: 0
rngtest: input channel speed: (min=441.005; avg=14730.378; max=21510.187)Kibits/s
rngtest: FIPS tests speed: (min=1.228; avg=55.967; max=62.742)Mibits/s
rngtest: Program run time: 263373905 microseconds

Changes this last posting:

- follow PLL initialization procedure as described in the documentation
- allow to specify clock source without a frequency
- rename pll_ref module parameter to hifn_pll_ref
- discard first rng value after initialization as suggested by the documentation
- use ktime instead of get_cycles for delaying rng reads
- adapt to the hwrng API changes
- fix cleanup in initialization error path

Michael, if you're OK with the RNG changes, I'd suggest that all three patches go through Herbert since the HIFN patches depend on that part.

 drivers/char/hw_random/amd-rng.c    |   12 ++-
 drivers/char/hw_random/core.c       |   24 +----
 drivers/char/hw_random/geode-rng.c  |   12 ++-
 drivers/char/hw_random/intel-rng.c  |   15 ++-
 drivers/char/hw_random/omap-rng.c   |   13 ++-
 drivers/char/hw_random/pasemi-rng.c |   14 ++-
 drivers/char/hw_random/via-rng.c    |   19 ++--
 drivers/crypto/hifn_795x.c          |  192 ++++++++++++++++++++++++++++++++++-
 include/linux/hw_random.h           |    2 +-
 9 files changed, 262 insertions(+), 41 deletions(-)

Patrick McHardy (3):
[HWRNG]: move status polling loop to data_present callbacks [HIFN]: Improve PLL initialization
[HIFN]: Add support for using the random number generator