Skip to content

hw/arm: Add generic FDT-based machine and infrastructure

Ruslan Ruslichenko qemu-arm qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest27 patches 14 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/27system/device_tree: update qemu_fdt_getprop/_cellhw/arm/boot.c hw/arm/raspi4b.c hw/arm/vexpress.c +3 more+55 -331 reply
2/27system/device_tree: add few parsing and traversal helpersinclude/system/device_tree.h system/device_tree.c+233 -02 replies
3/27util/log: add log entry for fdt generic utilsinclude/qemu/log.h util/log.c+2 -00 replies
4/27hw/core: introduce generic FDT device model registryhw/core/fdt_generic.c include/hw/core/fdt_generic.h+217 -00 replies
5/27hw/core/fdt_generic: implement FDT machine creation helpershw/core/fdt_generic.c include/hw/core/fdt_generic.h+95 -10 replies
6/27hw/core/fdt_generic: add cpu clusters managementhw/core/fdt_generic.c include/hw/core/fdt_generic.h+90 -00 replies
7/27hw/core/fdt_generic_util: implement main fdt parse routinehw/core/fdt_generic_util.c include/hw/core/fdt_generic_util.h+261 -00 replies
8/27hw/core/fdt_generic_util: implement fdt_init_qdevhw/core/fdt_generic_util.c+224 -00 replies
9/27hw/core/fdt_generic_util: initilize qdev properties from fdthw/core/fdt_generic_util.c+282 -00 replies
10/27hw/core/fdt_generic_util: actually realize devicehw/core/fdt_generic_util.c+20 -00 replies
11/27hw/core/fdt_generic_util: add TYPE_FDT_GENERIC_MMAPhw/core/fdt_generic_util.c include/hw/core/fdt_generic_util.h+55 -00 replies
12/27hw/core/fdt_generic_util: add TYPE_FDT_GENERIC_INTChw/core/fdt_generic_util.c include/hw/core/fdt_generic_util.h+66 -00 replies
13/27hw/core/fdt_generic_util: implement fdt_get_irq/_info APIhw/core/fdt_generic_util.c include/hw/core/fdt_generic_util.h+279 -00 replies
14/27hw/core/fdt_generic_util: map device memoryhw/core/fdt_generic_util.c+103 -00 replies
15/27hw/core/fdt_generic_util: Connect device irqshw/core/fdt_generic_util.c include/hw/core/fdt_generic.h+157 -10 replies
16/27hw/core/fdt_generic_util: realize cpu clustershw/core/fdt_generic_util.c+11 -00 replies
17/27hw/core: add fdt_generic to the buildhw/core/meson.build+2 -00 replies
18/27hw/core/machine: add '-hw-dtb' option for machinehw/core/machine.c include/hw/core/boards.h qemu-options.hx +1 more+32 -02 replies
19/27hw/arm: add generic ARM machine initialized by FDThw/arm/arm_generic_fdt.c hw/arm/meson.build+168 -00 replies
20/27hw/core/sysbus: implement FDT_GENERIC_MMAP_CLASS interfacehw/core/sysbus.c+28 -00 replies
21/27hw/intc/arm_gic: implement FDT_GENERIC_INTC and fdt supporthw/intc/arm_gic.c hw/intc/arm_gic_common.c+82 -00 replies
22/27target/arm/cpu: add fdt support for armv8-timertarget/arm/cpu.c+115 -00 replies
23/27qom/object: export object_resolve_link()include/qom/object.h qom/object.c+13 -10 replies
24/27system/memory: add setters for MemoryRegion propertiessystem/memory.c+161 -50 replies
25/27system/memory: implement FDT_GENERIC_MMAP interfacesystem/memory.c+58 -00 replies
26/27hw/core/fdt_generic_util: initialize serial deviceshw/core/fdt_generic_util.c+44 -00 replies
27/27system/memory: add QOM aliases for fdt supportsystem/memory.c+24 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 00/27] hw/arm: Add generic FDT-based machine and infrastructure

From: Ruslan Ruslichenko <[email protected]>

This patch series introduces new ARM machine model, arm-generic-fdt, and the underlying infrastructure required to instantiate a QEMU machine from a Device Tree.

Origin
This feature originates from AMD QEMU repository and was originally developed by AMD. The sources available by link: https://github.com/Xilinx/qemu.

Motivation
Currently, adding support for a new ARM board in QEMU required writing a dedicated C source file to define the memory map, instantiate devices, and wire interrupts. Any modification to board configuration requires a corresponding change in the source code and rebuild of the QEMU binary.

This series introduce alternative approach to define board configuration via a Device Tree. The new arm-generic-fdt machine parses DTB at runtime to dynamically construct system topology.

Beyond providing more flexible board creation, the series provides the infrastructure needed to enable Hardware Co-Simulation workflows in future by using Remote-Port protocol:
https://mail.gnu.org/archive/html/qemu-devel/2025-12/msg02121.html.
In mixed simulation environments - where QEMU emulates CPU subsystem and external simulator (such as SystemC) handles custom logic - memory map and interrupt lines may need to be changed depending on external hardware configuration.

