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 -- 2.43.0
