mips/malta: pass RNG seed via env var and re-randomize on reboot
commit6233a138599bea89ad683b883dca38388f12fd2d
authorJason A. Donenfeld <Jason@zx2c4.com>
Tue, 25 Oct 2022 17:28:43 +0000 (25 19:28 +0200)
committerPeter Maydell <peter.maydell@linaro.org>
Thu, 27 Oct 2022 10:47:45 +0000 (27 11:47 +0100)
tree5635a09061a7733dc3b1ccdef9ff4b5b3867a59f
parenta76b911c0de3d72e245060a57d02f816fb1334e2
mips/malta: pass RNG seed via env var and re-randomize on reboot

As of the kernel commit linked below, Linux ingests an RNG seed
passed as part of the environment block by the bootloader or firmware.
This mechanism works across all different environment block types,
generically, which pass some block via the second firmware argument. On
malta, this has been tested to work when passed as an argument from
U-Boot's linux_env_set.

As is the case on most other architectures (such as boston), when
booting with `-kernel`, QEMU, acting as the bootloader, should pass the
RNG seed, so that the machine has good entropy for Linux to consume. So
this commit implements that quite simply by using the guest random API,
which is what is used on nearly all other archs too. It also
reinitializes the seed on reboot, so that it is always fresh.

Link: https://git.kernel.org/torvalds/c/056a68cea01
Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
Cc: Paul Burton <paulburton@kernel.org>
Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
hw/mips/malta.c