@samitouri / QOSamiQemu / commits / 340a8c111d

hw/riscv: sifive_u: Align ROM reset vector data

The SiFive U ROM reset vector data needs proper 8-byte alignment for RV64 ld instructions. The misaligned load will cause exception when Zicclsm is supported as SiFive U CPU doesn't support hardware misaligned loads and stores. Add padding to ensure start_addr and fdt_load_addr are placed at 8-byte aligned offsets and adjust the load instruction offsets to match the new data layout. Signed-off-by: Frank Chang <frank.chang@sifive.com> Reviewed-by: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com> Message-ID: <20260810055618.1175500-3-frank.chang@sifive.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>

Frank Chang committed Aug 10, 2026 at 13:56 UTC 340a8c111dbf1f8f5524c6cbe959dad9b9af56b1
1 file changed +6 -5
hw/riscv/sifive_u.c
+6 -5
@@ -564,19 +564,20 @@ static void sifive_u_machine_init(MachineState *machine)
564 0,
565 0,
566 0x00028067, /* jr t0 */
567 + 0x00000000, /* padding for alignment */
568 start_addr, /* start: .dword */
569 start_addr_hi32,
570 fdt_load_addr, /* fdt_laddr: .dword */
571 fdt_load_addr_hi32,
571 - 0x00000000,
572 /* fw_dyn: */
573 };
574 +
575 if (riscv_is_32bit(&s->soc.u_cpus)) {
575 - reset_vec[4] = 0x0202a583; /* lw a1, 32(t0) */
576 - reset_vec[5] = 0x0182a283; /* lw t0, 24(t0) */
576 + reset_vec[4] = 0x0242a583; /* lw a1, 36(t0) */
577 + reset_vec[5] = 0x01c2a283; /* lw t0, 28(t0) */
578 } else {
578 - reset_vec[4] = 0x0202b583; /* ld a1, 32(t0) */
579 - reset_vec[5] = 0x0182b283; /* ld t0, 24(t0) */
579 + reset_vec[4] = 0x0242b583; /* ld a1, 36(t0) */
580 + reset_vec[5] = 0x01c2b283; /* ld t0, 28(t0) */
581 }
582
583