[PATCH] riscv: initialize jump labels before early_init_dt_scan()
From: Jason A. Donenfeld
Date: Tue Jun 07 2022 - 20:18:49 EST
Stephen reported that a static key warning splat appears during early
boot on arm64 systems that credit randomness from device trees that
contain an "rng-seed" property, because the dtb is parsed is called
before jump_label_init() during setup_arch(), which was fixed by
73e2d827a501 ("arm64: Initialize jump labels before
setup_machine_fdt()").
The same basic issue applies to RISC-V as well. So this commit moves the
call to jump_label_init() just before early_init_dt_scan().
jump_label_init() actually requires sbi_init() to be called first for
proper functioning, so it also moves that to the right place.
Reported-by: Stephen Boyd <swboyd@xxxxxxxxxxxx>
Reported-by: Phil Elwell <phil@xxxxxxxxxxxxxxx>
Cc: Ard Biesheuvel <ardb@xxxxxxxxxx>
Cc: Russel King <linux@xxxxxxxxxxxxxxx>
Cc: Catalin Marinas <catalin.marinas@xxxxxxx>
Cc: Paul Walmsley <paul.walmsley@xxxxxxxxxx>
Cc: Palmer Dabbelt <palmer@xxxxxxxxxxx>
Fixes: f5bda35fba61 ("random: use static branch for crng_ready()")
Signed-off-by: Jason A. Donenfeld <Jason@xxxxxxxxx>
---
arch/riscv/kernel/setup.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index f0f36a4a0e9b..c44c81b1cfb3 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -263,13 +263,15 @@ static void __init parse_dtb(void)
void __init setup_arch(char **cmdline_p)
{
+ early_ioremap_setup();
+ sbi_init();
+ jump_label_init();
+
parse_dtb();
setup_initial_init_mm(_stext, _etext, _edata, _end);
*cmdline_p = boot_command_line;
- early_ioremap_setup();
- jump_label_init();
parse_early_param();
efi_init();
@@ -285,7 +287,6 @@ void __init setup_arch(char **cmdline_p)
misc_mem_init();
init_resources();
- sbi_init();
#ifdef CONFIG_KASAN
kasan_init();
--
2.35.1