[PATCH 00/20] hw/arm: Store the ARM boot info in the machine state

Bin Meng posted 20 patches 1 week, 6 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260813154918.996812-1-bin.meng@processmission.com
Maintainers: "Cédric Le Goater" <clg@kaod.org>, Peter Maydell <peter.maydell@linaro.org>, Steven Lee <steven_lee@aspeedtech.com>, Troy Lee <leetroy@gmail.com>, Jamin Lin <jamin_lin@aspeedtech.com>, Kane Chen <kane_chen@aspeedtech.com>, Andrew Jeffery <andrew@codeconstruct.com.au>, Joel Stanley <joel@jms.id.au>, Strahinja Jankovic <strahinja.p.jankovic@gmail.com>, Jean-Christophe Dubois <jcd@tribudubois.net>, Gaurav Sharma <gaurav.sharma_7@nxp.com>, Jan Kiszka <jan.kiszka@web.de>, Tyrone Ting <kfting@nuvoton.com>, Hao Wu <wuhaotsh@google.com>, Niek Linnenbank <nieklinnenbank@gmail.com>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Alistair Francis <alistair@alistair23.me>
There is a newer version of this series
hw/arm/aspeed.c              | 17 +++++++--------
hw/arm/aspeed_ast27x0-fc.c   | 13 ++++++------
hw/arm/bananapi_m2u.c        | 37 ++++++++++++++++++++++++++-------
hw/arm/collie.c              | 14 ++++++-------
hw/arm/cubieboard.c          | 38 +++++++++++++++++++++++++++-------
hw/arm/exynos4_boards.c      | 26 +++++++++++------------
hw/arm/imx25_pdk.c           | 11 +++++-----
hw/arm/imx8mm-evk.c          | 34 +++++++++++++++++++++++++-----
hw/arm/integratorcp.c        | 40 +++++++++++++++++++++++++++++-------
hw/arm/kzm.c                 | 14 ++++++-------
hw/arm/mcimx7d-sabre.c       | 36 +++++++++++++++++++++++++++-----
hw/arm/musicpal.c            | 32 ++++++++++++++++++++++-------
hw/arm/npcm7xx.c             | 28 ++++++++++++-------------
hw/arm/npcm7xx_boards.c      | 15 +++++++++-----
hw/arm/npcm8xx.c             | 30 +++++++++++++--------------
hw/arm/npcm8xx_boards.c      |  3 ++-
hw/arm/omap_sx1.c            | 21 +++++++++++++------
hw/arm/orangepi.c            | 37 ++++++++++++++++++++++++++-------
hw/arm/realview.c            | 30 +++++++++++++++++++--------
hw/arm/sabrelite.c           | 24 +++++++++++-----------
hw/arm/versatilepb.c         | 16 +++++++++++----
hw/arm/xilinx_zynq.c         | 17 ++++++++-------
include/hw/arm/aspeed.h      |  2 ++
include/hw/arm/npcm7xx.h     | 10 +++++++--
include/hw/arm/npcm8xx.h     | 10 +++++++--
include/hw/arm/xilinx_zynq.h |  2 ++
26 files changed, 382 insertions(+), 175 deletions(-)
[PATCH 00/20] hw/arm: Store the ARM boot info in the machine state
Posted by Bin Meng 1 week, 6 days ago
Most ARM board files declare their struct arm_boot_info as a static
object at file scope (or, occasionally, as a function-local static
inside the machine init function). arm_load_kernel() stashes a pointer
to that struct in every CPU and dereferences it from do_cpu_reset() on
each reset, so the boot info conceptually belongs to the machine for the
lifetime of the VM, not to a static object whose ownership is left
implicit.

This is a longstanding leftover pattern: modern machines such as virt,
raspi and xlnx-zcu102 already keep the boot info in their MachineState
subclass. This series converts the remaining machines that still use
a static object, moving the struct into their machine state so that its
lifetime and ownership match how arm_load_kernel() actually uses it.


