QEMU-Arm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Bin Meng <bin.meng@processmission.com>
To: QEMU <qemu-devel@nongnu.org>
Cc: Peter Maydell <peter.maydell@linaro.org>, qemu-arm@nongnu.org
Subject: [PATCH v2 17/20] hw/arm: realview: Store boot info in the machine state
Date: Sun, 16 Aug 2026 21:12:47 +0800	[thread overview]
Message-ID: <20260816131300.51799-18-bin.meng@processmission.com> (raw)
In-Reply-To: <20260816131300.51799-1-bin.meng@processmission.com>

arm_load_kernel() keeps a pointer to the boot info struct for the
lifetime of the VM, so the struct logically belongs to the machine
rather than to a file scoped static object.

Give all four realview machine types the same RealViewMachineState
instance struct and store the boot info there.

As in the xlnx-zcu102 and raspi machines, the boot info belongs to
the machine rather than to a static object:

4d1ac883a7 ("hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102")
0f15c6e338 ("hw/arm/raspi: Move arm_boot_info structure to RaspiMachineState")

Signed-off-by: Bin Meng <bin.meng@processmission.com>
---

 hw/arm/realview.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/hw/arm/realview.c b/hw/arm/realview.c
index 2b9f3271d6..0c2daf5c01 100644
--- a/hw/arm/realview.c
+++ b/hw/arm/realview.c
@@ -39,10 +39,11 @@
 
 /* Board init.  */
 
