U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Dragan Simic <dsimic@manjaro.org>
To: Alex Shumsky <alexthreed@gmail.com>
Cc: u-boot@lists.denx.de, Ben Wolsieffer <benwolsieffer@gmail.com>,
	Chris Morgan <macromorgan@hotmail.com>,
	Jonas Karlman <jonas@kwiboo.se>,
	Kever Yang <kever.yang@rock-chips.com>,
	Marek Vasut <marex@denx.de>,
	Philipp Tomsich <philipp.tomsich@theobroma-systems.com>,
	Philipp Tomsich <philipp.tomsich@vrull.eu>,
	Quentin Schulz <quentin.schulz@cherry.de>,
	Simon Glass <sjg@chromium.org>, Tom Rini <trini@konsulko.com>
Subject: Re: [PATCH v2] rockchip: board: Increase rng-seed size to make it sufficient for modern Linux
Date: Mon, 14 Oct 2024 20:19:20 +0200	[thread overview]
Message-ID: <3f4143078e0dc3409c96ea13be5b8317@manjaro.org> (raw)
In-Reply-To: <20241014175338.2675136-1-alexthreed@gmail.com>

Hello Alex,

Thanks for the v2.  Please see a few comments below.

On 2024-10-14 19:53, Alex Shumsky wrote:
> Modern Linux requires 32 byte seed to initialize random pool, but 
> u-boot
> currently provides only 8 bytes. Increase rng-seed size to make Linux 
> happy and
> initialize rng pool instantly.
> 
> Boot with 8 byte rng-seed:
>     # dmesg | grep crng
>     [   12.089286] random: crng init done
> Boot with 32 byte rng-seed:
>     # dmesg | grep crng
>     [    0.000000] random: crng init done
> 
> https://github.com/torvalds/linux/blob/7234e2ea0edd00bfb6bb2159e55878c19885ce68/drivers/char/random.c#L632
> 
> Signed-off-by: Alex Shumsky <alexthreed@gmail.com>
> Fixes: d2048bafae40 ("rockchip: board: Add board_rng_seed() for all
> Rockchip devices")
> ---
> 
> Changes in v2:
> - add env config knob rng_seed_size

Perhaps the emitted warning should also be mentioned here.

> - 12-character commit SHA in Fixes
> 
>  arch/arm/mach-rockchip/board.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-rockchip/board.c 
> b/arch/arm/mach-rockchip/board.c
> index 3fadf7e412..f9f0d7214c 100644
> --- a/arch/arm/mach-rockchip/board.c
> +++ b/arch/arm/mach-rockchip/board.c
> @@ -472,9 +472,15 @@ __weak int misc_init_r(void)
>  __weak int board_rng_seed(struct abuf *buf)
>  {
>  	struct udevice *dev;
> -	size_t len = 0x8;
> +	ulong len = env_get_ulong("rng_seed_size", 10, 32);
>  	u64 *data;
> 
> +	if (len < 32) {
> +		// rng_seed_size should be 32 bytes for Linux 5.19+, or 64 for older 
> Linux'es

Shouldn't it be 8 for older kernels?

> +		log_warning("Too small rng_seed_size (%lu). It is likely
> insufficient to init linux crng\n",
> +			    len);

Perhaps this would read better:

   "Value for rng_seed_size too low (%lu) and likely insufficient
   for the Linux RNG initialization"

> +	}
> +
>  	data = malloc(len);
>  	if (!data) {
>  		printf("Out of memory\n");

  reply	other threads:[~2024-10-14 18:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-14 17:53 [PATCH v2] rockchip: board: Increase rng-seed size to make it sufficient for modern Linux Alex Shumsky
2024-10-14 18:19 ` Dragan Simic [this message]
2024-10-14 18:50   ` Alex ThreeD
2024-10-14 19:00     ` Dragan Simic
2024-10-14 19:17       ` Alex ThreeD
2024-10-14 19:28         ` Dragan Simic
2024-10-14 20:12           ` Marek Vasut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3f4143078e0dc3409c96ea13be5b8317@manjaro.org \
    --to=dsimic@manjaro.org \
    --cc=alexthreed@gmail.com \
    --cc=benwolsieffer@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=kever.yang@rock-chips.com \
    --cc=macromorgan@hotmail.com \
    --cc=marex@denx.de \
    --cc=philipp.tomsich@theobroma-systems.com \
    --cc=philipp.tomsich@vrull.eu \
    --cc=quentin.schulz@cherry.de \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox