All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/33] hw/arm: Introduce generic FDT-driven machine
@ 2026-04-02 21:55 Ruslan Ruslichenko
  2026-04-02 21:55 ` [PATCH v3 01/33] system/device_tree: update qemu_fdt_getprop_cell Ruslan Ruslichenko
                   ` (32 more replies)
  0 siblings, 33 replies; 36+ messages in thread
From: Ruslan Ruslichenko @ 2026-04-02 21:55 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, alex.bennee, peter.maydell, artem_mygaiev,
	volodymyr_babchuk, takahiro.nakata.wr, Edgar E . Iglesias,
	Ruslan_Ruslichenko, balaton, Alistair Francis, David Gibson

From: Ruslan Ruslichenko <Ruslan_Ruslichenko@epam.com>

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

Updates in v3:
- Added support for binding host memory backends.
- Simplified the main qdev initialization logic.
- Reworked logging withing the FDT framework.
- Moved the 'hw-dtb' parameter to be a machine option.
- Addressed other comments from v2.

Updates in v2:
This version add support for an sbsa-ref compatible platform. Major additions include:

GICv3: via the FDTGenericIntc interface.
GPEX PCI Host: Dynamic mapping of MMIO windows via aliases and irq routing via a new gsi-irqs property.
Block Devices: New support for binding QEMU block backends to FDT nodes using blockdev.
Testing: Added two new functional tests ensuring the machine can boot successfully similar sbsa-ref platform.

Also addressed comments received in v1.

