From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Anton Johansson" <anjo@rev.ng>,
"Alistair Francis" <alistair.francis@wdc.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Weiwei Li" <liwei1518@gmail.com>,
"Daniel Henrique Barboza" <dbarboza@ventanamicro.com>,
"Liu Zhiwei" <zhiwei_liu@linux.alibaba.com>,
qemu-riscv@nongnu.org
Subject: [PULL 23/23] hw/riscv: Widen OpenSBI dynamic info struct
Date: Tue, 28 Oct 2025 08:48:59 +0100 [thread overview]
Message-ID: <20251028074901.22062-24-philmd@linaro.org> (raw)
In-Reply-To: <20251028074901.22062-1-philmd@linaro.org>
From: Anton Johansson <anjo@rev.ng>
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>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20251027-feature-single-binary-hw-v1-v2-3-44478d589ae9@rev.ng>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
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 18664a174b5..ab9999be3f7 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 9510fca939b..75f34287ff1 100644
--- a/hw/riscv/boot.c
+++ b/hw/riscv/boot.c
@@ -388,7 +388,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)) {
@@ -398,15 +399,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);
}
/**
@@ -420,8 +423,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
next prev parent reply other threads:[~2025-10-28 7:57 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-28 7:48 [PULL 00/23] Misc HW patches for 2025-10-28 Philippe Mathieu-Daudé
2025-10-28 7:48 ` [PULL 01/23] target/hppa: Set FPCR exception flag bits for non-trapped exceptions Philippe Mathieu-Daudé
2025-10-28 7:48 ` [PULL 02/23] qom: remove redundant typedef when use OBJECT_DECLARE_SIMPLE_TYPE Philippe Mathieu-Daudé
2025-10-28 7:48 ` [PULL 03/23] hw/net/virtio-net: make VirtIONet.vlans an array instead of a pointer Philippe Mathieu-Daudé
2025-12-09 12:15 ` Fiona Ebner
2025-12-09 20:07 ` Philippe Mathieu-Daudé
2025-10-28 7:48 ` [PULL 04/23] migration/vmstate: remove VMSTATE_BUFFER_POINTER_UNSAFE macro Philippe Mathieu-Daudé
2025-10-28 7:48 ` [PULL 05/23] hw/pci-host/raven: Simplify creating PCI facing part Philippe Mathieu-Daudé
2025-10-28 7:48 ` [PULL 06/23] hw/pci-host/raven: Simplify " Philippe Mathieu-Daudé
2025-10-28 7:48 ` [PULL 07/23] hw/pci-host/raven: Simplify host bridge type declaration Philippe Mathieu-Daudé
2025-10-28 7:48 ` [PULL 08/23] hw/pci-host/raven: Use DEFINE_TYPES macro Philippe Mathieu-Daudé
2025-10-28 7:48 ` [PULL 09/23] hw/pci-host/raven: Simplify PCI bus creation Philippe Mathieu-Daudé
2025-10-28 7:48 ` [PULL 10/23] hw/qdev: Have qdev_get_gpio_out_connector() take const DeviceState arg Philippe Mathieu-Daudé
2025-10-28 7:48 ` [PULL 11/23] hw/sysbus: Have various helpers take a const SysBusDevice argument Philippe Mathieu-Daudé
2025-10-28 7:48 ` [PULL 12/23] hw/uefi: Include missing 'system/memory.h' header Philippe Mathieu-Daudé
2025-10-28 7:48 ` [PULL 13/23] hw/int/loongarch: " Philippe Mathieu-Daudé
2025-10-28 7:48 ` [PULL 14/23] hw/core/loader: Use qemu_open() instead of open() in get_image_size() Philippe Mathieu-Daudé
2025-10-28 7:48 ` [PULL 15/23] hw/core/loader: capture Error from load_image_targphys Philippe Mathieu-Daudé
2025-10-28 7:48 ` [PULL 16/23] hw/core/loader: improve error handling in image loading functions Philippe Mathieu-Daudé
2025-10-28 7:48 ` [PULL 17/23] hw/core/loader: add check for zero size in load_image_targphys_as Philippe Mathieu-Daudé
2025-10-28 7:48 ` [PULL 18/23] hw/core/loader: Pass errp to load_image_targphys_as() Philippe Mathieu-Daudé
2025-10-28 7:48 ` [PULL 19/23] hw/ppc: Pass error_fatal to load_image_targphys() Philippe Mathieu-Daudé
2025-10-28 7:48 ` [PULL 20/23] nw/nvram/ds1225y: Fix nvram MemoryRegion owner Philippe Mathieu-Daudé
2025-10-28 7:48 ` [PULL 21/23] hw/i386/intel_iommu: Remove an unused state field Philippe Mathieu-Daudé
2025-10-28 7:48 ` [PULL 22/23] hw/riscv: Use generic hwaddr for firmware addresses Philippe Mathieu-Daudé
2025-10-28 7:48 ` Philippe Mathieu-Daudé [this message]
2025-10-28 12:12 ` [PULL 00/23] Misc HW patches for 2025-10-28 Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251028074901.22062-24-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=alistair.francis@wdc.com \
--cc=anjo@rev.ng \
--cc=dbarboza@ventanamicro.com \
--cc=liwei1518@gmail.com \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=zhiwei_liu@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).