[PATCH v3 2/3] powerpc/powernv: wire up rng during setup_arch

Michael Ellerman mpe at ellerman.id.au
Sun Jun 19 21:49:26 AEST 2022


"Jason A. Donenfeld" <Jason at zx2c4.com> writes:
> The platform's RNG must be available before random_init() in order to be
> useful for initial seeding, which in turn means that it needs to be
> called from setup_arch(), rather than from an init call. Fortunately,
> each platform already has a setup_arch function pointer, which means
> it's easy to wire this up. This commit also removes some noisy log
> messages that don't add much.
>
> Cc: stable at vger.kernel.org
> Cc: Michael Ellerman <mpe at ellerman.id.au>
> Cc: Christophe Leroy <christophe.leroy at csgroup.eu>
> Fixes: a4da0d50b2a0 ("powerpc: Implement arch_get_random_long/int() for powernv")
> Signed-off-by: Jason A. Donenfeld <Jason at zx2c4.com>
> ---
>  arch/powerpc/platforms/powernv/powernv.h |  2 ++
>  arch/powerpc/platforms/powernv/rng.c     | 18 +++++-------------
>  arch/powerpc/platforms/powernv/setup.c   |  2 ++
>  3 files changed, 9 insertions(+), 13 deletions(-)
>
...
> diff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c
> index 824c3ad7a0fa..a5fcb6796b22 100644
> --- a/arch/powerpc/platforms/powernv/setup.c
> +++ b/arch/powerpc/platforms/powernv/setup.c
> @@ -203,6 +203,8 @@ static void __init pnv_setup_arch(void)
>  	pnv_check_guarded_cores();
>  
>  	/* XXX PMCS */
> +
> +	powernv_rng_init();
>  }

This crashes on power8 because it's too early to call kzalloc() in
rng_create(), and it's also too early to setup the percpu variables in
there.

I'll rework it and post a v4.

cheers


More information about the Linuxppc-dev mailing list