@samitouri / QOSamiQemu / commits / 42a64af521

hw/arm: realview: Store boot info in the machine state

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> Message-id: 20260816131300.51799-18-bin.meng@processmission.com Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Bin Meng committed Aug 16, 2026 at 21:12 UTC 42a64af521af89eac0272d6705b251c1b3fbf719
1 file changed +18 -9
hw/arm/realview.c
+18 -9
@@ -39,10 +39,11 @@
39
40 /* Board init. */
41
42 -static struct arm_boot_info realview_binfo = {
43 - .smp_loader_start = SMP_BOOT_ADDR,
44 - .smp_bootreg_addr = SMP_BOOTREG_ADDR,
45 -};
42 +typedef struct RealViewMachineState {
43 + MachineState parent;
44 +
45 + struct arm_boot_info bootinfo;
46 +} RealViewMachineState;
47
48 /* The following two lists must be consistent. */
49 enum realview_board_type {
@@ -76,6 +77,8 @@ static void split_irq_from_named(DeviceState *src, const char* outname,
77 static void realview_init(MachineState *machine,
78 enum realview_board_type board_type)
79 {
80 + /* All realview-* machines embed the same state as their first member */
81 + RealViewMachineState *rvms = (RealViewMachineState *)machine;
82 ARMCPU *cpu = NULL;
83 CPUARMState *env;
84 MemoryRegion *sysmem = get_system_memory();
@@ -202,7 +205,7 @@ static void realview_init(MachineState *machine,
205 }
206 sysbus_create_varargs("l2x0", periphbase + 0x2000, NULL);
207 /* Both A9 and 11MPCore put the GIC CPU i/f at base + 0x100 */
205 - realview_binfo.gic_cpu_if_addr = periphbase + 0x100;
208 + rvms->bootinfo.gic_cpu_if_addr = periphbase + 0x100;
209 } else {
210 uint32_t gic_addr = is_pb ? 0x1e000000 : 0x10040000;
211 /* For now just create the nIRQ GIC, and ignore the others. */
@@ -387,10 +390,12 @@ static void realview_init(MachineState *machine,
390 &error_fatal);
391 memory_region_add_subregion(sysmem, SMP_BOOT_ADDR, ram_hack);
392
390 - realview_binfo.ram_size = ram_size;
391 - realview_binfo.board_id = realview_board_id[board_type];
392 - realview_binfo.loader_start = (board_type == BOARD_PB_A8 ? 0x70000000 : 0);
393 - arm_load_kernel(cpu, machine, &realview_binfo);
393 + rvms->bootinfo.smp_loader_start = SMP_BOOT_ADDR;
394 + rvms->bootinfo.smp_bootreg_addr = SMP_BOOTREG_ADDR;
395 + rvms->bootinfo.ram_size = ram_size;
396 + rvms->bootinfo.board_id = realview_board_id[board_type];
397 + rvms->bootinfo.loader_start = board_type == BOARD_PB_A8 ? 0x70000000 : 0;
398 + arm_load_kernel(cpu, machine, &rvms->bootinfo);
399 }
400
401 static void realview_eb_init(MachineState *machine)
@@ -431,6 +436,7 @@ static const TypeInfo realview_eb_type = {
436 .name = MACHINE_TYPE_NAME("realview-eb"),
437 .parent = TYPE_MACHINE,
438 .class_init = realview_eb_class_init,
439 + .instance_size = sizeof(RealViewMachineState),
440 .interfaces = arm_machine_interfaces,
441 };
442
@@ -453,6 +459,7 @@ static const TypeInfo realview_eb_mpcore_type = {
459 .name = MACHINE_TYPE_NAME("realview-eb-mpcore"),
460 .parent = TYPE_MACHINE,
461 .class_init = realview_eb_mpcore_class_init,
462 + .instance_size = sizeof(RealViewMachineState),
463 .interfaces = arm_machine_interfaces,
464 };
465
@@ -473,6 +480,7 @@ static const TypeInfo realview_pb_a8_type = {
480 .name = MACHINE_TYPE_NAME("realview-pb-a8"),
481 .parent = TYPE_MACHINE,
482 .class_init = realview_pb_a8_class_init,
483 + .instance_size = sizeof(RealViewMachineState),
484 .interfaces = arm_machine_interfaces,
485 };
486
@@ -494,6 +502,7 @@ static const TypeInfo realview_pbx_a9_type = {
502 .name = MACHINE_TYPE_NAME("realview-pbx-a9"),
503 .parent = TYPE_MACHINE,
504 .class_init = realview_pbx_a9_class_init,
505 + .instance_size = sizeof(RealViewMachineState),
506 .interfaces = arm_machine_interfaces,
507 };
508