A multi-target system binary links more than one target, so each one needs an
accel-$cpu_type parent. accel-cpu-target.c registers that parent from a static
type_init. The name is "accel-" plus CPU_RESOLVING_TYPE. System targets for arm,
riscv, sh4, and xtensa share one CPU_RESOLVING_TYPE, so those bases build the
file once per TARGET_BASE_ARCH and link that object into every system target of
the base. User-mode and every other system target compile it once per target.
The constructor is static, so more than one copy can be linked.

test-multi-target checks that each target's accel parent exists after QOM init.

This is an alternative to gating accelerator CPU types with is_available. The
RISC-V TCG and KVM gates are reverted here as redundant.

v2: 
https://lore.kernel.org/qemu-devel/[email protected]/

Changes v2 -> v3:

- Drop accel_register_cpu_type() and the bool array keyed by SysEmuTarget.
  Register the parent from a static type_init in accel-cpu-target.c
- Build that file once per TARGET_BASE_ARCH for system targets that share
  CPU_RESOLVING_TYPE (arm, riscv, sh4, and xtensa), and link that one object
  into every system target of the base. v2 compiled accel-target.c once per
  target and skipped a second register
- Compile it once per target for user-mode and for every other system target.
  The static constructor lets a multi-target binary link those copies when the
  type names differ
- Check the accel parent from test_qom_types_are_unique(). v2 used a separate
  accel-cpu-parent-per-target test

Yonggang Luo (3):
  accel: register CPU parent once per target base arch
  Revert "target/riscv/kvm: restrict kvm-accel-riscv-cpu to riscv
    targets"
  Revert "target/riscv/tcg: restrict tcg-accel-riscv-cpu to riscv
    targets"

 accel/accel-common.c           | 15 ---------------
 accel/accel-cpu-target.c       | 27 +++++++++++++++++++++++++++
 meson.build                    | 32 ++++++++++++++++++++++++++++++++
 target/riscv/kvm/kvm-cpu.c     |  2 --
 target/riscv/tcg/tcg-cpu.c     |  1 -
 tests/unit/test-multi-target.c | 10 ++++++++++
 6 files changed, 69 insertions(+), 18 deletions(-)
 create mode 100644 accel/accel-cpu-target.c

-- 
2.55.0.windows.3


Reply via email to