Skip to content

Multi Architecture System Emulation

Peter Crosthwaite qemu-devel 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest34 of 35 patches 18 repliesIn review
  2. v2 RFC34 patches 64 repliesSuperseded
  3. v1 RFC34 patches 25 repliesSuperseded

Changes in v3 from the cover letter

Many changes, individual commit messages have details.
Split off prepatory work for CPU virtualisation to new patches Applied mechanical changes to all target-* where possible Improved cpu.h multi-inclusion support.
Major rewrite of the CPU interface virtualisation system. Rebase on hard-freeze merges (a lot of prep work + some content from v2 is
now in).

34 of 35 patches are in this archive. The cover letter announces 35.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/35cpu-exec: Migrate some generic fns to cpu-exec-commonMakefile.target cpu-exec-common.c cpu-exec.c+77 -492 replies
2/35translate: Listify tcg_exec_init()Makefile.target include/qemu-common.h translate-all.c +1 more+58 -11 reply
3/35translate-all: Move tcg_handle_interrupt() to -commontranslate-all.c translate-common.c+35 -300 replies
4/35tcg: split tcg_op_defs to -commonMakefile.target tcg/tcg-common.c tcg/tcg.c +1 more+35 -80 replies
5/35tcg: Move tcg_tb_ptr to -commontcg/tcg-common.c tci.c+2 -60 replies
6/35translate: move real_host_page setting to -commontranslate-all.c translate-common.c+3 -20 replies
7/35cpus: Listify cpu_list() functioncpu-exec-common.c cpus.c include/sysemu/cpus.h+39 -80 replies
8/35translate-common: Listify tcg_enabled()include/qemu-common.h translate-all.c translate-common.c+53 -00 replies
9/35core: Convert tcg_enabled() users to tcg_(any|all)_enabled()cpus.c exec.c include/exec/ram_addr.h +1 more+10 -90 replies
10/35exec-all: Move cpu_can_do_io() to qom/cpu.hinclude/exec/exec-all.h include/qom/cpu.h+21 -210 replies
11/35cputlb: move CPU_LOOP() for tlb_reset() to exec.ccputlb.c exec.c include/exec/cputlb.h+17 -170 replies
12/35cputlb: Change tlb_set_dirty() arg to cpucputlb.c exec.c include/exec/cputlb.h+4 -40 replies
13/35include/exec: Move cputlb exec.c defs outexec.c include/exec/cputlb.h include/exec/exec-all.h+18 -170 replies
14/35cpu-common: Define tb_page_addr_t for everyoneinclude/exec/cpu-common.h include/exec/exec-all.h include/qom/cpu.h+5 -20 replies
15/35include/exec: Split target_long def to new headerinclude/exec/cpu-defs.h include/exec/target-long.h+55 -224 replies
16/35cpu-defs: Allow multiple inclusionsinclude/exec/cpu-defs.h+47 -160 replies
17/35monitor: uninclude cpu_ldstmonitor.c+0 -10 replies
18/35target-*: Don't redefine cpu_exec()include/exec/cpu-all.h linux-user/main.c target-alpha/cpu.h +16 more+16 -471 reply
19/35target-*: cpu.h: Undefine core code symbolsinclude/exec/cpu-defs-clear.h target-alpha/cpu.h target-arm/cpu.h +15 more+56 -00 replies
20/35Makefile.target: Introduce arch-objMakefile.target target-alpha/Makefile.objs target-cris/Makefile.objs +13 more+99 -762 replies
21/35core: virtualise CPU interfaces completelycpus.c exec.c gdbstub.c +4 more+105 -220 replies
22/35core: Introduce multi-arch buildarch_init.c configure default-configs/multi-softmmu.mak +3 more+49 -30 replies
23/35arm: cpu: static inline cpu_arm_init()target-arm/cpu.h target-arm/helper.c+5 -60 replies
24/35target-arm: Split cp helper API to new C filetarget-arm/Makefile.objs target-arm/cp.c target-arm/helper.c+329 -3241 reply
25/35arm: register cpu_list() functiontarget-arm/cpu.h target-arm/helper.c+4 -30 replies
26/35arm: enable multi-archmulti-support/aarch64 target-arm/Makefile.objs target-arm/cp.c +5 more+390 -3411 reply
27/35hw: arm: Explicitly include cpu.h for consumershw/arm/strongarm.h include/hw/arm/arm.h include/hw/arm/digic.h +3 more+13 -00 replies
28/35arm: Remove ELF_MACHINE from cpu.hhw/arm/armv7m.c linux-user/elfload.c target-arm/cpu.h+3 -32 replies
29/35hw: mb: Explicitly include cpu.h for consumershw/microblaze/boot.h+2 -00 replies
30/35mb: Remove ELF_MACHINE from cpu.hhw/microblaze/boot.c linux-user/elfload.c target-microblaze/cpu.h+3 -40 replies
31/35microblaze: enable multi-archmulti-support/microblazeel target-microblaze/Makefile.objs target-microblaze/cpu-qom.h +2 more+31 -72 replies
32/35arm: boot: Don't assume all CPUs are ARMhw/arm/boot.c+6 -20 replies
34/35HACK: mb: boot: Assume using -firmware for mb softwarehw/microblaze/boot.c+4 -00 replies
35/35HACK: mb: boot: Disable dtb load in multi-archhw/microblaze/boot.c+4 -00 replies

