This series produces one qemu-system binary that can run ARM (32 and 64) and MicroBlaze. Upstream filters machines with TypeInfo.is_available. This series passes a TargetInfo into that callback and compiles ARM and MicroBlaze once so they can share qemu-system.
ARM virt keeps the QOM name virt. MicroBlaze boards keep their own names, so TYPE_ACCEL_CPU and the virt ACPI helpers stay per target. aarch64 and arm share one copy of the ARM sources. MicroBlaze is folded the same way. qemu-system links a target only when its arch sources are target-info-def.c alone. Machine is_available accepts ARM-family boards for arm and aarch64, aarch64-only boards for aarch64, and MicroBlaze boards for microblaze. target_ulong and TCG _tl helpers: arm and microblaze are 32-bit and aarch64 is 64-bit, so the shared compile uses a uint64_t target_ulong in softmmu common code. MO_TL follows target_long_bits(). target_long stays per-target. tcg_gen_*_tl and the TL memory helpers call the i32 or i64 operation through tl_is_64(). A helper tl argument uses an i64 slot in common code: tcg_gen_callN zero-extends a 32-bit temp into that slot and truncates an i64 return. Per-target builds keep target_ulong and TCGv tied to TARGET_LONG_BITS. Target selection has to work with more than one TargetInfo: - The combined binary takes arch:name on -M/-machine and in a [machine] type (aarch64:virt). arch: binds the target. microblaze: runs that target's default machine. arm and aarch64 have no default. No -M leaves target none and the empty none machine. qemu-system-$arch keeps the historic -M name. -M help lists every target; arch:help lists one. A later bare name keeps the last arch prefix. query-targets lists each linked target, including none. - TargetInfo is a constructor list. target_info_select() picks the entry, including SYS_EMU_TARGET_NONE. is_available takes const TargetInfo *. A single-target binary keeps its TargetInfo. arch: must match that binary or the machine is rejected. That binary drops types that fail is_available at registration. The combined binary keeps those types and filters with is_available for the selected target. Peter Maydell suggested this arch:name form in review of https://patchwork.ozlabs.org/project/qemu-devel/cover/[email protected]/#3749257 Daniel P. Berrange asked to query every machine in the binary and which targets can run it. This series adds query-targets for that: https://patchwork.ozlabs.org/project/qemu-devel/cover/[email protected]/#3749292 qemu-system-$TARGET is still built, including the Windows *w twin. qemu-system is extra. It links aarch64, arm, and microblaze. Do not add qemu-systemw for that binary. A GUI twin would keep QEMU exporting data from the .exe into DLLs, and those data exports cannot be delay-loaded (qdev_prop_array and other qdev_prop_*). That would block enabling modules globally on Windows. Examples: qemu-system -M aarch64:virt ... qemu-system -M microblaze:petalogix-s3adsp1800 ... qemu-system-aarch64 -M virt ... A bare machine name on qemu-system needs an arch: prefix. An unknown target fails with "target '...' is not available". v1: https://patchew.org/QEMU/[email protected]/ v2: https://patchew.org/QEMU/[email protected]/ v3: https://patchew.org/QEMU/[email protected]/ branch: https://gitlab.com/lygstate-qemu/qemu/-/tree/single-binary-arm-riscv?ref_type=heads x86_64 and i386: https://gitlab.com/lygstate-qemu/qemu/-/tree/combined-binary-multi-targets?ref_type=heads Changes v3 -> v4: v4 keeps arch:name selection, target none, and query-targets. qemu-system links ARM and MicroBlaze only. - Limit the combined binary to aarch64, arm, and microblaze. RISC-V stays on qemu-system-riscv32 and qemu-system-riscv64. Remove the target/riscv and hw/riscv compile-once patches and the RISC-V TARGET_LONG_BITS rewrites. - Drop virt QOM prefixes, MachineInfo typename, the shared TYPE_ACCEL_CPU parent, virt ACPI prefixes, and the RISC-V crc32, crc32c, and wfi helper renames. Those names are already unique for ARM and MicroBlaze. - Drop TargetCpuOps, AccelClass is_available, the move of kvm and whpx onto system_ss, and TargetInfo-gated migration fields. - The combined binary registers every machine and filters with is_available for the selected target. v3 skipped that filter while the target was none. v4 builds without these series: [PATCH v2 0/9] machine: uniquify virt QOM names https://patchew.org/QEMU/[email protected]/ [PATCH 00/21] accel/tcg: share raise_excp across TCG targets https://patchew.org/QEMU/[email protected]/ [PATCH v5 00/11] single-binary: Compile hw/riscv once https://patchew.org/QEMU/[email protected]/ Anton Johansson via qemu development (1): target-info: Introduce target_riscv32 Pierrick Bouvier (2): configs/targets: remove target info definitions target-info: rename target-info-stub.c in target-info-def.c Yonggang Luo (52): target-info: rename target-info-impl.h to target-info-def.h vl: parse early options before target-info init target-info: replace QOM registration with a constructor list tests/unit: add test-target-info tests/qtest: prepare machine-list-test for combined qemu-system kconfig: rename REGISTER to HW_REGISTER target-info: add TargetKconfig target-info: add target_is_* helpers for each architecture target-info: add target_is_any() qom: pass TargetInfo to is_available for latter use target/arm: move kvm_arm_set_cpreg_mig_tolerances to kvm.c target/arm: allow -cpu host with Nitro target/arm: gate -cpu host with TypeIsAvailable target/arm: replace target_long in A64 translate target/arm: use vaddr for the A64 insn_start pc tests/qtest: raise aspeed_smc-test timeout to 12 minutes target-info: add tl_is_64() and target_is_tl32/64 helpers tcg: declare TCGv in tcg.h tcg: dispatch TL memory helpers from tcg-op-mem.h tcg: dispatch tcg_gen_*_tl without TARGET_LONG_BITS tcg: dispatch tcg_gen_gvec_dup_tl at runtime tcg: give common-system helper tl an i64 slot accel/tcg: move helper_exit_atomic next to cpu_loop_exit_atomic tcg: move dup_const into tcg.c tcg: move goto_tb helpers into tcg-op-ldst.c accel/tcg: move gvec helpers into tcg-runtime-gvec.h accel/tcg: move helper_lookup_tb_ptr into cpu-exec.h accel/tcg: move memory helpers out of tcg-runtime.h tests/unit: cover common-system tl dispatch and calls target/arm: fix A64 guest address width at 64 target/arm: pass tl temps into SVE and SME helpers exec: provide target_ulong for softmmu common code exec: compile abi_ptr.h without per-target cpu-param.h accel/tcg: keep cpu-ldst endian aliases per-target target/arm: fold arm_ss into common source sets target/microblaze: fold system sources into common source sets meson: link shared objects into qemu-system target-info: add SysEmuTarget none module: load every arch-tagged module when target is none accel/tcg: tolerate NULL target_cpu_type for -M none target-info: select combined qemu-system target by name vl: parse arch: machine types on combined qemu-system qapi: add query-targets target-info: add target_is_microblaze hw/microblaze: set petalogix-s3adsp1800 TypeInfo.is_available hw/microblaze: expand petalogix-ml605 and xlnx-zynqmp-pmu to TypeInfo hw/arm: expand leftover 32-bit DEFINE_MACHINE to TypeInfo hw/arm: expand imx8mm-evk DEFINE_MACHINE to TypeInfo hw/arm: set virt TypeInfo.is_available hw/arm: set remaining 32-bit machine TypeInfo.is_available hw/arm: set aarch64-only machine TypeInfo.is_available tests/qtest: cover combined qemu-system machines accel/tcg/atomic_common.c.inc | 4 + accel/tcg/atomic_common.h | 70 ++ accel/tcg/cpu-exec-common.c | 10 + accel/tcg/cpu-exec-common.h | 1 + accel/tcg/cpu-exec.c | 5 + accel/tcg/cpu-exec.h | 1 + accel/tcg/ldst_common.c.inc | 4 + accel/tcg/ldst_common.h | 13 + accel/tcg/meson.build | 2 +- accel/tcg/tcg-all.c | 9 +- accel/tcg/tcg-runtime-gvec.c | 3 + .../tcg/{tcg-runtime.h => tcg-runtime-gvec.h} | 111 --- accel/tcg/tcg-runtime.c | 8 - accel/tcg/tcg-runtime.h | 293 ------ configs/targets/aarch64-softmmu.c | 25 - configs/targets/arm-softmmu.c | 25 - configs/targets/meson.build | 6 - configs/targets/riscv32-softmmu.c | 24 - configs/targets/riscv64-softmmu.c | 24 - hw/Kconfig | 2 +- hw/arm/aspeed_ast1040_evb.c | 1 + hw/arm/aspeed_ast10x0_evb.c | 2 + hw/arm/aspeed_ast2400_palmetto.c | 1 + hw/arm/aspeed_ast2400_quanta-q71l.c | 1 + hw/arm/aspeed_ast2400_supermicrox11.c | 1 + hw/arm/aspeed_ast2500_evb.c | 1 + hw/arm/aspeed_ast2500_g220a.c | 1 + hw/arm/aspeed_ast2500_romulus.c | 1 + hw/arm/aspeed_ast2500_supermicro-x11spi.c | 1 + hw/arm/aspeed_ast2500_tiogapass.c | 1 + hw/arm/aspeed_ast2500_witherspoon.c | 1 + hw/arm/aspeed_ast2500_yosemitev2.c | 1 + hw/arm/aspeed_ast2600_anacapa.c | 1 + hw/arm/aspeed_ast2600_bletchley.c | 1 + hw/arm/aspeed_ast2600_catalina.c | 1 + hw/arm/aspeed_ast2600_evb.c | 1 + hw/arm/aspeed_ast2600_fby35.c | 1 + hw/arm/aspeed_ast2600_fuji.c | 1 + hw/arm/aspeed_ast2600_gb200nvl.c | 1 + hw/arm/aspeed_ast2600_rainier.c | 1 + hw/arm/aspeed_ast2600_sanmiguel.c | 1 + hw/arm/aspeed_ast27x0-fc.c | 2 +- hw/arm/aspeed_ast27x0_evb.c | 4 +- hw/arm/ax3000-evk.c | 1 + hw/arm/b-l475e-iot01a.c | 1 + hw/arm/bananapi_m2u.c | 22 +- hw/arm/collie.c | 1 + hw/arm/cubieboard.c | 23 +- hw/arm/digic_boards.c | 19 +- hw/arm/exynos4_boards.c | 2 + hw/arm/imx25_pdk.c | 19 +- hw/arm/imx8mm-evk.c | 23 +- hw/arm/imx8mp-evk.c | 1 + hw/arm/integratorcp.c | 23 +- hw/arm/kzm.c | 19 +- hw/arm/max78000fthr.c | 19 +- hw/arm/mcimx6ul-evk.c | 19 +- hw/arm/mcimx7d-sabre.c | 23 +- hw/arm/microbit.c | 1 + hw/arm/mps2-tz.c | 5 + hw/arm/mps2.c | 4 + hw/arm/mps3r.c | 1 + hw/arm/msf2-som.c | 19 +- hw/arm/musca.c | 2 + hw/arm/netduino2.c | 19 +- hw/arm/netduinoplus2.c | 19 +- hw/arm/npcm7xx_boards.c | 5 + hw/arm/npcm8xx_boards.c | 1 + hw/arm/olimex-stm32-h405.c | 19 +- hw/arm/omap_sx1.c | 2 + hw/arm/orangepi.c | 23 +- hw/arm/raspi.c | 7 +- hw/arm/raspi4b.c | 2 +- hw/arm/realview.c | 4 + hw/arm/sabrelite.c | 1 + hw/arm/sbsa-ref.c | 1 + hw/arm/stellaris.c | 2 + hw/arm/stm32vldiscovery.c | 19 +- hw/arm/versatilepb.c | 2 + hw/arm/vexpress.c | 2 + hw/arm/virt.c | 1 + hw/arm/xen-pvh.c | 1 + hw/arm/xilinx_zynq.c | 1 + hw/arm/xlnx-versal-virt.c | 2 + hw/arm/xlnx-zcu102.c | 1 + hw/core/Kconfig | 2 +- hw/core/machine-qmp-cmds.c | 30 + hw/core/meson.build | 2 +- hw/dma/Kconfig | 4 +- hw/i2c/Kconfig | 2 +- hw/microblaze/petalogix_ml605_mmu.c | 19 +- hw/microblaze/petalogix_s3adsp1800_mmu.c | 1 + hw/microblaze/xlnx-zynqmp-pmu.c | 19 +- hw/usb/Kconfig | 2 +- include/accel/tcg/cpu-ldst.h | 4 +- include/exec/abi_ptr.h | 7 +- include/exec/helper-gen-common.h | 20 + include/exec/helper-head.h.inc | 21 +- include/exec/helper-proto-common.h | 20 + include/exec/target_long.h | 11 + include/qemu/config-file.h | 2 + include/qemu/module.h | 1 - include/qemu/target-info-def.h | 90 ++ include/qemu/target-info-impl.h | 42 - include/qemu/target-info-init.h | 53 -- include/qemu/target-info-qom.h | 30 - include/qemu/target-info-select.h | 24 + include/qemu/target-info.h | 174 +++- include/qemu/target-kconfig-has.h | 7 + include/qemu/target-kconfig.h | 34 + include/qom/object.h | 26 +- include/tcg/tcg-op-gvec.h | 21 +- include/tcg/tcg-op-mem.h | 114 ++- include/tcg/tcg-op-tl.h | 568 ++++++++++++ include/tcg/tcg-op.h | 291 +----- include/tcg/tcg.h | 73 +- meson.build | 233 ++++- page-vary-common.c | 2 +- page-vary-system.c | 2 +- qapi/machine.json | 48 +- qemu-options.hx | 11 +- qom/object.c | 20 +- scripts/gen-target-kconfig.py | 162 ++++ stubs/meson.build | 1 + stubs/target-info-select.c | 14 + system/target-info-select.c | 26 + system/vl.c | 312 ++++++- target-info-stub.c => target-info-def.c | 9 +- target-info-qom.c | 55 -- target-info.c | 180 +++- target-kconfig.c | 20 + target/arm/cpu.c | 6 +- target/arm/cpu.h | 1 + target/arm/cpu64.c | 80 +- target/arm/hvf/hvf-stub.c | 14 + target/arm/hvf/meson.build | 1 + target/arm/kvm-stub.c | 5 + target/arm/kvm.c | 36 + target/arm/kvm_arm.h | 9 + target/arm/meson.build | 4 +- target/arm/tcg/translate-a64.c | 6 +- target/arm/tcg/translate-a64.h | 3 + target/arm/tcg/translate-sme.c | 5 +- target/arm/tcg/translate-sve.c | 18 +- target/arm/whpx/whpx-stub.c | 5 + target/microblaze/meson.build | 2 +- target/none/cpu-param.h | 7 + target/none/cpu-qom.h | 6 + target/none/cpu.h | 18 + tcg/meson.build | 9 +- tcg/tcg-op-gvec.c | 17 - tcg/tcg-op-ldst.c | 31 + tcg/tcg-op.c | 32 - tcg/tcg.c | 52 +- tests/qtest/fuzz/fuzz.c | 3 - .../qtest/machine-list-combined-targets.h.in | 4 + tests/qtest/machine-list-combined-test.c | 104 +++ tests/qtest/machine-list-test.c | 94 ++ tests/qtest/machine-list-test.inc.h | 876 ++++++++++++++++++ tests/qtest/machine-option-test.c | 714 ++++++++++++++ tests/qtest/meson.build | 41 +- tests/unit/meson.build | 35 + tests/unit/test-helper-tl.c | 20 + tests/unit/test-helper-tl.h | 25 + tests/unit/test-helper-tl32.c | 27 + tests/unit/test-helper-tl64.c | 27 + tests/unit/test-target-info.c | 38 + tests/unit/test-target-kconfig-has.c | 22 + tests/unit/test-tcg-call-tl-stubs.c | 45 + tests/unit/test-tcg-call-tl.c | 280 ++++++ tests/unit/test-tcg-op-dispatch.h | 203 ++++ tests/unit/test-tcg-op-mem-config32.h | 2 + tests/unit/test-tcg-op-mem-config64.h | 2 + tests/unit/test-tcg-op-mem-tl32.c | 26 + tests/unit/test-tcg-op-mem-tl64.c | 26 + tests/unit/test-tcg-op-mem-va32-tl64.c | 35 + tests/unit/test-tcg-op-mem.c | 51 + tests/unit/test-tcg-op-tl32.c | 24 + tests/unit/test-tcg-op-tl64.c | 24 + tests/unit/test-tcg-op.c | 66 ++ util/module.c | 4 +- util/qemu-config.c | 10 +- 182 files changed, 5772 insertions(+), 1281 deletions(-) create mode 100644 accel/tcg/atomic_common.h create mode 100644 accel/tcg/cpu-exec-common.h create mode 100644 accel/tcg/cpu-exec.h create mode 100644 accel/tcg/ldst_common.h copy accel/tcg/{tcg-runtime.h => tcg-runtime-gvec.h} (70%) delete mode 100644 configs/targets/aarch64-softmmu.c delete mode 100644 configs/targets/arm-softmmu.c delete mode 100644 configs/targets/meson.build delete mode 100644 configs/targets/riscv32-softmmu.c delete mode 100644 configs/targets/riscv64-softmmu.c create mode 100644 include/qemu/target-info-def.h delete mode 100644 include/qemu/target-info-impl.h delete mode 100644 include/qemu/target-info-init.h delete mode 100644 include/qemu/target-info-qom.h create mode 100644 include/qemu/target-info-select.h create mode 100644 include/qemu/target-kconfig-has.h create mode 100644 include/qemu/target-kconfig.h create mode 100644 include/tcg/tcg-op-tl.h create mode 100644 scripts/gen-target-kconfig.py create mode 100644 stubs/target-info-select.c create mode 100644 system/target-info-select.c rename target-info-stub.c => target-info-def.c (88%) delete mode 100644 target-info-qom.c create mode 100644 target-kconfig.c create mode 100644 target/arm/hvf/hvf-stub.c create mode 100644 target/none/cpu-param.h create mode 100644 target/none/cpu-qom.h create mode 100644 target/none/cpu.h create mode 100644 tests/qtest/machine-list-combined-targets.h.in create mode 100644 tests/qtest/machine-list-combined-test.c create mode 100644 tests/qtest/machine-list-test.c create mode 100644 tests/qtest/machine-list-test.inc.h create mode 100644 tests/qtest/machine-option-test.c create mode 100644 tests/unit/test-helper-tl.c create mode 100644 tests/unit/test-helper-tl.h create mode 100644 tests/unit/test-helper-tl32.c create mode 100644 tests/unit/test-helper-tl64.c create mode 100644 tests/unit/test-target-info.c create mode 100644 tests/unit/test-target-kconfig-has.c create mode 100644 tests/unit/test-tcg-call-tl-stubs.c create mode 100644 tests/unit/test-tcg-call-tl.c create mode 100644 tests/unit/test-tcg-op-dispatch.h create mode 100644 tests/unit/test-tcg-op-mem-config32.h create mode 100644 tests/unit/test-tcg-op-mem-config64.h create mode 100644 tests/unit/test-tcg-op-mem-tl32.c create mode 100644 tests/unit/test-tcg-op-mem-tl64.c create mode 100644 tests/unit/test-tcg-op-mem-va32-tl64.c create mode 100644 tests/unit/test-tcg-op-mem.c create mode 100644 tests/unit/test-tcg-op-tl32.c create mode 100644 tests/unit/test-tcg-op-tl64.c create mode 100644 tests/unit/test-tcg-op.c -- 2.52.0.windows.1
