[PATCH v2 0/3] Register accel-$cpu_type for all targets

Yonggang Luo posted 3 patches 3 weeks, 4 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20261028063049.2530-1-luoyonggang@gmail.com
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>, Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, Chao Liu <chao.liu@processmission.com>
There is a newer version of this series
accel/accel-common.c           | 31 ++++++++++++++++++++++++++++---
accel/accel-internal.h         |  2 ++
accel/accel-target.c           | 21 +++++++++++++++++++++
accel/meson.build              |  1 +
target/riscv/kvm/kvm-cpu.c     |  2 --
target/riscv/tcg/tcg-cpu.c     |  1 -
tests/unit/test-multi-target.c | 22 ++++++++++++++++++++++
7 files changed, 74 insertions(+), 6 deletions(-)
create mode 100644 accel/accel-target.c
[PATCH v2 0/3] Register accel-$cpu_type for all targets
Posted by Yonggang Luo 3 weeks, 4 days ago
A multi-target system binary links more than one target, so each one needs an
accel-$cpu_type parent. accel-target.c is compiled once per target and calls
accel_register_cpu_type() with that target's SysEmuTarget and
CPU_RESOLVING_TYPE. A bool array keyed by SysEmuTarget records which arch
already registered. Targets that share one CPU_RESOLVING_TYPE reuse the parent
from the earlier arch.

linux-user still contains a single target and does not expose a target list in
QOM, so it registers one accel-$cpu_type parent.

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.

Changes v1 -> v2:

- Drop the cached QOM target list. v1 walked that list in
  accel_system_register_types() and registered one accel-$cpu_type per distinct
  cpu_type
- Compile accel-target.c once per target and call accel_register_cpu_type() with
  that target's SysEmuTarget and CPU_RESOLVING_TYPE. Targets that share one
  CPU_RESOLVING_TYPE reuse the parent from the earlier arch
- Register the linux-user parent from that same per-target file. v1 kept a
  type_init in accel-user.c that called target_cpu_type()
- Revert the RISC-V TCG and KVM is_available gates, now that every linked target
  registers its parent

Yonggang Luo (3):
  accel: register CPU parent for each target
  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           | 31 ++++++++++++++++++++++++++++---
 accel/accel-internal.h         |  2 ++
 accel/accel-target.c           | 21 +++++++++++++++++++++
 accel/meson.build              |  1 +
 target/riscv/kvm/kvm-cpu.c     |  2 --
 target/riscv/tcg/tcg-cpu.c     |  1 -
 tests/unit/test-multi-target.c | 22 ++++++++++++++++++++++
 7 files changed, 74 insertions(+), 6 deletions(-)
 create mode 100644 accel/accel-target.c

-- 
2.55.0.windows.3