Reviews trailers per patch

4 of 34 patches have a Reviewed-by or Acked-by.

PatchRichard Henderson
1/35
2/35R-b
3/35R-b
4/35
5/35
6/35
7/35
8/35
9/35
10/35R-b
11/35
12/35
13/35R-b
14/35
15/35
16/35
17/35
18/35
19/35
20/35
21/35
22/35
23/35
24/35
25/35
26/35
27/35
28/35
29/35
30/35
31/35
32/35
34/35
35/35

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [Qemu-devel] [PATCH v3 00/35] Multi Architecture System Emulation

Hi All,

This is target-multi, a system-mode build that can support multiple cpu-types.

Two architectures are initially converted. Microblaze and ARM. Step by step conversion in done for each. A microblaze is added to Xilinx Zynq platform as a test case. This will be elaborted more in future spins. This use case is valid, as Microblazes can be added (any number of them!) in Zynq FPGA programmable logic configuration.

The general approach (radically different to approach in V1 RFC) is to build and prelink an object (arch-obj.o) per-arch containing:

1: target-foo/*
2: All uses of env internals and CPU_GET_ENV
* cputlb, translate-all, cpu-exec
* TCG backend

This means cputlb and friends are compiled multiple times fo each arch. The symbols for each of these pre-links are then localised to avoid link time name collisions. This is based on Paolo's suggestion to templatify cputlb and friends. Just the net of what to multi-compile is widened to include the TCG stuff as well now.

Despite being some "major surgery" this approach actually solves many of big the problems raised in V1. Big problems sovled:

1: With the multi-compile TCG backends there are now multiple tcg_ctx's for each architecture. This solves the issue PMM raised WRT false positives on TB hashing as archs no longer share translation context.

2: There is no longer a need to reorder the CPU_COMMON within the ENV or the ENV within the CPU. This was flagged as a performance issue by multiple people in V1. All users of the env internals as well as ENV_GET_CPU are now in multi-compile code and so multi-arch does not need to define a generic ENV nor does in need to def the problematic ENV_GET_CPU.

3: With the prelink symbol localisation, link time namespace collision of helpers from multiple arches is no longer an issue. No need to bloat all the function names with arch specific prefixes.

4: The architecture specifics used/defined by cpu-defs can now vary from arch to arch (incl. target_ulong) greatly reducing coversion effort needed. The list of restrictions for multi-arch capability is much reduced since V1. No target_long issues anymore.

include/exec/*.h and some of the common code needs some refactoring to setup this single vs multi compile split. Mostly code movements.

Some functions (like tcg_enabled) need to be listified for each of the now-multiple TCG engines.

The interface between the multi compile and single compiled files needs to be virtualised using QOM cpu functions. But this is now a very low footprint change as most of the virtualised hooks are now in mutli-compiled code (they only exist as text once). There are more new hooks than before, but the per target change pattern is reduced.

For the implementation of the series, the trickiest part is (still) cpu.h inclusion management. There are now more than one cpu.h's and different parts of the tree need a different include scheme. target-multi defines it's own cpu.h which is bare minimum defs as needed by core code only. target-foo/cpu.h are mostly the same but refactored to avoid collisions with other cpu.h's. Inclusion scheme goes something like
this (for the multi-arch build):

*: Core code includes only target-multi/cpu.h
*: target-foo/ implementation code includes target-foo/cpu.h locally *: System level code (e.g. mach models) can use multiple target-foo/cpu.h's

The hardest unasnwered Q is (still) what to do about bootloading. Currently each arch has it's own architecture specific bootloading which may assume a single architecture. I have applied some hacks to at least get this RFC testable using a -kernel -firmware split but going forward being able to associate an elf/image with a cpu explictitly needs to be solved.

No support for KVM, im not sure if a mix of TCG and KVM is supported even for a single arch? (which would be prerequisite to MA KVM).

Depends (not heavily) on some already on list patches:

cef6466141     configure: factor out adding disas configure               
5caa2ae307     disas: Defeature print_target_address                       R:rth
b49c8a6428     cpu_defs: Simplify CPUTLB padding logic                     R:rth Q:paolo

These deps do not really inhibit at least a high level review of this series.

Regards,
Peter

Changed since v2:
Many changes, individual commit messages have details.
Split off prepatory work for CPU virtualisation to new patches Applied mechanical changes to all target-* where possible Improved cpu.h multi-inclusion support.
Major rewrite of the CPU interface virtualisation system. Rebase on hard-freeze merges (a lot of prep work + some content from v2 is
now in).

Changed since v1:
Near total rewrite.

Peter Crosthwaite (35):
cpu-exec: Migrate some generic fns to cpu-exec-common
translate: Listify tcg_exec_init()
translate-all: Move tcg_handle_interrupt() to -common
tcg: split tcg_op_defs to -common
tcg: Move tcg_tb_ptr to -common
translate: move real_host_page setting to -common
cpus: Listify cpu_list() function
translate-common: Listify tcg_enabled()
core: Convert tcg_enabled() users to tcg_(any|all)_enabled()
exec-all: Move cpu_can_do_io() to qom/cpu.h
cputlb: move CPU_LOOP() for tlb_reset() to exec.c
cputlb: Change tlb_set_dirty() arg to cpu include/exec: Move cputlb exec.c defs out
cpu-common: Define tb_page_addr_t for everyone include/exec: Split target_long def to new header
cpu-defs: Allow multiple inclusions
monitor: uninclude cpu_ldst
target-*: Don't redefine cpu_exec()
target-*: cpu.h: Undefine core code symbols Makefile.target: Introduce arch-obj
core: virtualise CPU interfaces completely
core: Introduce multi-arch build
arm: cpu: static inline cpu_arm_init()
target-arm: Split cp helper API to new C file
arm: register cpu_list() function
arm: enable multi-arch
hw: arm: Explicitly include cpu.h for consumers
arm: Remove ELF_MACHINE from cpu.h
hw: mb: Explicitly include cpu.h for consumers
mb: Remove ELF_MACHINE from cpu.h
microblaze: enable multi-arch
arm: boot: Don't assume all CPUs are ARM
arm: xilinx_zynq: Add a Microblaze
HACK: mb: boot: Assume using -firmware for mb software
HACK: mb: boot: Disable dtb load in multi-arch

 Makefile.target                   |  38 ++++-
 arch_init.c                       |   4 +-
 configure                         |  29 +++-
 cpu-exec-common.c                 | 108 ++++++++++++
 cpu-exec.c                        |  49 ------
 cpus.c                            |  16 +-
 cputlb.c                          |  30 ++--
 default-configs/multi-softmmu.mak |   2 +
 exec.c                            |  38 +++--
 gdbstub.c                         |   2 +-
 hw/arm/armv7m.c                   |   2 +-
 hw/arm/boot.c                     |   8 +-
 hw/arm/strongarm.h                |   2 +
 hw/arm/xilinx_zynq.c              |  15 ++
 hw/microblaze/boot.c              |  12 +-
 hw/microblaze/boot.h              |   2 +
 include/exec/cpu-all.h            |   2 +
 include/exec/cpu-common.h         |   2 +
 include/exec/cpu-defs-clear.h     |  33 ++++
 include/exec/cpu-defs.h           |  84 +++++-----
 include/exec/cputlb.h             |  16 --
 include/exec/exec-all.h           |  46 +++---
 include/exec/ram_addr.h           |   5 +-
 include/exec/target-long.h        |  54 ++++++
 include/hw/arm/arm.h              |   3 +
 include/hw/arm/digic.h            |   2 +
 include/hw/arm/exynos4210.h       |   2 +
 include/hw/arm/omap.h             |   2 +
 include/hw/arm/pxa.h              |   2 +
 include/qemu-common.h             |   6 +
 include/qom/cpu.h                 | 101 ++++++++++++
 include/sysemu/arch_init.h        |   1 +
 include/sysemu/cpus.h             |   7 +
 linux-user/elfload.c              |   3 +
 linux-user/main.c                 |  28 ++--
 memory.c                          |   8 +-
 monitor.c                         |   5 +-
 multi-support/aarch64             |   0
 multi-support/microblazeel        |   0
 target-alpha/Makefile.objs        |   8 +-
 target-alpha/cpu.h                |   3 +-
 target-arm/Makefile.objs          |  24 +--
 target-arm/cpu-qom.h              |   2 +
 target-arm/cpu.c                  |   2 +
 target-arm/cpu.h                  |  58 ++++++-
 target-arm/helper.c               | 334 +-------------------------------------
 target-arm/hw/Makefile.objs       |   1 +
 target-arm/hw/cp.c                | 328 +++++++++++++++++++++++++++++++++++++
 target-cris/Makefile.objs         |   6 +-
 target-cris/cpu.h                 |   3 +-
 target-i386/Makefile.objs         |  14 +-
 target-i386/cpu.h                 |   3 +-
 target-lm32/Makefile.objs         |   8 +-
 target-lm32/cpu.h                 |   4 +-
 target-m68k/Makefile.objs         |   6 +-
 target-m68k/cpu.h                 |   4 +-
 target-microblaze/Makefile.objs   |   6 +-
 target-microblaze/cpu-qom.h       |   2 +
 target-microblaze/cpu.c           |   2 +
 target-microblaze/cpu.h           |  31 +++-
 target-mips/Makefile.objs         |   8 +-
 target-mips/cpu.h                 |   4 +-
 target-moxie/Makefile.objs        |   4 +-
 target-moxie/cpu.h                |   3 +-
 target-multi/cpu.h                |  16 ++
 target-multi/helper.h             |   0
 target-openrisc/Makefile.objs     |   8 +-
 target-openrisc/cpu.h             |   4 +-
 target-ppc/Makefile.objs          |  30 ++--
 target-ppc/cpu.h                  |   3 +-
 target-s390x/Makefile.objs        |  10 +-
 target-s390x/cpu.h                |   3 +-
 target-sh4/Makefile.objs          |   4 +-
 target-sh4/cpu.h                  |   3 +-
 target-sparc/Makefile.objs        |  14 +-
 target-sparc/cpu.h                |   3 +-
 target-tricore/Makefile.objs      |   2 +-
 target-tricore/cpu.h              |   3 +-
 target-unicore32/Makefile.objs    |   6 +-
 target-unicore32/cpu.h            |   3 +-
 target-xtensa/Makefile.objs       |  12 +-
 target-xtensa/cpu.h               |   4 +-
 tcg/tcg-common.c                  |  34 ++++
 tcg/tcg.c                         |   8 +-
 tcg/tci/tcg-target.c              |   2 +-
 tci.c                             |   6 -
 translate-all.c                   |  44 ++---
 translate-common.c                | 131 +++++++++++++++
 88 files changed, 1276 insertions(+), 714 deletions(-)
 create mode 100644 cpu-exec-common.c
 create mode 100644 default-configs/multi-softmmu.mak
 create mode 100644 include/exec/cpu-defs-clear.h
 create mode 100644 include/exec/target-long.h
 create mode 100644 multi-support/aarch64
 create mode 100644 multi-support/microblazeel
 create mode 100644 target-arm/hw/Makefile.objs
 create mode 100644 target-arm/hw/cp.c
 create mode 100644 target-multi/cpu.h
 create mode 100644 target-multi/helper.h
 create mode 100644 tcg/tcg-common.c
 create mode 100644 translate-common.c
Signature · 1 line
1.9.1