rockchip: board: Increase rng-seed size to make it sufficient for modern Linux
Subsystems (3)
PATCH v3 1/1 rockchip: board: Increase rng-seed size to make it sufficient for modern Linux
Increase rng-seed size to make Linux happy and initialize rng pool instantly. Linux 5.19+ requires 32 bytes of entropy to initialize random pool, but u-boot currently provides only 8 bytes.
Linux 5.18 and probably some vesrions before it used to require 64 bytes. Bump min value to 64 bytes to be on a safe side.
Boot with 8 byte rng-seed (Linux 6.11):
# dmesg | grep crng
[ 12.089286] random: crng init done
Boot with 32 byte rng-seed (Linux 6.11):
# dmesg | grep crng
[ 0.000000] random: crng init doneLinux source references:
https://github.com/torvalds/linux/blob/7234e2ea0edd00bfb6bb2159e55878c19885ce68/drivers/char/random.c#L632
https://elixir.bootlin.com/linux/v5.18/source/drivers/char/random.c#L236
https://elixir.bootlin.com/linux/v5.19/source/drivers/char/random.c#L551
---
Changes in v3:
- reword warning
- increase default rng_seed_size to support older linux as well
- reword commit message
Changes in v2:
- add env config knob rng_seed_size
- add warning for small rng_seed_size
- 12-character commit SHA in Fixes
arch/arm/mach-rockchip/board.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
arch/arm/mach-rockchip/board.c +8 -1
@@ -472,9 +472,16 @@ __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 ,64 );u64 *data; +if (len <64 ) { +// rng_seed_size should be at least 32 bytes for Linux 5.19+, or 64 for +// older Linux'es +log_warning ("Value for rng_seed_size too low (%lu) and likely insufficient for the Linux RNG initialization\n" , + len); + } + data =malloc (len);if (!data) {printf ("Out of memory\n" );
Signature · 1 line
2.34.1
Quoted 13 lines · Alex Shumsky
Increase rng-seed size to make Linux happy and initialize rng pool instantly. Linux 5.19+ requires 32 bytes of entropy to initialize random pool, but u-boot currently provides only 8 bytes.
Linux 5.18 and probably some vesrions before it used to require 64 bytes. Bump min value to 64 bytes to be on a safe side.Boot with 8 byte rng-seed (Linux 6.11):
# dmesg | grep crng [ 12.089286] random: crng init done Boot with 32 byte rng-seed (Linux 6.11): # dmesg | grep crng [ 0.000000] random: crng init done
Quoted 8 lines
Linux source references:
https://github.com/torvalds/linux/blob/7234e2ea0edd00bfb6bb2159e55878c19885ce68/drivers/char/random.c#L632
https://elixir.bootlin.com/linux/v5.18/source/drivers/char/random.c#L236
https://elixir.bootlin.com/linux/v5.19/source/drivers/char/random.c#L551Signed-off-by Alex Shumsky <[email protected]>Fixes d2048bafae40 ("rockchip: board: Add board_rng_seed() for allRockchip devices")
Looking good to me, with some additional remarks below.
Quoted 30 lines
---
Changes in v3:
- reword warning
- increase defaultrng_seed_sizeto support older linux as well
- reword commit messageChanges in v2:
- add env config knobrng_seed_size
- add warning for smallrng_seed_size
- 12-character commit SHA in Fixesarch/arm/mach-rockchip/board.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)arch/arm/mach-rockchip/board.c +3
-1@@ -472,9 +472,16 @@ __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 ,64 );u64 *data; +if (len <64 ) { +// rng_seed_size should be at least 32 bytes for Linux 5.19+, or 64 for
arch/arm/mach-rockchip/board.c __weak int misc_init_r(void) · line 480
Quoted 1 line
arch/arm/mach-rockchip/board.c +1
-0+// older Linux'es
s/Linux'es/Linux kernel versions/
or s/Linux'es/Linux versions/
... and possibly break the comment after the comma, for improved readability.
Quoted 8 lines
arch/arm/mach-rockchip/board.c +1
-0+ log_warning("Value for rng_seed_size too low (%lu) and likelyinsufficient for the Linux RNG initialization\n",
arch/arm/mach-rockchip/board.c +3
-0+ len); + } + data =malloc (len);if (!data) {printf ("Out of memory\n" );
Quoted 4 lines · Alex Shumsky
Increase rng-seed size to make Linux happy and initialize rng pool instantly. Linux 5.19+ requires 32 bytes of entropy to initialize random pool, but u-boot currently provides only 8 bytes.
Linux 5.18 and probably some vesrions before it used to require 64 bytes.
"versions", typo
Quoted 9 lines
Bump min value to 64 bytes to be on a safe side.
Boot with 8 byte rng-seed (Linux 6.11):
# dmesg | grep crng [ 12.089286] random: crng init done Boot with 32 byte rng-seed (Linux 6.11): # dmesg | grep crng [ 0.000000] random: crng init done
Quoted 4 lines
Linux source references:
https://github.com/torvalds/linux/blob/7234e2ea0edd00bfb6bb2159e55878c19885ce68/drivers/char/random.c#L632
https://elixir.bootlin.com/linux/v5.18/source/drivers/char/random.c#L236
https://elixir.bootlin.com/linux/v5.19/source/drivers/char/random.c#L551
Please use https://git.kernel.org torvalds repo , not some random downstream webpages.
Quoted 22 lines
Signed-off-by Alex Shumsky <[email protected]>Fixes d2048bafae40 ("rockchip: board: Add board_rng_seed() for all Rockchip devices")---
Changes in v3:
- reword warning
- increase defaultrng_seed_sizeto support older linux as well
- reword commit messageChanges in v2:
- add env config knobrng_seed_size
- add warning for smallrng_seed_size
- 12-character commit SHA in Fixesarch/arm/mach-rockchip/board.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)arch/arm/mach-rockchip/board.c +0
-0
arch/arm/mach-rockchip/board.c __weak int misc_init_r(void) · line 480
Quoted 10 lines
arch/arm/mach-rockchip/board.c +4
-1@@ -472,9 +472,16 @@ __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 ,64 );u64 *data; +if (len <64 ) { +// rng_seed_size should be at least 32 bytes for Linux 5.19+, or 64 for +// older Linux'es
/*
* Please use C style
* multi-line
* comment.
*/
(also, s!Linux.es!Linux kernel versions! while you're fixing it )
arch/arm/mach-rockchip/board.c __weak int misc_init_r(void) · line 487
Quoted 7 lines
arch/arm/mach-rockchip/board.c +4
-0+log_warning ("Value for rng_seed_size too low (%lu) and likely insufficient for the Linux RNG initialization\n" , + len); + } + data =malloc (len);if (!data) {printf ("Out of memory\n" );
Thanks !