aboutsummaryrefslogtreecommitdiff
path: root/hw/nios2
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2022-07-19 14:01:13 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2022-07-22 19:01:44 +0200
commit6b23a6791685ac1bf071c0ebb35004e427c1806d (patch)
tree4ccf9df3ee2bfa0ddb87230e272af9308d21d5ad /hw/nios2
parent7906f11e62c39cdbf8edc274cb311a420d675371 (diff)
downloadqemu-6b23a6791685ac1bf071c0ebb35004e427c1806d.zip
qemu-6b23a6791685ac1bf071c0ebb35004e427c1806d.tar.gz
qemu-6b23a6791685ac1bf071c0ebb35004e427c1806d.tar.bz2
hw/nios2: virt: pass random seed to fdt
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. Cc: Chris Wulff <crwulff@gmail.com> Cc: Marek Vasut <marex@denx.de> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Message-Id: <20220719120113.118034-1-Jason@zx2c4.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/nios2')
-rw-r--r--hw/nios2/boot.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/hw/nios2/boot.c b/hw/nios2/boot.c
index 07b8d87..21cbfff 100644
--- a/hw/nios2/boot.c
+++ b/hw/nios2/boot.c
@@ -34,6 +34,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"
@@ -83,6 +84,7 @@ static int nios2_load_dtb(struct nios2_boot_info bi, const uint32_t ramsize,
int fdt_size;
void *fdt = NULL;
int r;
+ uint8_t rng_seed[32];
if (dtb_filename) {
fdt = load_device_tree(dtb_filename, &fdt_size);
@@ -91,6 +93,9 @@ static int nios2_load_dtb(struct nios2_boot_info bi, const uint32_t ramsize,
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);