]> git.itanic.dy.fi Git - linux-stable/commit
random: remove early archrandom abstraction
authorJason A. Donenfeld <Jason@zx2c4.com>
Fri, 28 Oct 2022 23:18:04 +0000 (01:18 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Fri, 18 Nov 2022 01:18:10 +0000 (02:18 +0100)
commit2c03e16f44993d45f064580adb0eb408b513ad72
tree90a6fb43cdf6bfd22bd5ae8fe1f5602f073b36b2
parentb9b01a5625b5a9e9d96d14d4a813a54e8a124f4b
random: remove early archrandom abstraction

The arch_get_random*_early() abstraction is not completely useful and
adds complexity, because it's not a given that there will be no calls to
arch_get_random*() between random_init_early(), which uses
arch_get_random*_early(), and init_cpu_features(). During that gap,
crng_reseed() might be called, which uses arch_get_random*(), since it's
mostly not init code.

Instead we can test whether we're in the early phase in
arch_get_random*() itself, and in doing so avoid all ambiguity about
where we are. Fortunately, the only architecture that currently
implements arch_get_random*_early() also has an alternatives-based cpu
feature system, one flag of which determines whether the other flags
have been initialized. This makes it possible to do the early check with
zero cost once the system is initialized.

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Jean-Philippe Brucker <jean-philippe@linaro.org>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
arch/arm64/include/asm/archrandom.h
drivers/char/random.c
include/linux/random.h