@samitouri / QOSamiQemu / commits / 39968a85c6

hw/riscv/atlantis: Ensure OpenSBI has a non-zero next_addr

When using OpenSBI fw_dynamic on the Atlantis board OpenSBI fails to print any output, as it hits an error early on in the boot process and gets stuck in `sbi_hart_hang()`. The error occurs in the `sanitize_domain()` function inside OpenSBI. `sanitize_domain()` is called after a M-Mode OpenSBI Firmware and a generic coverall S-Mode RWX memory region are created. `sanitize_domain()` is checking that the next address is executable. If no next address is provided (which occurs on QEMU with an empty payload), then `dom->next_addr` will be 0. On most RISC-V boards address 0 will fall inside the coverall S-Mode RWX memory region and pass this check. On Atlantis the OpenSBI firmware is running at address 0, so this address falls inside the M-Mode only OpenSBI firmware region and fails the check. Once the check has failed OpenSBI aborts and the user doesn't see any messages. This can be fixed by either supplying a payload, or just manually forcing a non-zero address (actually just any address that isn't the OpenSBI firmware) for next_addr. This patch ensures that if no kernel is loaded we still specify a default kernel_entry so that OpenSBI happily boots and jumps to the first address in memory. Signed-off-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Joel Stanley <joel@jms.id.au> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-ID: <20260630024952.1520546-9-joel@jms.id.au> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>

Alistair Francis committed Jun 30, 2026 at 12:19 UTC 39968a85c6d64490e530a02f527d80a28180478c
1 file changed +9 -1
hw/riscv/tt_atlantis.c
+9 -1
@@ -377,8 +377,16 @@ static void tt_atlantis_machine_done(Notifier *notifier, void *data)
377 if (machine->kernel_filename) {
378 riscv_load_kernel(machine, &boot_info, kernel_start_addr,
379 true, NULL);
380 + kernel_entry = boot_info.image_low_addr;
381 + } else {
382 + /* If we aren't loading a payload, OpenSBI thinks we are trying to boot
383 + * address 0, which fails `sbi_domain_check_addr()` as that is where
384 + * OpenSBI is running. Instead point OpenSBI to the end of the region
385 + * where it was loaded, which avoids the early hang, allowing the
386 + * system to proceed with the OpenSBI boot output.
387 + */
388 + kernel_entry = kernel_start_addr;
389 }
381 - kernel_entry = boot_info.image_low_addr;
390
391 fdt_load_addr = riscv_compute_fdt_addr(s->memmap[TT_ATL_DDR_LO].base,
392 s->memmap[TT_ATL_DDR_LO].size,