From 74e95f7071c8d8f40b352992b19c967655459b31 Mon Sep 17 00:00:00 2001 From: tangbinzy Date: Mon, 9 Sep 2024 08:20:28 +0000 Subject: [PATCH] hw/microblaze: pass random seed to fdt mainline inclusion commit b91b6b5a2cd83a096116929dfc8e016091080adc category: bugfix --------------------------------------------------------------- If the FDT contains /chosen/rng-seed, then the Linux RNG will use it to initialize early. Set this using the usual guest random number generation function. This FDT node is part of the DT specification. Reviewed-by: Edgar E. Iglesias Signed-off-by: Jason A. Donenfeld Signed-off-by: Edgar E. Iglesias Signed-off-by: tangbinzy --- hw/microblaze/boot.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/microblaze/boot.c b/hw/microblaze/boot.c index 8821d009f1..26f315aaea 100644 --- a/hw/microblaze/boot.c +++ b/hw/microblaze/boot.c @@ -31,6 +31,7 @@ #include "qemu/option.h" #include "qemu/config-file.h" #include "qemu/error-report.h" +#include "qemu/guest-random.h" #include "sysemu/device_tree.h" #include "sysemu/reset.h" #include "hw/boards.h" @@ -76,6 +77,7 @@ static int microblaze_load_dtb(hwaddr addr, int fdt_size; void *fdt = NULL; int r; + uint8_t rng_seed[32]; if (dtb_filename) { fdt = load_device_tree(dtb_filename, &fdt_size); @@ -84,6 +86,9 @@ static int microblaze_load_dtb(hwaddr addr, return 0; } + qemu_guest_getrandom_nofail(rng_seed, sizeof(rng_seed)); + qemu_fdt_setprop(fdt, "/chosen", "rng-seed", rng_seed, sizeof(rng_seed)); + if (kernel_cmdline) { r = qemu_fdt_setprop_string(fdt, "/chosen", "bootargs", kernel_cmdline); -- 2.41.0.windows.1