@samitouri / QOSamiQemu / commits / 4477c14482

hw/arm: versatilepb: 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 both machine types the same VersatileMachineState 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-20-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 4477c1448252fc33c978db30e96d1787ebd4df80
1 file changed +12 -4
hw/arm/versatilepb.c
+12 -4
@@ -182,10 +182,16 @@ static void vpb_sic_init(Object *obj)
182 peripherals and expansion busses. For now we emulate a subset of the
183 PB peripherals and just change the board ID. */
184
185 -static struct arm_boot_info versatile_binfo;
185 +typedef struct VersatileMachineState {
186 + MachineState parent;
187 +
188 + struct arm_boot_info bootinfo;
189 +} VersatileMachineState;
190
191 static void versatile_init(MachineState *machine, int board_id)
192 {
193 + /* versatilepb and versatileab embed the same state as first member */
194 + VersatileMachineState *vms = (VersatileMachineState *)machine;
195 Object *cpuobj;
196 ARMCPU *cpu;
197 MemoryRegion *sysmem = get_system_memory();
@@ -397,9 +403,9 @@ static void versatile_init(MachineState *machine, int board_id)
403 VERSATILE_FLASH_SECT_SIZE,
404 4, 0x0089, 0x0018, 0x0000, 0x0, 0);
405
400 - versatile_binfo.ram_size = machine->ram_size;
401 - versatile_binfo.board_id = board_id;
402 - arm_load_kernel(cpu, machine, &versatile_binfo);
406 + vms->bootinfo.ram_size = machine->ram_size;
407 + vms->bootinfo.board_id = board_id;
408 + arm_load_kernel(cpu, machine, &vms->bootinfo);
409 }
410
411 static void vpb_init(MachineState *machine)
@@ -431,6 +437,7 @@ static const TypeInfo versatilepb_type = {
437 .name = MACHINE_TYPE_NAME("versatilepb"),
438 .parent = TYPE_MACHINE,
439 .class_init = versatilepb_class_init,
440 + .instance_size = sizeof(VersatileMachineState),
441 .interfaces = arm_machine_interfaces,
442 };
443
@@ -453,6 +460,7 @@ static const TypeInfo versatileab_type = {
460 .name = MACHINE_TYPE_NAME("versatileab"),
461 .parent = TYPE_MACHINE,
462 .class_init = versatileab_class_init,
463 + .instance_size = sizeof(VersatileMachineState),
464 .interfaces = arm_machine_interfaces,
465 };
466