All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] riscv: initialize jump labels before early_init_dt_scan()
@ 2022-06-07 19:57 ` Jason A. Donenfeld
  0 siblings, 0 replies; 6+ messages in thread
From: Jason A. Donenfeld @ 2022-06-07 19:57 UTC (permalink / raw)
  To: linux-riscv, linux-kernel
  Cc: Jason A. Donenfeld, Stephen Boyd, Phil Elwell, Ard Biesheuvel,
	Russel King, Catalin Marinas, Paul Walmsley, Palmer Dabbelt

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@chromium.org>
Reported-by: Phil Elwell <phil@raspberrypi.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Russel King <linux@armlinux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Fixes: f5bda35fba61 ("random: use static branch for crng_ready()")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 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


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] riscv: initialize jump labels before early_init_dt_scan()
@ 2022-06-07 19:57 ` Jason A. Donenfeld
  0 siblings, 0 replies; 6+ messages in thread
From: Jason A. Donenfeld @ 2022-06-07 19:57 UTC (permalink / raw)
  To: linux-riscv, linux-kernel
  Cc: Jason A. Donenfeld, Stephen Boyd, Phil Elwell, Ard Biesheuvel,
	Russel King, Catalin Marinas, Paul Walmsley, Palmer Dabbelt

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@chromium.org>
Reported-by: Phil Elwell <phil@raspberrypi.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Russel King <linux@armlinux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Fixes: f5bda35fba61 ("random: use static branch for crng_ready()")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] riscv: initialize jump labels before early_init_dt_scan()
  2022-06-07 19:57 ` Jason A. Donenfeld
@ 2022-06-08  8:17   ` Jason A. Donenfeld
  -1 siblings, 0 replies; 6+ messages in thread
From: Jason A. Donenfeld @ 2022-06-08  8:17 UTC (permalink / raw)
  To: linux-riscv, LKML
  Cc: Stephen Boyd, Phil Elwell, Ard Biesheuvel, Russel King,
	Catalin Marinas, Paul Walmsley, Palmer Dabbelt

This patch isn't needed in the end. An equivalent patch is needed on
xtensa, powerpc, arc, mips, arm32, arm64, riscv. That's a bit much and
points to a larger issue. So I'll fix this the ugly way in the
random.c code :(.

H o w e v e r, I'm pretty sure that you do need to move the sbi_init()
call above the existing jump_label_init() call as already existing. So
you might consider doing that.

Jason

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] riscv: initialize jump labels before early_init_dt_scan()
@ 2022-06-08  8:17   ` Jason A. Donenfeld
  0 siblings, 0 replies; 6+ messages in thread
From: Jason A. Donenfeld @ 2022-06-08  8:17 UTC (permalink / raw)
  To: linux-riscv, LKML
  Cc: Stephen Boyd, Phil Elwell, Ard Biesheuvel, Russel King,
	Catalin Marinas, Paul Walmsley, Palmer Dabbelt

This patch isn't needed in the end. An equivalent patch is needed on
xtensa, powerpc, arc, mips, arm32, arm64, riscv. That's a bit much and
points to a larger issue. So I'll fix this the ugly way in the
random.c code :(.

H o w e v e r, I'm pretty sure that you do need to move the sbi_init()
call above the existing jump_label_init() call as already existing. So
you might consider doing that.

Jason

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] riscv: initialize jump labels before early_init_dt_scan()
  2022-06-07 19:57 ` Jason A. Donenfeld
@ 2022-06-08 16:20   ` Jisheng Zhang
  -1 siblings, 0 replies; 6+ messages in thread
From: Jisheng Zhang @ 2022-06-08 16:20 UTC (permalink / raw)
  To: Jason A. Donenfeld
  Cc: linux-riscv, linux-kernel, Stephen Boyd, Phil Elwell,
	Ard Biesheuvel, Russel King, Catalin Marinas, Paul Walmsley,
	Palmer Dabbelt

On Tue, Jun 07, 2022 at 09:57:52PM +0200, Jason A. Donenfeld wrote:
> 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

Moving the sbi_init() earlier has been sent out but the patch is missing
in 5.19-rc1

https://lore.kernel.org/linux-riscv/20220521143456.2759-1-jszhang@kernel.org/T/#m00c3cb5e4e360ca8d7aa10c79c10437b7307c16c



> proper functioning, so it also moves that to the right place.
> 
> Reported-by: Stephen Boyd <swboyd@chromium.org>
> Reported-by: Phil Elwell <phil@raspberrypi.com>
> Cc: Ard Biesheuvel <ardb@kernel.org>
> Cc: Russel King <linux@armlinux.org.uk>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Paul Walmsley <paul.walmsley@sifive.com>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Fixes: f5bda35fba61 ("random: use static branch for crng_ready()")
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
> ---
>  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
> 
> 
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] riscv: initialize jump labels before early_init_dt_scan()
@ 2022-06-08 16:20   ` Jisheng Zhang
  0 siblings, 0 replies; 6+ messages in thread
From: Jisheng Zhang @ 2022-06-08 16:20 UTC (permalink / raw)
  To: Jason A. Donenfeld
  Cc: linux-riscv, linux-kernel, Stephen Boyd, Phil Elwell,
	Ard Biesheuvel, Russel King, Catalin Marinas, Paul Walmsley,
	Palmer Dabbelt

On Tue, Jun 07, 2022 at 09:57:52PM +0200, Jason A. Donenfeld wrote:
> 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

Moving the sbi_init() earlier has been sent out but the patch is missing
in 5.19-rc1

https://lore.kernel.org/linux-riscv/20220521143456.2759-1-jszhang@kernel.org/T/#m00c3cb5e4e360ca8d7aa10c79c10437b7307c16c



> proper functioning, so it also moves that to the right place.
> 
> Reported-by: Stephen Boyd <swboyd@chromium.org>
> Reported-by: Phil Elwell <phil@raspberrypi.com>
> Cc: Ard Biesheuvel <ardb@kernel.org>
> Cc: Russel King <linux@armlinux.org.uk>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Paul Walmsley <paul.walmsley@sifive.com>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Fixes: f5bda35fba61 ("random: use static branch for crng_ready()")
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
> ---
>  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
> 
> 
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-06-08 17:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-07 19:57 [PATCH] riscv: initialize jump labels before early_init_dt_scan() Jason A. Donenfeld
2022-06-07 19:57 ` Jason A. Donenfeld
2022-06-08  8:17 ` Jason A. Donenfeld
2022-06-08  8:17   ` Jason A. Donenfeld
2022-06-08 16:20 ` Jisheng Zhang
2022-06-08 16:20   ` Jisheng Zhang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.