Origin & Motivation
This feature originates from the AMD QEMU repository (https://github.com/Xilinx/qemu).

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

This series introduces an alternative approach: defining the board configuration via a Device Tree Blob (DTB) provided at
the command line. The new arm-generic-fdt machine parses this DTB at runtime to dynamically construct the system topology.

Beyond providing more flexible board creation, this infrastructure is a prerequisite for enabling Hardware Co-Simulation
workflows (e.g., using the Remote-Port protocol: https://mail.gnu.org/archive/html/qemu-devel/2026-02/msg01760.html).
In mixed simulation environments where QEMU emulates the CPU subsystem and an external simulator (such as SystemC) handles
custom logic, the memory map and interrupt lines often need to change dynamically based on the external hardware configuration,
making static C models impractical.

Implementation Overview
The series implements an FDT loading framework in hw/core/fdt_generic_util.c capable of:

Parsing and creating device models from FDT nodes.
Setting QOM properties based on FDT properties.
Connecting IRQs for SysBus devices (via FDTGenericIntc).
Mapping memory regions for IO devices or system RAM (via FDTGenericMMap).
Attaching block devices specified via blockdev interface.
NOTE: GPIO wiring for non-SysBus devices is not supported.

Testing
Testing can be performed by two scripts within patch series.
Pre-compiled dtb binaries for tests are currently placed at tests/data/dtb/aarch64/arm-generic-fdt.

The Device Trees to emulate VM similar sources used for testing can be found by following links:

Hardware DTS: https://gist.github.com/ruslichenkor/82245d89fb2a64dc7f1b694504cb840e#file-arm64-sbsa-hw-dts
Guest DTS: https://gist.github.com/ruslichenkor/82245d89fb2a64dc7f1b694504cb840e#file-arm64-sbsa-guest-dts

Example command to launch a VM similar to SBSA-ref:

/qemu/build/qemu-system-aarch64 \
        --machine arm-generic-fdt,hw-dtb=arm64-sbsa-hw.dtb \
        -dtb arm64-sbsa-guest.dtb \
        -serial mon:stdio \
        -netdev user,id=net0 \
        -device e1000e,netdev=net0 \
        -device bochs-display \
        -blockdev driver=file,filename=./SBSA_FLASH0.fd,node-name=pflash0 \
        -blockdev driver=file,filename=./SBSA_FLASH1.fd,node-name=pflash1 \
        -device usb-kbd -device usb-tablet \
        -drive file=./alpine-standard-3.23.3-aarch64.iso,if=none,id=cdrom0,readonly=on \
        -device ide-cd,bus=ahci.0,unit=0,drive=cdrom0

Also it is possible to run simple ARM64 VM with direct kernel boot.
The example device tree for minimal VM machine can be found here:

Hardware DTS: https://gist.github.com/ruslichenkor/19a1b7d937dbf889190e670cb677e43e#file-arm64-virt-hw-dts
Guest DTS: https://gist.github.com/ruslichenkor/19a1b7d937dbf889190e670cb677e43e#file-arm64-virt-guest-dts

Example command for direct kernel boot:

./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 '

Open Questions
Location of Test Binaries:
I have added the compiled Device Tree Blobs (DTB) required for the functional tests into tests/data/dtb.

Question: Is this the preferred location for static test binaries, or should they be placed elsewhere?

Patch Summary
hw/core: Add Generic FDT parsing infrastructure and utility functions (fdt_generic_util)
hw/arm: Add the arm-generic-fdt 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 GICv3 (IRQ translation and default wiring)
hw/pci-host: Add gsi-irqs property for INTx mapping
target/arm: Add FDT support for CPU timers

Ruslan Ruslichenko (33):
  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
  qdev: Add qdev_prop_get_array_elem_type() helper
  qom/object: export object_resolve_link()
  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 regions
  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/arm: add generic ARM machine initialized by FDT
  hw/arm/arm_generic_fdt: Add support for host-backed RAM regions
  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
  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/intc/arm_gicv3: Implement FDTGenericIntc interface
  hw/core/fdt_generic_util: Add deferred device initialization support
  hw/core/fdt_generic_util: Add blockdev binding support
  hw/pci-host: add gsi-irqs property array
  tests/functional: Add functional tests for arm-generic-fdt machine

 hw/arm/arm_generic_fdt.c                      |  266 ++++
 hw/arm/boot.c                                 |    8 +-
 hw/arm/meson.build                            |    2 +
 hw/arm/raspi4b.c                              |    8 +-
 hw/arm/vexpress.c                             |    4 +-
 hw/core/fdt_generic.c                         |  259 ++++
 hw/core/fdt_generic_util.c                    | 1194 +++++++++++++++++
 hw/core/meson.build                           |    2 +
 hw/core/qdev-properties.c                     |   12 +
 hw/core/sysbus.c                              |   28 +
 hw/intc/arm_gic.c                             |   32 +
 hw/intc/arm_gic_common.c                      |   50 +
 hw/intc/arm_gicv3.c                           |   45 +
 hw/intc/arm_gicv3_common.c                    |   68 +
 hw/pci-host/gpex.c                            |    6 +
 include/hw/core/fdt_generic.h                 |  134 ++
 include/hw/core/fdt_generic_util.h            |  145 ++
 include/hw/core/qdev-properties.h             |    1 +
 include/hw/pci-host/gpex.h                    |    3 +
 include/qemu/log.h                            |    1 +
 include/qom/object.h                          |   12 +
 include/system/device_tree.h                  |   27 +-
 qom/object.c                                  |    2 +-
 system/device_tree.c                          |  210 ++-
 system/memory.c                               |  357 ++++-
 target/arm/cpu.c                              |  112 ++
 .../arm-generic-fdt/arm64-sbsa-guest.dtb      |  Bin 0 -> 673 bytes
 .../aarch64/arm-generic-fdt/arm64-sbsa-hw.dtb |  Bin 0 -> 5290 bytes
 tests/functional/aarch64/meson.build          |    2 +
 .../aarch64/test_arm_generic_fdt.py           |  114 ++
 .../aarch64/test_arm_generic_fdt_alpine.py    |   61 +
 util/log.c                                    |    1 +
 32 files changed, 3138 insertions(+), 28 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
 create mode 100644 tests/data/dtb/aarch64/arm-generic-fdt/arm64-sbsa-guest.dtb
 create mode 100644 tests/data/dtb/aarch64/arm-generic-fdt/arm64-sbsa-hw.dtb
 create mode 100755 tests/functional/aarch64/test_arm_generic_fdt.py
 create mode 100755 tests/functional/aarch64/test_arm_generic_fdt_alpine.py

-- 
2.43.0



^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2026-04-03 17:26 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-02 21:55 [PATCH v3 00/33] hw/arm: Introduce generic FDT-driven machine Ruslan Ruslichenko
2026-04-02 21:55 ` [PATCH v3 01/33] system/device_tree: update qemu_fdt_getprop_cell Ruslan Ruslichenko
2026-04-02 21:55 ` [PATCH v3 02/33] system/device_tree: add few parsing and traversal helpers Ruslan Ruslichenko
2026-04-03  0:52   ` David Gibson
2026-04-03 17:25     ` Ruslan Ruslichenko
2026-04-02 21:55 ` [PATCH v3 03/33] util/log: add log entry for fdt generic utils Ruslan Ruslichenko
2026-04-02 21:55 ` [PATCH v3 04/33] hw/core: introduce generic FDT device model registry Ruslan Ruslichenko
2026-04-02 21:55 ` [PATCH v3 05/33] hw/core/fdt_generic: implement FDT machine creation helpers Ruslan Ruslichenko
2026-04-02 21:55 ` [PATCH v3 06/33] hw/core/fdt_generic: add cpu clusters management Ruslan Ruslichenko
2026-04-02 21:55 ` [PATCH v3 07/33] hw/core/fdt_generic_util: implement main fdt parse routine Ruslan Ruslichenko
2026-04-02 21:55 ` [PATCH v3 08/33] hw/core/fdt_generic_util: implement fdt_init_qdev Ruslan Ruslichenko
2026-04-02 21:55 ` [PATCH v3 09/33] qdev: Add qdev_prop_get_array_elem_type() helper Ruslan Ruslichenko
2026-04-02 21:55 ` [PATCH v3 10/33] qom/object: export object_resolve_link() Ruslan Ruslichenko
2026-04-02 21:55 ` [PATCH v3 11/33] hw/core/fdt_generic_util: initilize qdev properties from fdt Ruslan Ruslichenko
2026-04-02 21:55 ` [PATCH v3 12/33] hw/core/fdt_generic_util: actually realize device Ruslan Ruslichenko
2026-04-02 21:55 ` [PATCH v3 13/33] hw/core/fdt_generic_util: add TYPE_FDT_GENERIC_MMAP Ruslan Ruslichenko
2026-04-02 21:55 ` [PATCH v3 14/33] hw/core/fdt_generic_util: add TYPE_FDT_GENERIC_INTC Ruslan Ruslichenko
2026-04-02 21:56 ` [PATCH v3 15/33] hw/core/fdt_generic_util: implement fdt_get_irq/_info API Ruslan Ruslichenko
2026-04-02 21:56 ` [PATCH v3 16/33] hw/core/fdt_generic_util: map device memory regions Ruslan Ruslichenko
2026-04-02 21:56 ` [PATCH v3 17/33] hw/core/fdt_generic_util: Connect device irqs Ruslan Ruslichenko
2026-04-02 21:56 ` [PATCH v3 18/33] hw/core/fdt_generic_util: realize cpu clusters Ruslan Ruslichenko
2026-04-02 21:56 ` [PATCH v3 19/33] hw/core: add fdt_generic to the build Ruslan Ruslichenko
2026-04-02 21:56 ` [PATCH v3 20/33] hw/arm: add generic ARM machine initialized by FDT Ruslan Ruslichenko
2026-04-02 21:56 ` [PATCH v3 21/33] hw/arm/arm_generic_fdt: Add support for host-backed RAM regions Ruslan Ruslichenko
2026-04-02 21:56 ` [PATCH v3 22/33] hw/core/sysbus: implement FDT_GENERIC_MMAP_CLASS interface Ruslan Ruslichenko
2026-04-02 21:56 ` [PATCH v3 23/33] hw/intc/arm_gic: implement FDT_GENERIC_INTC and fdt support Ruslan Ruslichenko
2026-04-02 21:56 ` [PATCH v3 24/33] target/arm/cpu: add fdt support for armv8-timer Ruslan Ruslichenko
2026-04-02 21:56 ` [PATCH v3 25/33] system/memory: add setters for MemoryRegion properties Ruslan Ruslichenko
2026-04-02 21:56 ` [PATCH v3 26/33] system/memory: implement FDT_GENERIC_MMAP interface Ruslan Ruslichenko
2026-04-02 21:56 ` [PATCH v3 27/33] hw/core/fdt_generic_util: initialize serial devices Ruslan Ruslichenko
2026-04-02 21:56 ` [PATCH v3 28/33] system/memory: add QOM aliases for fdt support Ruslan Ruslichenko
2026-04-02 21:56 ` [PATCH v3 29/33] hw/intc/arm_gicv3: Implement FDTGenericIntc interface Ruslan Ruslichenko
2026-04-02 21:56 ` [PATCH v3 30/33] hw/core/fdt_generic_util: Add deferred device initialization support Ruslan Ruslichenko
2026-04-02 21:56 ` [PATCH v3 31/33] hw/core/fdt_generic_util: Add blockdev binding support Ruslan Ruslichenko
2026-04-02 21:56 ` [PATCH v3 32/33] hw/pci-host: add gsi-irqs property array Ruslan Ruslichenko
2026-04-02 21:56 ` [PATCH v3 33/33] tests/functional: Add functional tests for arm-generic-fdt machine Ruslan Ruslichenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.