@samitouri / QOSamiQemu / commits / 3b9cb3dd04

hw/arm: imx8mm-evk: 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 function scoped static object. Move it into a new Imx8mmEvkMachineState and register the machine type explicitly instead of through the DEFINE_MACHINE_AARCH64 macro. 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-9-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 3b9cb3dd042c1edc4c7a240e8dcd3252e6d38dd4
1 file changed +19 -10
hw/arm/imx8mm-evk.c
+19 -10
@@ -20,6 +20,15 @@
20 #include "qapi/error.h"
21 #include <libfdt.h>
22
23 +#define TYPE_IMX8MM_EVK_MACHINE MACHINE_TYPE_NAME("imx8mm-evk")
24 +OBJECT_DECLARE_SIMPLE_TYPE(Imx8mmEvkMachineState, IMX8MM_EVK_MACHINE)
25 +
26 +struct Imx8mmEvkMachineState {
27 + MachineState parent;
28 +
29 + struct arm_boot_info bootinfo;
30 +};
31 +
32 static void imx8mm_evk_modify_dtb(const struct arm_boot_info *info, void *fdt)
33 {
34 int i, offset;
@@ -60,7 +69,7 @@ static void imx8mm_evk_modify_dtb(const struct arm_boot_info *info, void *fdt)
69
70 static void imx8mm_evk_init(MachineState *machine)
71 {
63 - static struct arm_boot_info boot_info;
72 + Imx8mmEvkMachineState *ims = IMX8MM_EVK_MACHINE(machine);
73 FslImx8mmState *s;
74
75 if (machine->ram_size > FSL_IMX8MM_RAM_SIZE_MAX) {
@@ -69,13 +78,11 @@ static void imx8mm_evk_init(MachineState *machine)
78 exit(1);
79 }
80
72 - boot_info = (struct arm_boot_info) {
73 - .loader_start = FSL_IMX8MM_RAM_START,
74 - .board_id = -1,
75 - .ram_size = machine->ram_size,
76 - .psci_conduit = QEMU_PSCI_CONDUIT_SMC,
77 - .modify_dtb = imx8mm_evk_modify_dtb,
78 - };
81 + ims->bootinfo.loader_start = FSL_IMX8MM_RAM_START;
82 + ims->bootinfo.board_id = -1;
83 + ims->bootinfo.ram_size = machine->ram_size;
84 + ims->bootinfo.psci_conduit = QEMU_PSCI_CONDUIT_SMC;
85 + ims->bootinfo.modify_dtb = imx8mm_evk_modify_dtb;
86
87 s = FSL_IMX8MM(object_new_with_props(TYPE_FSL_IMX8MM, OBJECT(machine),
88 "soc", &error_fatal, NULL));
@@ -103,7 +110,7 @@ static void imx8mm_evk_init(MachineState *machine)
110 }
111
112 if (!qtest_enabled()) {
106 - arm_load_kernel(&s->cpu[0], machine, &boot_info);
113 + arm_load_kernel(&s->cpu[0], machine, &ims->bootinfo);
114 }
115 }
116
@@ -127,4 +134,6 @@ static void imx8mm_evk_machine_init(MachineClass *mc)
134 mc->get_default_cpu_type = imx8mm_evk_get_default_cpu_type;
135 }
136
130 -DEFINE_MACHINE_AARCH64("imx8mm-evk", imx8mm_evk_machine_init)
137 +DEFINE_MACHINE_EXTENDED("imx8mm-evk", MACHINE, Imx8mmEvkMachineState,
138 + imx8mm_evk_machine_init, false,
139 + aarch64_machine_interfaces)