On Wed, Jun 3, 2026 at 5:03 PM Joel Stanley <[email protected]> wrote:
>
> From: Nicholas Piggin <[email protected]>
>
> OpenSBI hangs before any console output if the domain init code sees the
> next stage is not in an executable region.
>
> If no kernel payload is provided to QEMU, the next stage address is
> NULL, and the riscv virt machine memory map ends up covering the 0
> address with the catch all S-mode RWX region and so OpenSBI prints
> console messages and does not hang until the next stage boot.
>
> The Tenstorrent Atlantis machine address map has RAM starting at 0 and
> it loads OpenSBI there, so it is M-mode and not accessible by S-mode,
> tripping the early check and hang.
>
> Add a helper to set up a simple payload that gets OpenSBI messages to
> console, until OpenSBI can be fixed.

I still don't like this. What is the status of the OpenSBI fix? Can we
link to the upstream patch? I'm worried we are going to be stuck with
this hack forever.

Alistair

>
> Signed-off-by: Nicholas Piggin <[email protected]>
> Reviewed-by: Daniel Henrique Barboza <[email protected]>
> Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
> Signed-off-by: Joel Stanley <[email protected]>
> ---
>  hw/riscv/tt_atlantis.c | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
>
> diff --git a/hw/riscv/tt_atlantis.c b/hw/riscv/tt_atlantis.c
> index 1ccd7d017c56..5de138578b48 100644
> --- a/hw/riscv/tt_atlantis.c
> +++ b/hw/riscv/tt_atlantis.c
> @@ -413,6 +413,30 @@ static void load_fdt(TTAtlantisState *s)
>      create_fdt_memory(s);
>  }
>
> +/*
> + * This works around a problem with OpenSBI hanging with no console output if
> + * no payload is provided. By chance, machines with memory at 0x80000000 do 
> get
> + * output, but Atlantis memory begins at 0x0 which takes a different OpenSBI
> + * error path.
> + *
> + * This can be removed when OpenSBI is fixed in QEMU.
> + */
> +static void tt_atlantis_setup_halting_payload_opensbi_fixup(
> +                                        RISCVBootInfo *info, hwaddr addr)
> +{
> +    /* Store the payload vector in little_endian byte order */
> +    static const uint32_t payload_vec[] = {
> +        const_le32(0x10500073),         /* 1: wfi           */
> +        const_le32(0xffdff06f),         /* j       1b       */
> +    };
> +    rom_add_blob_fixed_as("mrom.payload", payload_vec, sizeof(payload_vec),
> +                          addr, &address_space_memory);
> +
> +    info->kernel_size = sizeof(payload_vec);
> +    info->image_low_addr = addr;
> +    info->image_high_addr = info->image_low_addr + info->kernel_size;
> +}
> +
>  static void tt_atlantis_machine_done(Notifier *notifier, void *data)
>  {
>      TTAtlantisState *s = container_of(notifier, TTAtlantisState, 
> machine_done);
> @@ -450,6 +474,9 @@ static void tt_atlantis_machine_done(Notifier *notifier, 
> void *data)
>      if (machine->kernel_filename) {
>          riscv_load_kernel(machine, &boot_info, kernel_start_addr,
>                            true, NULL);
> +    } else {
> +        tt_atlantis_setup_halting_payload_opensbi_fixup(&boot_info,
> +                                                        kernel_start_addr);
>      }
>      kernel_entry = boot_info.image_low_addr;
>
> --
> 2.47.3
>
>

Reply via email to