Implementation overview
The series implements FDT loading framework itself, which is capable of:
- Parsing and creating device models
- Set properties for them from a device tree
- Connect IRQs for SysBus devices
- Map memory regions for IO device or system RAM.

NOTE: The GPIO wiring for non-SysBus devices would be added in future patch series.

Patch Summary
- hw/core: Add Generic FDT parsing infrastructure and utility functions
- hw/arm: Add the arm-generic-machine model
- hw/core/sysbus: Add IO memory mapping for standard SysBus devices
- system/memory: Allow MemoryRegions to be configured from FDT
- hw/intc: Add FDT support for ARM GIC (IRQ translation and default wiring)
- target/arm: Add FDT support for CPU timers

Testing
Testing performed used Yocto core-image-minimal rootfs and kernel image.

The hardware description Device tree (used with '-hw-dtb' option) can be found here: https://gist.github.com/ruslichenkor/19a1b7d937dbf889190e670cb677e43e#file-arm64-virt-hw-dts

The guest device tree (used with standard '-dtb' option) can be found here: https://gist.github.com/ruslichenkor/19a1b7d937dbf889190e670cb677e43e#file-arm64-virt-guest-dts

Execute command itself:

./qemu-system-aarch64 \
    -machine arm-generic-fdt \
    -hw-dtb arm64-virt-hw.dtb \
    -dtb arm64-virt-guest.dtb \
    -cpu cortex-a57 -smp 4 -m 256 \
    -drive id=disk0,file=./core-image-minimal-qemuarm64.rootfs-20251218190831.ext4,if=none,format=raw \
    -device virtio-blk-device,drive=disk0 \
    -kernel ./Image \
    -nographic \
    -append 'root=/dev/vda console=ttyAMA0 mem=256M swiotlb=0 '

Ruslan Ruslichenko (27):
system/device_tree: update qemu_fdt_getprop/_cell system/device_tree: add few parsing and traversal helpers util/log: add log entry for fdt generic utils hw/core: introduce generic FDT device model registry hw/core/fdt_generic: implement FDT machine creation helpers hw/core/fdt_generic: add cpu clusters management hw/core/fdt_generic_util: implement main fdt parse routine hw/core/fdt_generic_util: implement fdt_init_qdev hw/core/fdt_generic_util: initilize qdev properties from fdt hw/core/fdt_generic_util: actually realize device hw/core/fdt_generic_util: add TYPE_FDT_GENERIC_MMAP hw/core/fdt_generic_util: add TYPE_FDT_GENERIC_INTC hw/core/fdt_generic_util: implement fdt_get_irq/_info API hw/core/fdt_generic_util: map device memory hw/core/fdt_generic_util: Connect device irqs hw/core/fdt_generic_util: realize cpu clusters hw/core: add fdt_generic to the build hw/core/machine: add '-hw-dtb' option for machine hw/arm: add generic ARM machine initialized by FDT hw/core/sysbus: implement FDT_GENERIC_MMAP_CLASS interface hw/intc/arm_gic: implement FDT_GENERIC_INTC and fdt support target/arm/cpu: add fdt support for armv8-timer qom/object: export object_resolve_link() system/memory: add setters for MemoryRegion properties system/memory: implement FDT_GENERIC_MMAP interface hw/core/fdt_generic_util: initialize serial devices system/memory: add QOM aliases for fdt support

 hw/arm/arm_generic_fdt.c           |  166 ++++
 hw/arm/boot.c                      |    8 +-
 hw/arm/meson.build                 |    2 +
 hw/arm/raspi4b.c                   |    8 +-
 hw/arm/vexpress.c                  |    4 +-
 hw/arm/xlnx-zcu102.c               |    3 +-
 hw/core/fdt_generic.c              |  286 ++++++
 hw/core/fdt_generic_util.c         | 1349 ++++++++++++++++++++++++++++
 hw/core/machine.c                  |   19 +
 hw/core/meson.build                |    2 +
 hw/core/sysbus.c                   |   28 +
 hw/intc/arm_gic.c                  |   32 +
 hw/intc/arm_gic_common.c           |   50 ++
 include/hw/core/boards.h           |    1 +
 include/hw/core/fdt_generic.h      |  127 +++
 include/hw/core/fdt_generic_util.h |  140 +++
 include/qemu/log.h                 |    1 +
 include/qom/object.h               |   12 +
 include/system/device_tree.h       |   62 +-
 qemu-options.hx                    |    9 +
 qom/object.c                       |    2 +-
 system/device_tree.c               |  236 ++++-
 system/memory.c                    |  248 ++++-
 system/vl.c                        |    3 +
 target/arm/cpu.c                   |  115 +++
 util/log.c                         |    1 +
 26 files changed, 2875 insertions(+), 39 deletions(-)
 create mode 100644 hw/arm/arm_generic_fdt.c
 create mode 100644 hw/core/fdt_generic.c
 create mode 100644 hw/core/fdt_generic_util.c
 create mode 100644 include/hw/core/fdt_generic.h
 create mode 100644 include/hw/core/fdt_generic_util.h
Signature · 1 line
2.43.0