random: add arch_get_random_*long_early()
authorMark Rutland <mark.rutland@arm.com>
Mon, 10 Feb 2020 13:00:13 +0000 (13:00 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 28 Feb 2020 04:21:52 +0000 (23:21 -0500)
commit253d3194c2b58152fe830fd27c2fd83ebc6fe5ee
treee9e6c341e7642b3e5cade3e18b57e2e049b75060
parent5cbe0f13b51ac2fb2fd55902cff8d0077fc084c0
random: add arch_get_random_*long_early()

Some architectures (e.g. arm64) can have heterogeneous CPUs, and the
boot CPU may be able to provide entropy while secondary CPUs cannot. On
such systems, arch_get_random_long() and arch_get_random_seed_long()
will fail unless support for RNG instructions has been detected on all
CPUs. This prevents the boot CPU from being able to provide
(potentially) trusted entropy when seeding the primary CRNG.

To make it possible to seed the primary CRNG from the boot CPU without
adversely affecting the runtime versions of arch_get_random_long() and
arch_get_random_seed_long(), this patch adds new early versions of the
functions used when initializing the primary CRNG.

Default implementations are provided atop of the existing
arch_get_random_long() and arch_get_random_seed_long() so that only
architectures with such constraints need to provide the new helpers.

There should be no functional change as a result of this patch.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Theodore Ts'o <tytso@mit.edu>
Link: https://lore.kernel.org/r/20200210130015.17664-3-mark.rutland@arm.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
drivers/char/random.c
include/linux/random.h