Skip to content

Commit

Permalink
hw/microblaze: pass random seed to fdt
Browse files Browse the repository at this point in the history
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 <edgar.iglesias@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
  • Loading branch information
zx2c4 authored and edgarigl committed Sep 21, 2022
1 parent 2906f93 commit b91b6b5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions hw/microblaze/boot.c
Expand Up @@ -30,6 +30,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"
Expand Down Expand Up @@ -75,6 +76,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);
Expand All @@ -83,6 +85,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);
Expand Down

0 comments on commit b91b6b5

Please sign in to comment.