diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c index 3fadf7e4122..75d6693e28a 100644 --- a/arch/arm/mach-rockchip/board.c +++ b/arch/arm/mach-rockchip/board.c @@ -472,9 +472,18 @@ __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 kernel versions + */ + log_warning("Value for rng_seed_size (%lu) too low, Linux kernel RNG may fail to initialize early\n", + len); + } + data = malloc(len); if (!data) { printf("Out of memory\n"); diff --git a/common/Kconfig b/common/Kconfig index 90cee19d413..14a6c44c804 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -928,6 +928,9 @@ config BOARD_RNG_SEED new seed for use on subsequent boots, and whether or not the kernel should account any entropy from the given seed. + Default seed size (64 bytes) can be overridden by a decimal + environment variable rng_seed_size. + endmenu menu "Update support" diff --git a/doc/usage/environment.rst b/doc/usage/environment.rst index cc33d3ec0f2..7bd9ffce8d8 100644 --- a/doc/usage/environment.rst +++ b/doc/usage/environment.rst @@ -323,6 +323,11 @@ netretry Useful on scripts which control the retry operation themselves. +rng_seed_size + Size of random value added to device-tree node /chosen/rng-seed. + This variable is given as a decimal number. + If unset, 64 bytes is used as the default. + silent_linux If set then Linux will be told to boot silently, by adding 'console=' to its command line. If "yes" it will be diff --git a/include/fdt_support.h b/include/fdt_support.h index 741e2360c22..9447a64e060 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -202,7 +202,8 @@ int ft_board_setup(void *blob, struct bd_info *bd); * * This function is called if CONFIG_BOARD_RNG_SEED is set, and must * be provided by the board. It should return, via @buf, some suitable - * seed value to pass to the kernel. + * seed value to pass to the kernel. Seed size could be set in a decimal + * environment variable rng_seed_size and it defaults to 64 bytes. * * @param buf A struct abuf for returning the seed and its size. * @return 0 if ok, negative on error.