-static struct arm_boot_info realview_binfo = {
-    .smp_loader_start = SMP_BOOT_ADDR,
-    .smp_bootreg_addr = SMP_BOOTREG_ADDR,
-};
+typedef struct RealViewMachineState {
+    MachineState parent;
+
+    struct arm_boot_info bootinfo;
+} RealViewMachineState;
 
 /* The following two lists must be consistent.  */
 enum realview_board_type {
@@ -76,6 +77,8 @@ static void split_irq_from_named(DeviceState *src, const char* outname,
 static void realview_init(MachineState *machine,
                           enum realview_board_type board_type)
 {
+    /* All realview-* machines embed the same state as their first member */
+    RealViewMachineState *rvms = (RealViewMachineState *)machine;
     ARMCPU *cpu = NULL;
     CPUARMState *env;
     MemoryRegion *sysmem = get_system_memory();
@@ -202,7 +205,7 @@ static void realview_init(MachineState *machine,
         }
         sysbus_create_varargs("l2x0", periphbase + 0x2000, NULL);
         /* Both A9 and 11MPCore put the GIC CPU i/f at base + 0x100 */
-        realview_binfo.gic_cpu_if_addr = periphbase + 0x100;
+        rvms->bootinfo.gic_cpu_if_addr = periphbase + 0x100;
     } else {
         uint32_t gic_addr = is_pb ? 0x1e000000 : 0x10040000;
         /* For now just create the nIRQ GIC, and ignore the others.  */
@@ -387,10 +390,12 @@ static void realview_init(MachineState *machine,
                            &error_fatal);
     memory_region_add_subregion(sysmem, SMP_BOOT_ADDR, ram_hack);
 
-    realview_binfo.ram_size = ram_size;
-    realview_binfo.board_id = realview_board_id[board_type];
-    realview_binfo.loader_start = (board_type == BOARD_PB_A8 ? 0x70000000 : 0);
-    arm_load_kernel(cpu, machine, &realview_binfo);
+    rvms->bootinfo.smp_loader_start = SMP_BOOT_ADDR;
+    rvms->bootinfo.smp_bootreg_addr = SMP_BOOTREG_ADDR;
+    rvms->bootinfo.ram_size = ram_size;
+    rvms->bootinfo.board_id = realview_board_id[board_type];
+    rvms->bootinfo.loader_start = board_type == BOARD_PB_A8 ? 0x70000000 : 0;
+    arm_load_kernel(cpu, machine, &rvms->bootinfo);
 }
 
 static void realview_eb_init(MachineState *machine)
@@ -431,6 +436,7 @@ static const TypeInfo realview_eb_type = {
     .name = MACHINE_TYPE_NAME("realview-eb"),
     .parent = TYPE_MACHINE,
     .class_init = realview_eb_class_init,
+    .instance_size = sizeof(RealViewMachineState),
     .interfaces = arm_machine_interfaces,
 };
 
@@ -453,6 +459,7 @@ static const TypeInfo realview_eb_mpcore_type = {
     .name = MACHINE_TYPE_NAME("realview-eb-mpcore"),
     .parent = TYPE_MACHINE,
     .class_init = realview_eb_mpcore_class_init,
+    .instance_size = sizeof(RealViewMachineState),
     .interfaces = arm_machine_interfaces,
 };
 
@@ -473,6 +480,7 @@ static const TypeInfo realview_pb_a8_type = {
     .name = MACHINE_TYPE_NAME("realview-pb-a8"),
     .parent = TYPE_MACHINE,
     .class_init = realview_pb_a8_class_init,
+    .instance_size = sizeof(RealViewMachineState),
     .interfaces = arm_machine_interfaces,
 };
 
@@ -494,6 +502,7 @@ static const TypeInfo realview_pbx_a9_type = {
     .name = MACHINE_TYPE_NAME("realview-pbx-a9"),
     .parent = TYPE_MACHINE,
     .class_init = realview_pbx_a9_class_init,
+    .instance_size = sizeof(RealViewMachineState),
     .interfaces = arm_machine_interfaces,
 };
 
-- 
2.53.0



  parent reply	other threads:[~2026-08-16 13:16 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-16 13:12 [PATCH v2 00/20] hw/arm: Store the ARM boot info in the machine state Bin Meng
2026-08-16 13:12 ` [PATCH v2 01/20] hw/arm: aspeed: Store " Bin Meng
2026-08-16 14:54   ` Philippe Mathieu-Daudé
2026-08-21  9:23     ` Peter Maydell
2026-08-16 13:12 ` [PATCH v2 02/20] hw/arm: aspeed_ast27x0-fc: " Bin Meng
2026-08-16 14:55   ` Philippe Mathieu-Daudé
2026-08-16 13:12 ` [PATCH v2 03/20] hw/arm: bananapi_m2u: " Bin Meng
2026-08-16 13:12 ` [PATCH v2 04/20] hw/arm: collie: " Bin Meng
2026-08-16 13:12 ` [PATCH v2 05/20] hw/arm: cubieboard: " Bin Meng
2026-08-16 13:12 ` [PATCH v2 06/20] hw/arm: exynos4_boards: Store boot info in the board state Bin Meng
2026-08-16 14:56   ` Philippe Mathieu-Daudé
2026-08-16 13:12 ` [PATCH v2 07/20] hw/arm: imx25_pdk: " Bin Meng
2026-08-16 13:12 ` [PATCH v2 08/20] hw/arm: imx8mm-evk: Store boot info in the machine state Bin Meng
2026-08-16 13:12 ` [PATCH v2 09/20] hw/arm: integratorcp: " Bin Meng
2026-08-16 13:12 ` [PATCH v2 10/20] hw/arm: kzm: Store boot info in the board state Bin Meng
2026-08-16 13:12 ` [PATCH v2 11/20] hw/arm: mcimx7d-sabre: Store boot info in the machine state Bin Meng
2026-08-16 13:12 ` [PATCH v2 12/20] hw/arm: musicpal: " Bin Meng
2026-08-16 13:12 ` [PATCH v2 13/20] hw/arm: npcm7xx: " Bin Meng
2026-08-16 13:12 ` [PATCH v2 14/20] hw/arm: npcm8xx: " Bin Meng
2026-08-16 13:12 ` [PATCH v2 15/20] hw/arm: omap_sx1: " Bin Meng
2026-08-16 14:57   ` Philippe Mathieu-Daudé
2026-08-16 13:12 ` [PATCH v2 16/20] hw/arm: orangepi: " Bin Meng
2026-08-16 13:12 ` Bin Meng [this message]
2026-08-16 13:12 ` [PATCH v2 18/20] hw/arm: sabrelite: " Bin Meng
2026-08-16 15:07   ` Philippe Mathieu-Daudé
2026-08-16 13:12 ` [PATCH v2 19/20] hw/arm: versatilepb: " Bin Meng
2026-08-16 15:06   ` Philippe Mathieu-Daudé
2026-08-21  9:49     ` Peter Maydell
2026-08-16 13:12 ` [PATCH v2 20/20] hw/arm: xilinx_zynq: " Bin Meng
2026-08-21  9:49 ` [PATCH v2 00/20] hw/arm: Store the ARM " Peter Maydell

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=20260816131300.51799-18-bin.meng@processmission.com \
    --to=bin.meng@processmission.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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