Bin Meng (20):
  hw/arm: aspeed: Store boot info in the machine state
  hw/arm: aspeed_ast27x0-fc: Store boot info in the machine state
  hw/arm: bananapi_m2u: Store boot info in the machine state
  hw/arm: collie: Store boot info in the machine state
  hw/arm: cubieboard: Store boot info in the machine state
  hw/arm: exynos4_boards: Store boot info in the board state
  hw/arm: imx25_pdk: Store boot info in the board state
  hw/arm: imx8mm-evk: Store boot info in the machine state
  hw/arm: integratorcp: Store boot info in the machine state
  hw/arm: kzm: Store boot info in the board state
  hw/arm: mcimx7d-sabre: Store boot info in the machine state
  hw/arm: musicpal: Store boot info in the machine state
  hw/arm: npcm7xx: Store boot info in the machine state
  hw/arm: npcm8xx: Store boot info in the machine state
  hw/arm: omap_sx1: Store boot info in the machine state
  hw/arm: orangepi: Store boot info in the machine state
  hw/arm: realview: Store boot info in the machine state
  hw/arm: sabrelite: Store boot info in the machine state
  hw/arm: versatilepb: Store boot info in the machine state
  hw/arm: xilinx_zynq: Store boot info in the machine state

 hw/arm/aspeed.c              | 17 +++++++--------
 hw/arm/aspeed_ast27x0-fc.c   | 13 ++++++------
 hw/arm/bananapi_m2u.c        | 37 ++++++++++++++++++++++++++-------
 hw/arm/collie.c              | 14 ++++++-------
 hw/arm/cubieboard.c          | 38 +++++++++++++++++++++++++++-------
 hw/arm/exynos4_boards.c      | 26 +++++++++++------------
 hw/arm/imx25_pdk.c           | 11 +++++-----
 hw/arm/imx8mm-evk.c          | 34 +++++++++++++++++++++++++-----
 hw/arm/integratorcp.c        | 40 +++++++++++++++++++++++++++++-------
 hw/arm/kzm.c                 | 14 ++++++-------
 hw/arm/mcimx7d-sabre.c       | 36 +++++++++++++++++++++++++++-----
 hw/arm/musicpal.c            | 32 ++++++++++++++++++++++-------
 hw/arm/npcm7xx.c             | 28 ++++++++++++-------------
 hw/arm/npcm7xx_boards.c      | 15 +++++++++-----
 hw/arm/npcm8xx.c             | 30 +++++++++++++--------------
 hw/arm/npcm8xx_boards.c      |  3 ++-
 hw/arm/omap_sx1.c            | 21 +++++++++++++------
 hw/arm/orangepi.c            | 37 ++++++++++++++++++++++++++-------
 hw/arm/realview.c            | 30 +++++++++++++++++++--------
 hw/arm/sabrelite.c           | 24 +++++++++++-----------
 hw/arm/versatilepb.c         | 16 +++++++++++----
 hw/arm/xilinx_zynq.c         | 17 ++++++++-------
 include/hw/arm/aspeed.h      |  2 ++
 include/hw/arm/npcm7xx.h     | 10 +++++++--
 include/hw/arm/npcm8xx.h     | 10 +++++++--
 include/hw/arm/xilinx_zynq.h |  2 ++
 26 files changed, 382 insertions(+), 175 deletions(-)

---
base-commit: 539bc315538afe036a4b99088659aa82e3b489f2
branch: cleanup-arm-static-boot-info

-- 
2.53.0
Re: [PATCH 00/20] hw/arm: Store the ARM boot info in the machine state
Posted by Peter Maydell 1 week, 4 days ago
On Thu, 13 Aug 2026 at 16:49, Bin Meng <bin.meng@processmission.com> wrote:
>
>
> Most ARM board files declare their struct arm_boot_info as a static
> object at file scope (or, occasionally, as a function-local static
> inside the machine init function). arm_load_kernel() stashes a pointer
> to that struct in every CPU and dereferences it from do_cpu_reset() on
> each reset, so the boot info conceptually belongs to the machine for the
> lifetime of the VM, not to a static object whose ownership is left
> implicit.
>
> This is a longstanding leftover pattern: modern machines such as virt,
> raspi and xlnx-zcu102 already keep the boot info in their MachineState
> subclass. This series converts the remaining machines that still use
> a static object, moving the struct into their machine state so that its
> lifetime and ownership match how arm_load_kernel() actually uses it.

Yes, I think mostly we have this leftover because converting
machines which don't yet have a state struct to have one seemed
a bit tedious. But it'll be useful to have them for other
cleanup reasons in future I suspect; I like the cleanup.

Rather than commenting on a lot of individual patches, I'll just
list a couple of niggles here:

(1) Can we be consistent about whether we set fields individually,
like this in patch 2:

+    bpms->bootinfo.loader_start = r40->memmap[AW_R40_DEV_SDRAM];
+    bpms->bootinfo.ram_size = machine->ram_size;
+    bpms->bootinfo.psci_conduit = QEMU_PSCI_CONDUIT_SMC;

or via a struct initializer, like this in patch 3:

+    cms->bootinfo = (struct arm_boot_info) {
+        .loader_start = SA_SDCS0,
+        .ram_size = RAM_SIZE,
+        .board_id = 0x208,
+    };

I don't particularly care which you pick, I'd just like to avoid
the needless variation.

(2) Could we use DEFINE_MACHINE_EXTENDED() rather than writing
out all the QOM boilerplate by hand, for the boards which previously
used DEFINE_MACHINE_ARM? (No need to convert to macros if we were
already using hand-written boilerplate, like omap_sx1.c.)

thanks
-- PMM
Re: [PATCH 00/20] hw/arm: Store the ARM boot info in the machine state
Posted by Philippe Mathieu-Daudé 1 week, 5 days ago
On 13/8/26 17:48, Bin Meng wrote:
> 
> Most ARM board files declare their struct arm_boot_info as a static
> object at file scope (or, occasionally, as a function-local static
> inside the machine init function). arm_load_kernel() stashes a pointer
> to that struct in every CPU and dereferences it from do_cpu_reset() on
> each reset, so the boot info conceptually belongs to the machine for the
> lifetime of the VM, not to a static object whose ownership is left
> implicit.
> 
> This is a longstanding leftover pattern: modern machines such as virt,
> raspi and xlnx-zcu102 already keep the boot info in their MachineState
> subclass. This series converts the remaining machines that still use
> a static object, moving the struct into their machine state so that its
> lifetime and ownership match how arm_load_kernel() actually uses it.

I wanted that cleanup since a long time, excellent, thanks Bin!