target: New binary to prototype heterogeneous machines
v3 cover target: New binary to prototype heterogeneous machines
Since v2:
- Run check-qtest instead of check-unit in CI (Alex)
Almost 2 years later we got hundreds of cleanups patches merged, so we can get this patch in. Building the 'any' target has to be explictly requested in ./configure target-list argument.
This binary will be use to rework QEMU startup code, paving the way toward dynamic machines. It might also allow experimenting with multiple TCG target frontends and possibly prototyping concurrent HW/SW accelerations.
The corresponding CI jobs takes <3min!!!
https://gitlab.com/philmd/qemu/-/jobs/6177909577
Duration: 2 minutes 50 seconds
v1: https://lore.kernel.org/qemu-devel/[email protected]/
v2: https://lore.kernel.org/qemu-devel/[email protected]/
Philippe Mathieu-Daudé (1):
target: Add system emulation aiming to target any architecture
configs/devices/any-softmmu/default.mak | 9 +++++++++ configs/targets/any-softmmu.mak | 3 +++ meson.build | 6 ++++-- qapi/machine.json | 2 +- include/sysemu/arch_init.h | 1 + target/any/cpu-param.h | 13 +++++++++++++ target/any/cpu-qom.h | 12 ++++++++++++ target/any/cpu.h | 24 ++++++++++++++++++++++++ .gitlab-ci.d/buildtest.yml | 20 ++++++++++++++++++++ hw/any/meson.build | 5 +++++ hw/meson.build | 1 + target/Kconfig | 1 + target/any/Kconfig | 4 ++++ target/any/meson.build | 7 +++++++ target/meson.build | 1 + 15 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 configs/devices/any-softmmu/default.mak create mode 100644 configs/targets/any-softmmu.mak create mode 100644 target/any/cpu-param.h create mode 100644 target/any/cpu-qom.h create mode 100644 target/any/cpu.h create mode 100644 hw/any/meson.build create mode 100644 target/any/Kconfig create mode 100644 target/any/meson.build
Signature · 1 line
2.41.0
PATCH v3 1/1 target: Add system emulation aiming to target any architecture
From: Philippe Mathieu-Daudé <[email protected]>
Add the 'any'-architecture target.
- Only consider 64-bit targets
- Do not use any hardware accelerator (except qtest)
- For architecture constants, use:
. max of supported targets phys/virt address space . max of supported targets MMU modes
. min of supported targets variable page bits
Build as:
$ ../configure --target-list=any-softmmu \
--disable-hvf \
--disable-kvm \
--disable-nvmm \
--disable-tcg \
--disable-whpx \
--disable-xenTest as:
$ qemu-system-any -M none,accel=qtest -monitor stdio
QEMU 6.2.50 monitor - type 'help' for more information
(qemu) info mtree
address-space: I/O
0000000000000000-000000000000ffff (prio 0, i/o): ioaddress-space: memory
0000000000000000-ffffffffffffffff (prio 0, i/o): system
(qemu) info qom-tree
/machine (none-machine)
/peripheral (container)
/peripheral-anon (container)
/unattached (container)
/io[0] (memory-region)
/sysbus (System)
/system[0] (memory-region) (qemu) info qtree
bus: main-system-bus
type System
(qemu) info cpus
(qemu)
--- configs/devices/any-softmmu/default.mak | 9 +++++++++ configs/targets/any-softmmu.mak | 3 +++ meson.build | 6 ++++-- qapi/machine.json | 2 +- include/sysemu/arch_init.h | 1 + target/any/cpu-param.h | 13 +++++++++++++ target/any/cpu-qom.h | 12 ++++++++++++ target/any/cpu.h | 24 ++++++++++++++++++++++++ .gitlab-ci.d/buildtest.yml | 20 ++++++++++++++++++++ hw/any/meson.build | 5 +++++ hw/meson.build | 1 + target/Kconfig | 1 + target/any/Kconfig | 4 ++++ target/any/meson.build | 7 +++++++ target/meson.build | 1 + 15 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 configs/devices/any-softmmu/default.mak create mode 100644 configs/targets/any-softmmu.mak create mode 100644 target/any/cpu-param.h create mode 100644 target/any/cpu-qom.h create mode 100644 target/any/cpu.h create mode 100644 hw/any/meson.build create mode 100644 target/any/Kconfig create mode 100644 target/any/meson.build
configs/devices/any-softmmu/default.mak new file +9 -0
@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +CONFIG_ISA_BUS=y +CONFIG_PCI=y +CONFIG_PCI_DEVICES=y +CONFIG_I2C=y +CONFIG_TPM=y +CONFIG_NUBUS=y +CONFIG_VIRTIO=y
configs/targets/any-softmmu.mak new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +TARGET_ARCH=any
meson.build +4 -2
@@ -46,7 +46,7 @@ qapi_trace_events = [] bsd_oses = ['gnu/kfreebsd', 'freebsd', 'netbsd', 'openbsd', 'dragonfly', 'darwin'] supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux'] supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv32', 'riscv64', 'x86', 'x86_64', - 'arm', 'aarch64', 'loongarch64', 'mips', 'mips64', 'sparc64'] + 'arm', 'aarch64', 'loongarch64', 'mips', 'mips64', 'sparc64', 'any'] cpu = host_machine.cpu_family()
@@ -3043,7 +3043,9 @@ foreach target : target_dirs if default_targets continue endif - error('No accelerator available for target @0@'.format(target)) + if 'any-softmmu' not in target_dirs + error('No accelerator available for target @0@'.format(target)) + endif endif actual_target_dirs += target
qapi/machine.json +1 -1
@@ -36,7 +36,7 @@ 'mips64el', 'mipsel', 'nios2', 'or1k', 'ppc', 'ppc64', 'riscv32', 'riscv64', 'rx', 's390x', 'sh4', 'sh4eb', 'sparc', 'sparc64', 'tricore', - 'x86_64', 'xtensa', 'xtensaeb' ] } + 'x86_64', 'xtensa', 'xtensaeb', 'any' ] } ## # @CpuS390State:
include/sysemu/arch_init.h +1 -0
@@ -4,6 +4,7 @@enum {QEMU_ARCH_ALL =-1 , +QEMU_ARCH_ANY =-1 ,QEMU_ARCH_ALPHA = (1 <<0 ),QEMU_ARCH_ARM = (1 <<1 ),QEMU_ARCH_CRIS = (1 <<2 ),
target/any/cpu-param.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef ANY_CPU_PARAM_H +#define ANY_CPU_PARAM_H + +#define TARGET_LONG_BITS 64 + +#define TARGET_PHYS_ADDR_SPACE_BITS 64/* MAX(targets) */ +#define TARGET_VIRT_ADDR_SPACE_BITS 64/* MAX(targets) */ + +#define TARGET_PAGE_BITS_VARY +#define TARGET_PAGE_BITS_MIN 10/* MIN(targets)=ARMv5/ARMv6, ignoring AVR */ + +#endif
target/any/cpu-qom.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef QEMU_DUMMY_CPU_QOM_H +#define QEMU_DUMMY_CPU_QOM_H + +#include "hw/core/cpu.h" +#include "qom/object.h" + +#define TYPE_DUMMY_CPU "dummy-cpu" + +OBJECT_DECLARE_CPU_TYPE(DUMMYCPU, CPUClass, DUMMY_CPU) + +#endif
target/any/cpu.h new file +24 -0
@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef TARGET_ANY_CPU_H +#define TARGET_ANY_CPU_H + +#include "cpu-qom.h" +#include "exec/cpu-defs.h" + +#define DUMMY_CPU_TYPE_SUFFIX "-" TYPE_DUMMY_CPU +#define DUMMY_CPU_TYPE_NAME (name) (name DUMMY_CPU_TYPE_SUFFIX) +#define CPU_RESOLVING_TYPE TYPE_DUMMY_CPU + +struct CPUArchState { +/* nothing here */ +}; + +struct ArchCPU { +CPUState parent_obj; + +CPUArchState env; +}; + +#include "exec/cpu-all.h" /* FIXME remove once exec/ headers cleaned */ + +#endif
.gitlab-ci.d/buildtest.yml +20 -0
@@ -729,3 +729,23 @@ pages: - public variables: QEMU_JOB_PUBLISH: 1 + +build-system-any: + extends: + - .native_build_job_template + needs: + - job: amd64-alpine-container + variables: + IMAGE: alpine + TARGETS: any-softmmu + MAKE_CHECK_ARGS: check-qtest + CONFIGURE_ARGS: + --disable-tools + --disable-hvf + --disable-kvm + --disable-nvmm + --disable-tcg + --disable-whpx + --disable-xen + --with-default-devices + --enable-qom-cast-debug
hw/any/meson.build new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +any_ss = ss.source_set() + +hw_arch += {'any': any_ss}
hw/meson.build +1 -0
@@ -47,6 +47,7 @@ subdir('xenpv') subdir('fsi') subdir('alpha') +subdir('any') subdir('arm') subdir('avr') subdir('cris')
target/Kconfig +1 -0
@@ -1,4 +1,5 @@ source alpha/Kconfig +source any/Kconfig source arm/Kconfig source avr/Kconfig source cris/Kconfig
target/any/Kconfig new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +config ANY + bool
target/any/meson.build new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +any_ss = ss.source_set() +any_system_ss = ss.source_set() + +target_arch += {'any': any_ss} +target_system_arch += {'any': any_system_ss}
target/meson.build +1 -0
@@ -1,4 +1,5 @@ subdir('alpha') +subdir('any') subdir('arm') subdir('avr') subdir('cris')
Signature · 1 line
2.41.0
Re: [PATCH v3 1/1] target: Add system emulation aiming to target any architecture
Quoted 21 lines · Philippe Mathieu-Daudé
From: Philippe Mathieu-Daudé <[email protected]>
Add the 'any'-architecture target.
- Only consider 64-bit targets
- Do not use any hardware accelerator (except qtest)
- For architecture constants, use:
. max of supported targets phys/virt address space . max of supported targets MMU modes
. min of supported targets variable page bitsBuild as:
$ ../configure --target-list=any-softmmu \ --disable-hvf \ --disable-kvm \ --disable-nvmm \ --disable-tcg \ --disable-whpx \ --disable-xen
Quoted 4 lines
Test as:
$ qemu-system-any -M none,accel=qtest -monitor stdio QEMU 6.2.50 monitor - type 'help' for more information
6.2.50? :)
Quoted 101 lines
(qemu) info mtree
address-space: I/O
0000000000000000-000000000000ffff (prio 0, i/o): ioaddress-space: memory
0000000000000000-ffffffffffffffff (prio 0, i/o): system(qemu) info qom-tree
/machine (none-machine)
/peripheral (container)
/peripheral-anon (container)
/unattached (container)/io[0] (memory-region) /sysbus (System) /system[0] (memory-region)(qemu) info qtree
bus: main-system-bus
type System
(qemu) info cpus
(qemu)Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
configs/devices/any-softmmu/default.mak | 9 +++++++++ configs/targets/any-softmmu.mak | 3 +++ meson.build | 6 ++++-- qapi/machine.json | 2 +- include/sysemu/arch_init.h | 1 + target/any/cpu-param.h | 13 +++++++++++++ target/any/cpu-qom.h | 12 ++++++++++++ target/any/cpu.h | 24 ++++++++++++++++++++++++ .gitlab-ci.d/buildtest.yml | 20 ++++++++++++++++++++ hw/any/meson.build | 5 +++++ hw/meson.build | 1 + target/Kconfig | 1 + target/any/Kconfig | 4 ++++ target/any/meson.build | 7 +++++++ target/meson.build | 1 + 15 files changed, 106 insertions(+), 3 deletions(-)create mode 100644 configs/devices/any-softmmu/default.mak create mode 100644 configs/targets/any-softmmu.mak create mode 100644
target/any/cpu-param.h
create mode 100644target/any/cpu-qom.h
create mode 100644target/any/cpu.h
create mode 100644 hw/any/meson.build
create mode 100644 target/any/Kconfig
create mode 100644 target/any/meson.buildconfigs/devices/any-softmmu/default.mak new file +9
-0@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +CONFIG_ISA_BUS=y +CONFIG_PCI=y +CONFIG_PCI_DEVICES=y +CONFIG_I2C=y +CONFIG_TPM=y +CONFIG_NUBUS=y +CONFIG_VIRTIO=yconfigs/targets/any-softmmu.mak new file +3
-0@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +TARGET_ARCH=anymeson.build +0
-0@@ -46,7 +46,7 @@ qapi_trace_events = []
bsd_oses= ['gnu/kfreebsd', 'freebsd', 'netbsd', 'openbsd', 'dragonfly', 'darwin']supported_oses= ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux']supported_cpus= ['ppc', 'ppc64', 's390x', 'riscv32', 'riscv64', 'x86', 'x86_64',meson.build +1
-1- 'arm', 'aarch64', 'loongarch64', 'mips', 'mips64', 'sparc64'] + 'arm', 'aarch64', 'loongarch64', 'mips', 'mips64', 'sparc64', 'any']cpu =
host_machine.cpu_family()meson.build +3
-1@@ -3043,7 +3043,9 @@ foreach target : target_dirs if default_targets continue endif - error('No accelerator available for target @0@'.format(target)) + if 'any-softmmu' not in target_dirs + error('No accelerator available for target @0@'.format(target)) + endif endif actual_target_dirs += targetqapi/machine.json +0
-0
qapi/machine.json line 39
Quoted 5 lines
qapi/machine.json +1
-1@@ -36,7 +36,7 @@ 'mips64el', 'mipsel', 'nios2', 'or1k', 'ppc', 'ppc64', 'riscv32', 'riscv64', 'rx', 's390x', 'sh4', 'sh4eb', 'sparc', 'sparc64', 'tricore', - 'x86_64', 'xtensa', 'xtensaeb' ] } + 'x86_64', 'xtensa', 'xtensaeb', 'any' ] }
This array looks alphabetically sorted (before the any), might that be on purpose?
Quoted 24 lines
qapi/machine.json +0
-0## # @CpuS390State:include/sysemu/arch_init.h +1
-0@@ -4,6 +4,7 @@enum {QEMU_ARCH_ALL =-1 , +QEMU_ARCH_ANY =-1 ,QEMU_ARCH_ALPHA = (1 <<0 ),QEMU_ARCH_ARM = (1 <<1 ),QEMU_ARCH_CRIS = (1 <<2 ),target/any/cpu-param.h new file +3
-0@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef ANY_CPU_PARAM_H +#define ANY_CPU_PARAM_H
target/any/cpu-param.h line 13
Quoted 10 lines
target/any/cpu-param.h new file +10
-0+ +#define TARGET_LONG_BITS 64 + +#define TARGET_PHYS_ADDR_SPACE_BITS 64/* MAX(targets) */ +#define TARGET_VIRT_ADDR_SPACE_BITS 64/* MAX(targets) */ + +#define TARGET_PAGE_BITS_VARY +#define TARGET_PAGE_BITS_MIN 10/* MIN(targets)=ARMv5/ARMv6, ignoring AVR */ + +#endif
Nit:
-#endif
+#endif /* ANY_CPU_PARAM_H */
(And for the other #endifs following)
Quoted 32 lines
target/any/cpu-qom.h new file +12
-0@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef QEMU_DUMMY_CPU_QOM_H +#define QEMU_DUMMY_CPU_QOM_H + +#include "hw/core/cpu.h" +#include "qom/object.h" + +#define TYPE_DUMMY_CPU "dummy-cpu" + +OBJECT_DECLARE_CPU_TYPE(DUMMYCPU, CPUClass, DUMMY_CPU) + +#endif target/any/cpu.h new file +8
-0@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef TARGET_ANY_CPU_H +#define TARGET_ANY_CPU_H + +#include "cpu-qom.h" +#include "exec/cpu-defs.h" + +#define DUMMY_CPU_TYPE_SUFFIX "-" TYPE_DUMMY_CPU
target/any/cpu.h line 18
Quoted 10 lines
target/any/cpu.h new file +10
-0+#define DUMMY_CPU_TYPE_NAME (name) (name DUMMY_CPU_TYPE_SUFFIX) +#define CPU_RESOLVING_TYPE TYPE_DUMMY_CPU + +struct CPUArchState { +/* nothing here */ +}; + +struct ArchCPU { +CPUState parent_obj; +
+ /* Properties */
?
Quoted 104 lines
target/any/cpu.h new file +6
-0+ CPUArchState env; +}; + +#include "exec/cpu-all.h" /* FIXME remove once exec/ headers cleaned */ + +#endif .gitlab-ci.d/buildtest.yml +20
-0@@ -729,3 +729,23 @@ pages: - public variables: QEMU_JOB_PUBLISH: 1 + +build-system-any: + extends: + - .native_build_job_template + needs: + - job: amd64-alpine-container + variables: + IMAGE: alpine + TARGETS: any-softmmu + MAKE_CHECK_ARGS: check-qtest + CONFIGURE_ARGS: + --disable-tools + --disable-hvf + --disable-kvm + --disable-nvmm + --disable-tcg + --disable-whpx + --disable-xen + --with-default-devices + --enable-qom-cast-debughw/any/meson.build new file +5
-0@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +any_ss = ss.source_set() + +hw_arch += {'any': any_ss}hw/meson.build +1
-0@@ -47,6 +47,7 @@ subdir('xenpv') subdir('fsi') subdir('alpha') +subdir('any') subdir('arm') subdir('avr') subdir('cris')target/Kconfig +0
-0@@ -1,4 +1,5 @@source alpha/Kconfig
+source any/Kconfig
source arm/Kconfig
source avr/Kconfig
source cris/Kconfigtarget/any/Kconfig new file +4
-0@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +config ANY + booltarget/any/meson.build new file +7
-0@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +any_ss = ss.source_set() +any_system_ss = ss.source_set() + +target_arch += {'any': any_ss} +target_system_arch += {'any': any_system_ss}target/meson.build +1
-0@@ -1,4 +1,5 @@ subdir('alpha') +subdir('any') subdir('arm') subdir('avr') subdir('cris')Signature · 1 line
2.41.0
LGTM in general overall. In case this wasn't discussed already, would it be a good idea to name the target x-any if it ends up in a stable release?
Regardless of my inlined style comments:
Re: [PATCH v3 1/1] target: Add system emulation aiming to target any architecture
Quoted 22 lines · Manos Pitsidianakis
Quoted 21 lines · Philippe Mathieu-Daudé
From: Philippe Mathieu-Daudé <[email protected]>
Add the 'any'-architecture target.
- Only consider 64-bit targets
- Do not use any hardware accelerator (except qtest)
- For architecture constants, use:
. max of supported targets phys/virt address space . max of supported targets MMU modes
. min of supported targets variable page bitsBuild as:
$ ../configure --target-list=any-softmmu \ --disable-hvf \ --disable-kvm \ --disable-nvmm \ --disable-tcg \ --disable-whpx \ --disable-xen
Quoted 6 lines
Quoted 4 lines
Test as:
$ qemu-system-any -M none,accel=qtest -monitor stdio QEMU 6.2.50 monitor - type 'help' for more information6.2.50? :)
Time passed...
Quoted 1 line
LGTM in general overall. In case this wasn't discussed already, would it be a good idea to name the target x-any if it ends up in a stable release?
This will end in stable releases. Do you mean distribution releases? They don't include qemu-system-all and we don't use x-all. Why would a distrib want to include a pointless binary? :)
Quoted 3 lines
Regardless of my inlined style comments:
Reviewed-by Manos Pitsidianakis <[email protected]>
Thanks!
Forgot to Cc Anton :/
Quoted 22 lines · Philippe Mathieu-Daudé
Since v2:
- Run check-qtest instead of check-unit in CI (Alex)Almost 2 years later we got hundreds of cleanups patches merged, so we can get this patch in. Building the 'any' target has to be explictly requested in ./configure target-list argument.
This binary will be use to rework QEMU startup code, paving the way toward dynamic machines. It might also allow experimenting with multiple TCG target frontends and possibly prototyping concurrent HW/SW accelerations.
The corresponding CI jobs takes <3min!!!
https://gitlab.com/philmd/qemu/-/jobs/6177909577
Duration: 2 minutes 50 secondsv1: https://lore.kernel.org/qemu-devel/[email protected]/
v2: https://lore.kernel.org/qemu-devel/[email protected]/Philippe Mathieu-Daudé (1):
target: Add system emulation aiming to target any architecture