[PATCH v2] rockchip: board: Increase rng-seed size to make it sufficient for modern Linux
Alex Shumsky
alexthreed at gmail.com
Mon Oct 14 19:53:38 CEST 2024
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 at gmail.com>
Fixes: d2048bafae40 ("rockchip: board: Add board_rng_seed() for all Rockchip devices")
---
Changes in v2:
- add env config knob rng_seed_size
- 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
+ log_warning("Too small rng_seed_size (%lu). It is likely insufficient to init linux crng\n",
+ len);
+ }
+
data = malloc(len);
if (!data) {
printf("Out of memory\n");
--
2.34.1
More information about the U-Boot
mailing list