On Wed, Oct 15, 2025 at 11:29 PM Anton Johansson via <[email protected]> wrote: > > Since fw_dynamic_info is only used for non 32 bit targets, target_long > is int64_t anyway. Rename struct to fw_dynamic_info64 and use int64_t. > > Signed-off-by: Anton Johansson <[email protected]>
Reviewed-by: Alistair Francis <[email protected]> Alistair > --- > include/hw/riscv/boot_opensbi.h | 14 +++++++------- > hw/riscv/boot.c | 22 ++++++++++++---------- > 2 files changed, 19 insertions(+), 17 deletions(-) > > diff --git a/include/hw/riscv/boot_opensbi.h b/include/hw/riscv/boot_opensbi.h > index 18664a174b..ab9999be3f 100644 > --- a/include/hw/riscv/boot_opensbi.h > +++ b/include/hw/riscv/boot_opensbi.h > @@ -29,17 +29,17 @@ enum sbi_scratch_options { > }; > > /** Representation dynamic info passed by previous booting stage */ > -struct fw_dynamic_info { > +struct fw_dynamic_info64 { > /** Info magic */ > - target_long magic; > + int64_t magic; > /** Info version */ > - target_long version; > + int64_t version; > /** Next booting stage address */ > - target_long next_addr; > + int64_t next_addr; > /** Next booting stage mode */ > - target_long next_mode; > + int64_t next_mode; > /** Options for OpenSBI library */ > - target_long options; > + int64_t options; > /** > * Preferred boot HART id > * > @@ -55,7 +55,7 @@ struct fw_dynamic_info { > * stage can set it to -1UL which will force the FW_DYNAMIC firmware > * to use the relocation lottery mechanism. > */ > - target_long boot_hart; > + int64_t boot_hart; > }; > > /** Representation dynamic info passed by previous booting stage */ > diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c > index 4eadcff26c..64608e58c7 100644 > --- a/hw/riscv/boot.c > +++ b/hw/riscv/boot.c > @@ -387,7 +387,8 @@ void riscv_rom_copy_firmware_info(MachineState *machine, > uint64_t kernel_entry) > { > struct fw_dynamic_info32 dinfo32; > - struct fw_dynamic_info dinfo; > + struct fw_dynamic_info64 dinfo64; > + void *dinfo_ptr = NULL; > size_t dinfo_len; > > if (riscv_is_32bit(harts)) { > @@ -397,15 +398,17 @@ void riscv_rom_copy_firmware_info(MachineState *machine, > dinfo32.next_addr = cpu_to_le32(kernel_entry); > dinfo32.options = 0; > dinfo32.boot_hart = 0; > + dinfo_ptr = &dinfo32; > dinfo_len = sizeof(dinfo32); > } else { > - dinfo.magic = cpu_to_le64(FW_DYNAMIC_INFO_MAGIC_VALUE); > - dinfo.version = cpu_to_le64(FW_DYNAMIC_INFO_VERSION); > - dinfo.next_mode = cpu_to_le64(FW_DYNAMIC_INFO_NEXT_MODE_S); > - dinfo.next_addr = cpu_to_le64(kernel_entry); > - dinfo.options = 0; > - dinfo.boot_hart = 0; > - dinfo_len = sizeof(dinfo); > + dinfo64.magic = cpu_to_le64(FW_DYNAMIC_INFO_MAGIC_VALUE); > + dinfo64.version = cpu_to_le64(FW_DYNAMIC_INFO_VERSION); > + dinfo64.next_mode = cpu_to_le64(FW_DYNAMIC_INFO_NEXT_MODE_S); > + dinfo64.next_addr = cpu_to_le64(kernel_entry); > + dinfo64.options = 0; > + dinfo64.boot_hart = 0; > + dinfo_ptr = &dinfo64; > + dinfo_len = sizeof(dinfo64); > } > > /** > @@ -419,8 +422,7 @@ void riscv_rom_copy_firmware_info(MachineState *machine, > } > > rom_add_blob_fixed_as("mrom.finfo", > - riscv_is_32bit(harts) ? > - (void *)&dinfo32 : (void *)&dinfo, > + dinfo_ptr, > dinfo_len, > rom_base + reset_vec_size, > &address_space_memory); > > -- > 2.51.0 > >
