All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Song Gao <gaosong@loongson.cn>
Cc: qemu-devel@nongnu.org, peter.maydell@linaro.org,
	"Jason A. Donenfeld" <Jason@zx2c4.com>
Subject: Re: [PULL 6/7] hw/loongarch: virt: pass random seed to fdt
Date: Mon, 18 Nov 2024 19:57:44 +0000	[thread overview]
Message-ID: <ZzucOBWZJYeUVi3V@redhat.com> (raw)
In-Reply-To: <20240912125132.268802-7-gaosong@loongson.cn>

Hi Song / Jason,

We're seeing non-deterministic hangs in our functional test
suite 'tests/functional/test_loongarch64_virt.py' and my
attempt at git bisect is blaming this commit.

With this applied, perhaps 1 time in 10, the test case hangs,
with zero serial port output from EDK2 emitted

  https://gitlab.com/qemu-project/qemu/-/issues/2686

I'm not seeing an obvious flaw in this commit's code, so I'm
wondering if it has accidentally tickled some other subtle
pre-existing bug elsewhere. Some general problem with FDT
handling on loongarch64 perhaps ?

On Thu, Sep 12, 2024 at 08:51:31PM +0800, Song Gao wrote:
> 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 the same procedure that's done in b91b6b5a2c ("hw/microblaze:
> pass random seed to fdt"), e4b4f0b71c ("hw/riscv: virt: pass random seed
> to fdt"), c6fe3e6b4c ("hw/openrisc: virt: pass random seed to fdt"),
> 67f7e426e5 ("hw/i386: pass RNG seed via setup_data entry"), c287941a4d
> ("hw/rx: pass random seed to fdt"), 5e19cc68fb ("hw/mips: boston: pass
> random seed to fdt"), 6b23a67916 ("hw/nios2: virt: pass random seed to fdt")
> c4b075318e ("hw/ppc: pass random seed to fdt"), and 5242876f37
> ("hw/arm/virt: dt: add rng-seed property").
> 
> These earlier commits later were amended to rerandomize the RNG seed on
> snapshot load, but the LoongArch code somehow already does that, despite
> not having this patch here, presumably due to some lucky copy and
> pasting.
> 
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
> Reviewed-by: Song Gao <gaosong@loongson.cn>
> Message-Id: <20240905153316.2038769-1-Jason@zx2c4.com>
> Signed-off-by: Song Gao <gaosong@loongson.cn>
> ---
>  hw/loongarch/virt.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
> index 76dd29a391..81b1f9486f 100644
> --- a/hw/loongarch/virt.c
> +++ b/hw/loongarch/virt.c
> @@ -48,6 +48,7 @@
>  #include "hw/block/flash.h"
>  #include "hw/virtio/virtio-iommu.h"
>  #include "qemu/error-report.h"
> +#include "qemu/guest-random.h"
>  
>  static bool virt_is_veiointc_enabled(LoongArchVirtMachineState *lvms)
>  {
> @@ -303,6 +304,7 @@ static void fdt_add_uart_node(LoongArchVirtMachineState *lvms,
>  static void create_fdt(LoongArchVirtMachineState *lvms)
>  {
>      MachineState *ms = MACHINE(lvms);
> +    uint8_t rng_seed[32];
>  
>      ms->fdt = create_device_tree(&lvms->fdt_size);
>      if (!ms->fdt) {
> @@ -316,6 +318,10 @@ static void create_fdt(LoongArchVirtMachineState *lvms)
>      qemu_fdt_setprop_cell(ms->fdt, "/", "#address-cells", 0x2);
>      qemu_fdt_setprop_cell(ms->fdt, "/", "#size-cells", 0x2);
>      qemu_fdt_add_subnode(ms->fdt, "/chosen");
> +
> +    /* Pass seed to RNG */
> +    qemu_guest_getrandom_nofail(rng_seed, sizeof(rng_seed));
> +    qemu_fdt_setprop(ms->fdt, "/chosen", "rng-seed", rng_seed, sizeof(rng_seed));
>  }
>  
>  static void fdt_add_cpu_nodes(const LoongArchVirtMachineState *lvms)
> -- 
> 2.34.1
> 
> 

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



  reply	other threads:[~2024-11-18 19:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-12 12:51 [PULL 0/7] loongarch-to-apply queue Song Gao
2024-09-12 12:51 ` [PULL 1/7] target/loongarch: Add compatible support about VM reboot Song Gao
2024-09-12 12:51 ` [PULL 2/7] hw/loongarch: Remove default enable with VIRTIO_VGA device Song Gao
2024-09-12 12:51 ` [PULL 3/7] target/loongarch/kvm: Add vCPU reset function Song Gao
2024-09-12 12:51 ` [PULL 4/7] target/loongarch: Support QMP dump-guest-memory Song Gao
2024-09-12 12:51 ` [PULL 5/7] hw/loongarch: virt: support up to 4 serial ports Song Gao
2024-09-12 12:51 ` [PULL 6/7] hw/loongarch: virt: pass random seed to fdt Song Gao
2024-11-18 19:57   ` Daniel P. Berrangé [this message]
2024-11-19  1:36     ` mao bibo
2024-09-12 12:51 ` [PULL 7/7] hw/loongarch: Add acpi SPCR table support Song Gao
2024-09-13 13:34 ` [PULL 0/7] loongarch-to-apply queue Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZzucOBWZJYeUVi3V@redhat.com \
    --to=berrange@redhat.com \
    --cc=Jason@zx2c4.com \
    --cc=gaosong@loongson.cn \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.