* [PATCH v2 0/3] single-binary: Prepare hw/riscv for single compilation
@ 2025-10-27 12:35 Anton Johansson via
2025-10-27 12:35 ` [PATCH v2 1/3] hw/riscv: Use generic hwaddr for firmware addressses Anton Johansson via
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Anton Johansson via @ 2025-10-27 12:35 UTC (permalink / raw)
To: qemu-devel
Cc: pierrick.bouvier, philmd, alistair.francis, richard.henderson,
palmer
Hello,
this is a small prerequisite patchset that removes target_[u]?long and
replaces a few target specific macros with target-info variants.
Next up is using the target-info style QOM filtering of boards and then
moving translation units to common code. My current patches for this
are based on Philippes single-binary-hw-arm-rfc-v5 branch, is there some
other branch I should target here?
Changes in v2:
- Use MAKE_64BIT_MASK() in patch 2 (Richard);
- Dropped runtime TARGET_PHYS_ADDR_SPACE_BITS as it shouldn't be exposed
to common code and is better dealt with in other ways
(Richard, Philippe);
- Added reviewed-bys.
---
Anton Johansson (3):
hw/riscv: Use generic hwaddr for firmware addressses
hw/riscv: Replace target_ulong uses
hw/riscv: Widen OpenSBI dynamic info struct
include/hw/riscv/boot.h | 20 +++++++++----------
include/hw/riscv/boot_opensbi.h | 14 ++++++-------
hw/riscv/boot.c | 44 +++++++++++++++++++++--------------------
hw/riscv/microchip_pfsoc.c | 2 +-
hw/riscv/riscv-iommu.c | 6 ++++--
hw/riscv/riscv_hart.c | 2 +-
hw/riscv/sifive_u.c | 2 +-
hw/riscv/spike.c | 4 ++--
hw/riscv/virt.c | 2 +-
9 files changed, 50 insertions(+), 46 deletions(-)
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH v2 1/3] hw/riscv: Use generic hwaddr for firmware addressses 2025-10-27 12:35 [PATCH v2 0/3] single-binary: Prepare hw/riscv for single compilation Anton Johansson via @ 2025-10-27 12:35 ` Anton Johansson via 2025-10-27 12:39 ` Philippe Mathieu-Daudé 2025-10-27 12:35 ` [PATCH v2 2/3] hw/riscv: Replace target_ulong uses Anton Johansson via ` (2 subsequent siblings) 3 siblings, 1 reply; 11+ messages in thread From: Anton Johansson via @ 2025-10-27 12:35 UTC (permalink / raw) To: qemu-devel Cc: pierrick.bouvier, philmd, alistair.francis, richard.henderson, palmer Signed-off-by: Anton Johansson <anjo@rev.ng> --- include/hw/riscv/boot.h | 20 ++++++++++---------- hw/riscv/boot.c | 22 +++++++++++----------- hw/riscv/microchip_pfsoc.c | 2 +- hw/riscv/sifive_u.c | 2 +- hw/riscv/spike.c | 4 ++-- hw/riscv/virt.c | 2 +- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/include/hw/riscv/boot.h b/include/hw/riscv/boot.h index 7d59b2e6c6..d835594baa 100644 --- a/include/hw/riscv/boot.h +++ b/include/hw/riscv/boot.h @@ -43,21 +43,21 @@ bool riscv_is_32bit(RISCVHartArrayState *harts); char *riscv_plic_hart_config_string(int hart_count); void riscv_boot_info_init(RISCVBootInfo *info, RISCVHartArrayState *harts); -target_ulong riscv_calc_kernel_start_addr(RISCVBootInfo *info, - target_ulong firmware_end_addr); -target_ulong riscv_find_and_load_firmware(MachineState *machine, - const char *default_machine_firmware, - hwaddr *firmware_load_addr, - symbol_fn_t sym_cb); +hwaddr riscv_calc_kernel_start_addr(RISCVBootInfo *info, + hwaddr firmware_end_addr); +hwaddr riscv_find_and_load_firmware(MachineState *machine, + const char *default_machine_firmware, + hwaddr *firmware_load_addr, + symbol_fn_t sym_cb); const char *riscv_default_firmware_name(RISCVHartArrayState *harts); char *riscv_find_firmware(const char *firmware_filename, const char *default_machine_firmware); -target_ulong riscv_load_firmware(const char *firmware_filename, - hwaddr *firmware_load_addr, - symbol_fn_t sym_cb); +hwaddr riscv_load_firmware(const char *firmware_filename, + hwaddr *firmware_load_addr, + symbol_fn_t sym_cb); void riscv_load_kernel(MachineState *machine, RISCVBootInfo *info, - target_ulong kernel_start_addr, + hwaddr kernel_start_addr, bool load_initrd, symbol_fn_t sym_cb); uint64_t riscv_compute_fdt_addr(hwaddr dram_base, hwaddr dram_size, diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c index 828a867be3..4eadcff26c 100644 --- a/hw/riscv/boot.c +++ b/hw/riscv/boot.c @@ -74,8 +74,8 @@ void riscv_boot_info_init(RISCVBootInfo *info, RISCVHartArrayState *harts) info->is_32bit = riscv_is_32bit(harts); } -target_ulong riscv_calc_kernel_start_addr(RISCVBootInfo *info, - target_ulong firmware_end_addr) { +hwaddr riscv_calc_kernel_start_addr(RISCVBootInfo *info, + hwaddr firmware_end_addr) { if (info->is_32bit) { return QEMU_ALIGN_UP(firmware_end_addr, 4 * MiB); } else { @@ -133,13 +133,13 @@ char *riscv_find_firmware(const char *firmware_filename, return filename; } -target_ulong riscv_find_and_load_firmware(MachineState *machine, - const char *default_machine_firmware, - hwaddr *firmware_load_addr, - symbol_fn_t sym_cb) +hwaddr riscv_find_and_load_firmware(MachineState *machine, + const char *default_machine_firmware, + hwaddr *firmware_load_addr, + symbol_fn_t sym_cb) { char *firmware_filename; - target_ulong firmware_end_addr = *firmware_load_addr; + hwaddr firmware_end_addr = *firmware_load_addr; firmware_filename = riscv_find_firmware(machine->firmware, default_machine_firmware); @@ -154,9 +154,9 @@ target_ulong riscv_find_and_load_firmware(MachineState *machine, return firmware_end_addr; } -target_ulong riscv_load_firmware(const char *firmware_filename, - hwaddr *firmware_load_addr, - symbol_fn_t sym_cb) +hwaddr riscv_load_firmware(const char *firmware_filename, + hwaddr *firmware_load_addr, + symbol_fn_t sym_cb) { uint64_t firmware_entry, firmware_end; ssize_t firmware_size; @@ -227,7 +227,7 @@ static void riscv_load_initrd(MachineState *machine, RISCVBootInfo *info) void riscv_load_kernel(MachineState *machine, RISCVBootInfo *info, - target_ulong kernel_start_addr, + hwaddr kernel_start_addr, bool load_initrd, symbol_fn_t sym_cb) { diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c index 2e74783fce..e5a0196a00 100644 --- a/hw/riscv/microchip_pfsoc.c +++ b/hw/riscv/microchip_pfsoc.c @@ -515,7 +515,7 @@ static void microchip_icicle_kit_machine_init(MachineState *machine) uint64_t mem_low_size, mem_high_size; hwaddr firmware_load_addr; const char *firmware_name; - target_ulong firmware_end_addr, kernel_start_addr; + hwaddr firmware_end_addr, kernel_start_addr; uint64_t kernel_entry; uint64_t fdt_load_addr; DriveInfo *dinfo = drive_get(IF_SD, 0, 0); diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index d69f942cfb..390f9b8d9a 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -515,7 +515,7 @@ static void sifive_u_machine_init(MachineState *machine) MemoryRegion *system_memory = get_system_memory(); MemoryRegion *flash0 = g_new(MemoryRegion, 1); hwaddr start_addr = memmap[SIFIVE_U_DEV_DRAM].base; - target_ulong firmware_end_addr, kernel_start_addr; + hwaddr firmware_end_addr, kernel_start_addr; const char *firmware_name; uint32_t start_addr_hi32 = 0x00000000; uint32_t fdt_load_addr_hi32 = 0x00000000; diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c index 641aae8c01..b0bab3fe00 100644 --- a/hw/riscv/spike.c +++ b/hw/riscv/spike.c @@ -197,9 +197,9 @@ static void spike_board_init(MachineState *machine) SpikeState *s = SPIKE_MACHINE(machine); MemoryRegion *system_memory = get_system_memory(); MemoryRegion *mask_rom = g_new(MemoryRegion, 1); - target_ulong firmware_end_addr = memmap[SPIKE_DRAM].base; + hwaddr firmware_end_addr = memmap[SPIKE_DRAM].base; hwaddr firmware_load_addr = memmap[SPIKE_DRAM].base; - target_ulong kernel_start_addr; + hwaddr kernel_start_addr; char *firmware_name; uint64_t fdt_load_addr; uint64_t kernel_entry; diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 47e573f85a..17909206c7 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -1434,7 +1434,7 @@ static void virt_machine_done(Notifier *notifier, void *data) machine_done); MachineState *machine = MACHINE(s); hwaddr start_addr = s->memmap[VIRT_DRAM].base; - target_ulong firmware_end_addr, kernel_start_addr; + hwaddr firmware_end_addr, kernel_start_addr; const char *firmware_name = riscv_default_firmware_name(&s->soc[0]); uint64_t fdt_load_addr; uint64_t kernel_entry = 0; -- 2.51.0 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/3] hw/riscv: Use generic hwaddr for firmware addressses 2025-10-27 12:35 ` [PATCH v2 1/3] hw/riscv: Use generic hwaddr for firmware addressses Anton Johansson via @ 2025-10-27 12:39 ` Philippe Mathieu-Daudé 2025-10-27 18:13 ` Anton Johansson via 0 siblings, 1 reply; 11+ messages in thread From: Philippe Mathieu-Daudé @ 2025-10-27 12:39 UTC (permalink / raw) To: Anton Johansson, qemu-devel Cc: pierrick.bouvier, alistair.francis, richard.henderson, palmer Typo addres[s]ses ;) On 27/10/25 13:35, Anton Johansson wrote: > Signed-off-by: Anton Johansson <anjo@rev.ng> > --- > include/hw/riscv/boot.h | 20 ++++++++++---------- > hw/riscv/boot.c | 22 +++++++++++----------- > hw/riscv/microchip_pfsoc.c | 2 +- > hw/riscv/sifive_u.c | 2 +- > hw/riscv/spike.c | 4 ++-- > hw/riscv/virt.c | 2 +- > 6 files changed, 26 insertions(+), 26 deletions(-) > > diff --git a/include/hw/riscv/boot.h b/include/hw/riscv/boot.h > index 7d59b2e6c6..d835594baa 100644 > --- a/include/hw/riscv/boot.h > +++ b/include/hw/riscv/boot.h > @@ -43,21 +43,21 @@ bool riscv_is_32bit(RISCVHartArrayState *harts); > char *riscv_plic_hart_config_string(int hart_count); > > void riscv_boot_info_init(RISCVBootInfo *info, RISCVHartArrayState *harts); > -target_ulong riscv_calc_kernel_start_addr(RISCVBootInfo *info, > - target_ulong firmware_end_addr); > -target_ulong riscv_find_and_load_firmware(MachineState *machine, > - const char *default_machine_firmware, > - hwaddr *firmware_load_addr, > - symbol_fn_t sym_cb); > +hwaddr riscv_calc_kernel_start_addr(RISCVBootInfo *info, > + hwaddr firmware_end_addr); > +hwaddr riscv_find_and_load_firmware(MachineState *machine, > + const char *default_machine_firmware, > + hwaddr *firmware_load_addr, > + symbol_fn_t sym_cb); > const char *riscv_default_firmware_name(RISCVHartArrayState *harts); > char *riscv_find_firmware(const char *firmware_filename, > const char *default_machine_firmware); > -target_ulong riscv_load_firmware(const char *firmware_filename, > - hwaddr *firmware_load_addr, > - symbol_fn_t sym_cb); > +hwaddr riscv_load_firmware(const char *firmware_filename, > + hwaddr *firmware_load_addr, > + symbol_fn_t sym_cb); OK up to here, > void riscv_load_kernel(MachineState *machine, > RISCVBootInfo *info, > - target_ulong kernel_start_addr, > + hwaddr kernel_start_addr, but can we have this single change in a distinct patch please, so we can better describe it than "firmware address" and it doesn't block the rest? > bool load_initrd, > symbol_fn_t sym_cb); ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/3] hw/riscv: Use generic hwaddr for firmware addressses 2025-10-27 12:39 ` Philippe Mathieu-Daudé @ 2025-10-27 18:13 ` Anton Johansson via 0 siblings, 0 replies; 11+ messages in thread From: Anton Johansson via @ 2025-10-27 18:13 UTC (permalink / raw) To: Philippe Mathieu-Daudé Cc: qemu-devel, pierrick.bouvier, alistair.francis, richard.henderson, palmer On 27/10/25, Philippe Mathieu-Daudé wrote: > Typo addres[s]ses ;) Ah dang! [...] > > void riscv_load_kernel(MachineState *machine, > > RISCVBootInfo *info, > > - target_ulong kernel_start_addr, > > + hwaddr kernel_start_addr, > > but can we have this single change in a distinct patch please, > so we can better describe it than "firmware address" and it > doesn't block the rest? Of course will do, thanks! ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 2/3] hw/riscv: Replace target_ulong uses 2025-10-27 12:35 [PATCH v2 0/3] single-binary: Prepare hw/riscv for single compilation Anton Johansson via 2025-10-27 12:35 ` [PATCH v2 1/3] hw/riscv: Use generic hwaddr for firmware addressses Anton Johansson via @ 2025-10-27 12:35 ` Anton Johansson via 2025-10-29 18:01 ` Philippe Mathieu-Daudé 2025-10-30 4:10 ` Alistair Francis 2025-10-27 12:35 ` [PATCH v2 3/3] hw/riscv: Widen OpenSBI dynamic info struct Anton Johansson via 2025-10-28 7:25 ` [PATCH v2 0/3] single-binary: Prepare hw/riscv for single compilation Philippe Mathieu-Daudé 3 siblings, 2 replies; 11+ messages in thread From: Anton Johansson via @ 2025-10-27 12:35 UTC (permalink / raw) To: qemu-devel Cc: pierrick.bouvier, philmd, alistair.francis, richard.henderson, palmer Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Anton Johansson <anjo@rev.ng> --- hw/riscv/riscv-iommu.c | 6 ++++-- hw/riscv/riscv_hart.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/riscv/riscv-iommu.c b/hw/riscv/riscv-iommu.c index b33c7fe325..f8656ec04b 100644 --- a/hw/riscv/riscv-iommu.c +++ b/hw/riscv/riscv-iommu.c @@ -26,6 +26,8 @@ #include "migration/vmstate.h" #include "qapi/error.h" #include "qemu/timer.h" +#include "qemu/target-info.h" +#include "qemu/bitops.h" #include "cpu_bits.h" #include "riscv-iommu.h" @@ -391,9 +393,9 @@ static int riscv_iommu_spa_fetch(RISCVIOMMUState *s, RISCVIOMMUContext *ctx, const uint64_t va_mask = (1ULL << va_len) - 1; if (pass == S_STAGE && va_len > 32) { - target_ulong mask, masked_msbs; + uint64_t mask, masked_msbs; - mask = (1L << (TARGET_LONG_BITS - (va_len - 1))) - 1; + mask = MAKE_64BIT_MASK(0, target_long_bits() - va_len + 1); masked_msbs = (addr >> (va_len - 1)) & mask; if (masked_msbs != 0 && masked_msbs != mask) { diff --git a/hw/riscv/riscv_hart.c b/hw/riscv/riscv_hart.c index c7e98a4308..65d2c92018 100644 --- a/hw/riscv/riscv_hart.c +++ b/hw/riscv/riscv_hart.c @@ -93,7 +93,7 @@ static bool csr_qtest_callback(CharBackend *chr, gchar **words) g_assert(rc == 0); csr_call(words[1], cpu, csr, &val); - qtest_sendf(chr, "OK 0 "TARGET_FMT_lx"\n", (target_ulong)val); + qtest_sendf(chr, "OK 0 %"PRIx64"\n", val); return true; } -- 2.51.0 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2 2/3] hw/riscv: Replace target_ulong uses 2025-10-27 12:35 ` [PATCH v2 2/3] hw/riscv: Replace target_ulong uses Anton Johansson via @ 2025-10-29 18:01 ` Philippe Mathieu-Daudé 2025-10-30 4:10 ` Alistair Francis 1 sibling, 0 replies; 11+ messages in thread From: Philippe Mathieu-Daudé @ 2025-10-29 18:01 UTC (permalink / raw) To: Anton Johansson, qemu-devel Cc: pierrick.bouvier, alistair.francis, richard.henderson, palmer On 27/10/25 13:35, Anton Johansson wrote: > Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> > Signed-off-by: Anton Johansson <anjo@rev.ng> > --- > hw/riscv/riscv-iommu.c | 6 ++++-- > hw/riscv/riscv_hart.c | 2 +- > 2 files changed, 5 insertions(+), 3 deletions(-) > > diff --git a/hw/riscv/riscv-iommu.c b/hw/riscv/riscv-iommu.c > index b33c7fe325..f8656ec04b 100644 > --- a/hw/riscv/riscv-iommu.c > +++ b/hw/riscv/riscv-iommu.c > @@ -26,6 +26,8 @@ > #include "migration/vmstate.h" > #include "qapi/error.h" > #include "qemu/timer.h" > +#include "qemu/target-info.h" > +#include "qemu/bitops.h" > > #include "cpu_bits.h" > #include "riscv-iommu.h" > @@ -391,9 +393,9 @@ static int riscv_iommu_spa_fetch(RISCVIOMMUState *s, RISCVIOMMUContext *ctx, > const uint64_t va_mask = (1ULL << va_len) - 1; > > if (pass == S_STAGE && va_len > 32) { > - target_ulong mask, masked_msbs; > + uint64_t mask, masked_msbs; > > - mask = (1L << (TARGET_LONG_BITS - (va_len - 1))) - 1; > + mask = MAKE_64BIT_MASK(0, target_long_bits() - va_len + 1); > masked_msbs = (addr >> (va_len - 1)) & mask; > > if (masked_msbs != 0 && masked_msbs != mask) { > diff --git a/hw/riscv/riscv_hart.c b/hw/riscv/riscv_hart.c > index c7e98a4308..65d2c92018 100644 > --- a/hw/riscv/riscv_hart.c > +++ b/hw/riscv/riscv_hart.c > @@ -93,7 +93,7 @@ static bool csr_qtest_callback(CharBackend *chr, gchar **words) > g_assert(rc == 0); > csr_call(words[1], cpu, csr, &val); > > - qtest_sendf(chr, "OK 0 "TARGET_FMT_lx"\n", (target_ulong)val); > + qtest_sendf(chr, "OK 0 %"PRIx64"\n", val); > > return true; > } > What about csr_call()? ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 2/3] hw/riscv: Replace target_ulong uses 2025-10-27 12:35 ` [PATCH v2 2/3] hw/riscv: Replace target_ulong uses Anton Johansson via 2025-10-29 18:01 ` Philippe Mathieu-Daudé @ 2025-10-30 4:10 ` Alistair Francis 1 sibling, 0 replies; 11+ messages in thread From: Alistair Francis @ 2025-10-30 4:10 UTC (permalink / raw) To: Anton Johansson Cc: qemu-devel, pierrick.bouvier, philmd, alistair.francis, richard.henderson, palmer On Mon, Oct 27, 2025 at 10:35 PM Anton Johansson via <qemu-devel@nongnu.org> wrote: > > Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> > Signed-off-by: Anton Johansson <anjo@rev.ng> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Alistair > --- > hw/riscv/riscv-iommu.c | 6 ++++-- > hw/riscv/riscv_hart.c | 2 +- > 2 files changed, 5 insertions(+), 3 deletions(-) > > diff --git a/hw/riscv/riscv-iommu.c b/hw/riscv/riscv-iommu.c > index b33c7fe325..f8656ec04b 100644 > --- a/hw/riscv/riscv-iommu.c > +++ b/hw/riscv/riscv-iommu.c > @@ -26,6 +26,8 @@ > #include "migration/vmstate.h" > #include "qapi/error.h" > #include "qemu/timer.h" > +#include "qemu/target-info.h" > +#include "qemu/bitops.h" > > #include "cpu_bits.h" > #include "riscv-iommu.h" > @@ -391,9 +393,9 @@ static int riscv_iommu_spa_fetch(RISCVIOMMUState *s, RISCVIOMMUContext *ctx, > const uint64_t va_mask = (1ULL << va_len) - 1; > > if (pass == S_STAGE && va_len > 32) { > - target_ulong mask, masked_msbs; > + uint64_t mask, masked_msbs; > > - mask = (1L << (TARGET_LONG_BITS - (va_len - 1))) - 1; > + mask = MAKE_64BIT_MASK(0, target_long_bits() - va_len + 1); > masked_msbs = (addr >> (va_len - 1)) & mask; > > if (masked_msbs != 0 && masked_msbs != mask) { > diff --git a/hw/riscv/riscv_hart.c b/hw/riscv/riscv_hart.c > index c7e98a4308..65d2c92018 100644 > --- a/hw/riscv/riscv_hart.c > +++ b/hw/riscv/riscv_hart.c > @@ -93,7 +93,7 @@ static bool csr_qtest_callback(CharBackend *chr, gchar **words) > g_assert(rc == 0); > csr_call(words[1], cpu, csr, &val); > > - qtest_sendf(chr, "OK 0 "TARGET_FMT_lx"\n", (target_ulong)val); > + qtest_sendf(chr, "OK 0 %"PRIx64"\n", val); > > return true; > } > > -- > 2.51.0 > > ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 3/3] hw/riscv: Widen OpenSBI dynamic info struct 2025-10-27 12:35 [PATCH v2 0/3] single-binary: Prepare hw/riscv for single compilation Anton Johansson via 2025-10-27 12:35 ` [PATCH v2 1/3] hw/riscv: Use generic hwaddr for firmware addressses Anton Johansson via 2025-10-27 12:35 ` [PATCH v2 2/3] hw/riscv: Replace target_ulong uses Anton Johansson via @ 2025-10-27 12:35 ` Anton Johansson via 2025-10-27 12:42 ` Philippe Mathieu-Daudé 2025-10-28 7:25 ` [PATCH v2 0/3] single-binary: Prepare hw/riscv for single compilation Philippe Mathieu-Daudé 3 siblings, 1 reply; 11+ messages in thread From: Anton Johansson via @ 2025-10-27 12:35 UTC (permalink / raw) To: qemu-devel Cc: pierrick.bouvier, philmd, alistair.francis, richard.henderson, palmer 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. Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Anton Johansson <anjo@rev.ng> --- 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 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2 3/3] hw/riscv: Widen OpenSBI dynamic info struct 2025-10-27 12:35 ` [PATCH v2 3/3] hw/riscv: Widen OpenSBI dynamic info struct Anton Johansson via @ 2025-10-27 12:42 ` Philippe Mathieu-Daudé 0 siblings, 0 replies; 11+ messages in thread From: Philippe Mathieu-Daudé @ 2025-10-27 12:42 UTC (permalink / raw) To: Anton Johansson, qemu-devel Cc: pierrick.bouvier, alistair.francis, richard.henderson, palmer On 27/10/25 13:35, Anton Johansson 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. > > Reviewed-by: Alistair Francis <alistair.francis@wdc.com> > Signed-off-by: Anton Johansson <anjo@rev.ng> > --- > 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; I wonder why some of these fields are signed; but this is pre-existing, so for this patch: Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> > /** 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; > }; ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 0/3] single-binary: Prepare hw/riscv for single compilation 2025-10-27 12:35 [PATCH v2 0/3] single-binary: Prepare hw/riscv for single compilation Anton Johansson via ` (2 preceding siblings ...) 2025-10-27 12:35 ` [PATCH v2 3/3] hw/riscv: Widen OpenSBI dynamic info struct Anton Johansson via @ 2025-10-28 7:25 ` Philippe Mathieu-Daudé 2025-10-29 21:56 ` Philippe Mathieu-Daudé 3 siblings, 1 reply; 11+ messages in thread From: Philippe Mathieu-Daudé @ 2025-10-28 7:25 UTC (permalink / raw) To: Anton Johansson, qemu-devel Cc: pierrick.bouvier, alistair.francis, richard.henderson, palmer On 27/10/25 13:35, Anton Johansson wrote: > Anton Johansson (3): > hw/riscv: Use generic hwaddr for firmware addressses > hw/riscv: Widen OpenSBI dynamic info struct Queuing patches #1 (without kernel hwaddr change) and #3, thanks! ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 0/3] single-binary: Prepare hw/riscv for single compilation 2025-10-28 7:25 ` [PATCH v2 0/3] single-binary: Prepare hw/riscv for single compilation Philippe Mathieu-Daudé @ 2025-10-29 21:56 ` Philippe Mathieu-Daudé 0 siblings, 0 replies; 11+ messages in thread From: Philippe Mathieu-Daudé @ 2025-10-29 21:56 UTC (permalink / raw) To: Anton Johansson, qemu-devel Cc: pierrick.bouvier, alistair.francis, richard.henderson, palmer On 28/10/25 08:25, Philippe Mathieu-Daudé wrote: > On 27/10/25 13:35, Anton Johansson wrote: > >> Anton Johansson (3): >> hw/riscv: Use generic hwaddr for firmware addressses > >> hw/riscv: Widen OpenSBI dynamic info struct > > Queuing patches #1 (without kernel hwaddr change) and #3, thanks! And now #2 also queued. ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2025-10-30 4:12 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-10-27 12:35 [PATCH v2 0/3] single-binary: Prepare hw/riscv for single compilation Anton Johansson via 2025-10-27 12:35 ` [PATCH v2 1/3] hw/riscv: Use generic hwaddr for firmware addressses Anton Johansson via 2025-10-27 12:39 ` Philippe Mathieu-Daudé 2025-10-27 18:13 ` Anton Johansson via 2025-10-27 12:35 ` [PATCH v2 2/3] hw/riscv: Replace target_ulong uses Anton Johansson via 2025-10-29 18:01 ` Philippe Mathieu-Daudé 2025-10-30 4:10 ` Alistair Francis 2025-10-27 12:35 ` [PATCH v2 3/3] hw/riscv: Widen OpenSBI dynamic info struct Anton Johansson via 2025-10-27 12:42 ` Philippe Mathieu-Daudé 2025-10-28 7:25 ` [PATCH v2 0/3] single-binary: Prepare hw/riscv for single compilation Philippe Mathieu-Daudé 2025-10-29 21:56 ` Philippe Mathieu-Daudé
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).