[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 06/30] hw/ppc: pass random seed to fdt
From: |
Daniel Henrique Barboza |
Subject: |
[PULL 06/30] hw/ppc: pass random seed to fdt |
Date: |
Mon, 18 Jul 2022 14:21:44 -0300 |
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
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 is confirmed to successfully initialize the
RNG on Linux 5.19-rc6. The rng-seed node is part of the DT spec. Set
this on the paravirt platforms, spapr and e500, just as is done on other
architectures with paravirt hardware.
Cc: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20220712135114.289855-1-Jason@zx2c4.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
hw/ppc/e500.c | 5 +++++
hw/ppc/spapr.c | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index 757cfaa62f..32495d0123 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -17,6 +17,7 @@
#include "qemu/osdep.h"
#include "qemu/datadir.h"
#include "qemu/units.h"
+#include "qemu/guest-random.h"
#include "qapi/error.h"
#include "e500.h"
#include "e500-ccsr.h"
@@ -346,6 +347,7 @@ static int ppce500_load_device_tree(PPCE500MachineState
*pms,
};
const char *dtb_file = machine->dtb;
const char *toplevel_compat = machine->dt_compatible;
+ uint8_t rng_seed[32];
if (dtb_file) {
char *filename;
@@ -403,6 +405,9 @@ static int ppce500_load_device_tree(PPCE500MachineState
*pms,
if (ret < 0)
fprintf(stderr, "couldn't set /chosen/bootargs\n");
+ qemu_guest_getrandom_nofail(rng_seed, sizeof(rng_seed));
+ qemu_fdt_setprop(fdt, "/chosen", "rng-seed", rng_seed, sizeof(rng_seed));
+
if (kvm_enabled()) {
/* Read out host's frequencies */
clock_freq = kvmppc_get_clockfreq();
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 9a5382d527..3a5112899e 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -27,6 +27,7 @@
#include "qemu/osdep.h"
#include "qemu/datadir.h"
#include "qemu/memalign.h"
+#include "qemu/guest-random.h"
#include "qapi/error.h"
#include "qapi/qapi-events-machine.h"
#include "qapi/qapi-events-qdev.h"
@@ -1014,6 +1015,7 @@ static void spapr_dt_chosen(SpaprMachineState *spapr,
void *fdt, bool reset)
{
MachineState *machine = MACHINE(spapr);
SpaprMachineClass *smc = SPAPR_MACHINE_GET_CLASS(machine);
+ uint8_t rng_seed[32];
int chosen;
_FDT(chosen = fdt_add_subnode(fdt, 0, "chosen"));
@@ -1091,6 +1093,9 @@ static void spapr_dt_chosen(SpaprMachineState *spapr,
void *fdt, bool reset)
spapr_dt_ov5_platform_support(spapr, fdt, chosen);
}
+ qemu_guest_getrandom_nofail(rng_seed, sizeof(rng_seed));
+ _FDT(fdt_setprop(fdt, chosen, "rng-seed", rng_seed, sizeof(rng_seed)));
+
_FDT(spapr_dt_ovec(fdt, chosen, spapr->ov5_cas, "ibm,architecture-vec-5"));
}
--
2.36.1
- [PULL 00/30] ppc queue, Daniel Henrique Barboza, 2022/07/18
- [PULL 01/30] ppc64: Allocate IRQ lines with qdev_init_gpio_in(), Daniel Henrique Barboza, 2022/07/18
- [PULL 02/30] ppc/40x: Allocate IRQ lines with qdev_init_gpio_in(), Daniel Henrique Barboza, 2022/07/18
- [PULL 03/30] ppc/6xx: Allocate IRQ lines with qdev_init_gpio_in(), Daniel Henrique Barboza, 2022/07/18
- [PULL 04/30] ppc/e500: Allocate IRQ lines with qdev_init_gpio_in(), Daniel Henrique Barboza, 2022/07/18
- [PULL 05/30] ppc: Remove unused irq_inputs, Daniel Henrique Barboza, 2022/07/18
- [PULL 06/30] hw/ppc: pass random seed to fdt,
Daniel Henrique Barboza <=
- [PULL 07/30] target/ppc/kvm: Skip current and parent directories in kvmppc_find_cpu_dt, Daniel Henrique Barboza, 2022/07/18
- [PULL 08/30] target/ppc: Fix gen_priv_exception error value in mfspr/mtspr, Daniel Henrique Barboza, 2022/07/18
- [PULL 11/30] target/ppc: fix exception error code in helper_{load, store}_dcr, Daniel Henrique Barboza, 2022/07/18
- [PULL 09/30] target/ppc: fix exception error value in slbfee, Daniel Henrique Barboza, 2022/07/18
- [PULL 13/30] target/ppc: fix exception error code in spr_write_excp_vector, Daniel Henrique Barboza, 2022/07/18
- [PULL 12/30] target/ppc: fix PMU Group A register read/write exceptions, Daniel Henrique Barboza, 2022/07/18
- [PULL 10/30] target/ppc: remove mfdcrux and mtdcrux, Daniel Henrique Barboza, 2022/07/18
- [PULL 16/30] target/ppc: receive DisasContext explicitly in GEN_PRIV, Daniel Henrique Barboza, 2022/07/18
- [PULL 14/30] target/ppc: Move tlbie[l] to decode tree, Daniel Henrique Barboza, 2022/07/18
- [PULL 15/30] target/ppc: Implement ISA 3.00 tlbie[l], Daniel Henrique Barboza, 2022/07/18