Skip to content

exec/cpu: Call cpu_exec_realizefn() once in cpu_common_realize()

Philippe Mathieu-Daudé kvm qemu-arm qemu-devel qemu-riscv 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest22 patches 29 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/22target/i386: Only realize existing APIC devicetarget/i386/cpu-sysemu.c target/i386/cpu.c+8 -92 replies
2/22hw/intc/apic: Pass CPU using QOM link propertyhw/intc/apic_common.c target/i386/cpu-sysemu.c+8 -52 replies
3/22target/i386/kvm: Correct comment in kvm_cpu_realize()target/i386/kvm/kvm-cpu.c+1 -02 replies
4/22exec/cpu: Never call cpu_reset() before cpu_realize()target/arm/cpu.c target/avr/cpu.c target/cris/cpu.c +12 more+15 -162 replies
5/22exec/cpu: Call qemu_init_vcpu() once in cpu_common_realize()hw/core/cpu-common.c target/alpha/cpu.c target/arm/cpu.c +19 more+4 -362 replies
6/22exec/cpu: Call cpu_remove_sync() once in cpu_common_unrealize()hw/core/cpu-common.c target/i386/cpu.c target/ppc/cpu_init.c+3 -35 replies
7/22exec/cpu: Introduce the CPU address space destruction functioninclude/exec/cpu-common.h include/hw/core/cpu.h softmmu/physmem.c+33 -02 replies
8/22exec/cpu: RFC Destroy vCPU address spaces in cpu_common_unrealize()hw/core/cpu-common.c+5 -01 reply
9/22target/arm: Create timers *after* accelerator vCPU is realizedtarget/arm/cpu.c+8 -61 reply
10/22target/hppa: Create timer *after* accelerator vCPU is realizedtarget/hppa/cpu.c+2 -21 reply
11/22target/nios2: Create IRQs *after* accelerator vCPU is realizedtarget/nios2/cpu.c+8 -81 reply
12/22target/mips: Create clock *after* accelerator vCPU is realizedtarget/mips/cpu.c+14 -141 reply
13/22target/xtensa: Create IRQs *after* accelerator vCPU is realizedtarget/xtensa/cpu.c+4 -41 reply
14/22target/sparc: Init CPU environment *after* accelerator vCPU is realizedtarget/sparc/cpu.c+6 -61 reply
15/22exec/cpu: Introduce CPUClass::verify_accel_features()cpu.c include/hw/core/cpu.h+9 -01 reply
16/22target/arm: Extract verify_accel_features() from cpu_realize()target/arm/cpu.c+24 -171 reply
17/22target/i386: Extract verify_accel_features() from cpu_realize()target/i386/cpu.c+36 -260 replies
18/22target/s390x: Call s390_cpu_realize_sysemu from s390_realize_cpu_modeltarget/s390x/cpu-sysemu.c target/s390x/cpu.c target/s390x/cpu_models.c +1 more+6 -91 reply
19/22target/s390x: Have s390_realize_cpu_model() return a booleantarget/s390x/cpu.c target/s390x/cpu_models.c target/s390x/s390x-internal.h+9 -80 replies
20/22target/s390x: Use s390_realize_cpu_model() as verify_accel_features()target/s390x/cpu.c+1 -50 replies
21/22exec/cpu: Have cpu_exec_realize() return a booleancpu.c include/hw/core/cpu.h+5 -31 reply
22/22exec/cpu: Call cpu_exec_realizefn() once in cpu_common_realize()hw/core/cpu-common.c target/alpha/cpu.c target/arm/cpu.c +20 more+8 -1501 reply

Reviews trailers per patch

12 of 22 patches have a Reviewed-by or Acked-by.

PatchSalil MehtaRichard HendersonIgor Mammedov
1/22
2/22R-b R-b
3/22R-b R-b
4/22R-b
5/22R-b
6/22R-b
7/22Co-authored-by
8/22
9/22R-b
10/22
11/22R-b
12/22R-b
13/22R-b
14/22R-b
15/22R-b
16/22
17/22
18/22
19/22
20/22
21/22R-b
22/22

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [PATCH 00/22] exec/cpu: Call cpu_exec_realizefn() once in cpu_common_realize()

Hi,

TL;DR: This series factor duplicated common code in CPUs DeviceRealize() handlers out, moving as a single call in cpu_common_realize().

In an effort to have most of:
- CPU core code independant of accelerators
- CPU core code target agnostic
- CPU target code independant of accelerators
- and cpu_reset() called automatically without having to rely on global QEMUResetHandler,
I'm working on the core CPU code, unfortunately touching files in all targets.

I suppose them term "exec" used in various areas of QEMU started from what we call today "accel[erators]" [*]. So cpu_exec_realizefn() can be read as cpu_accel_realize(), or "generic code where an accelerator realizes its internal fields on an abstract (target independent) CPU".

This series moves a common pattern used in all target's cpu_realize() handlers to the common cpu_exec_realizefn().

Some optional code is used to check CPU requested features are compatible with the accelerator possibilities. We extracted this code as CPUClass::verify_accel_features() handler. Better name welcomed :)

Some targets were calling cpu_reset() *before* cpu_common_realizefn(), we moved it *after* (since RESET shouldn't happen before REALIZE). I still have to audit each target to confirm there are no side effects. Besides this cpu_reset() change, the rest should be relatively trivial to review, still I'd like feedback from the respective target maintainers for the "move HW creation after vCPU one" patches.

Regards,

Phil.

Follow-up: Make cpu_reset() accel-agnostic and move it
to cpu_common_realize() (not trivial due to KVM run_on_cpu() calls).

[*] If Paolo/Richard confirm, I might post series renaming
various APIs s/exec/accel/, because various headers meaning aren't clear to me.

Philippe Mathieu-Daudé (21):
target/i386: Only realize existing APIC device hw/intc/apic: Pass CPU using QOM link property target/i386/kvm: Correct comment in kvm_cpu_realize() exec/cpu: Never call cpu_reset() before cpu_realize() exec/cpu: Call qemu_init_vcpu() once in cpu_common_realize() exec/cpu: Call cpu_remove_sync() once in cpu_common_unrealize() exec/cpu: RFC Destroy vCPU address spaces in cpu_common_unrealize() target/arm: Create timers *after* accelerator vCPU is realized target/hppa: Create timer *after* accelerator vCPU is realized target/nios2: Create IRQs *after* accelerator vCPU is realized target/mips: Create clock *after* accelerator vCPU is realized target/xtensa: Create IRQs *after* accelerator vCPU is realized target/sparc: Init CPU environment *after* accelerator vCPU is
realized
exec/cpu: Introduce CPUClass::verify_accel_features() target/arm: Extract verify_accel_features() from cpu_realize() target/i386: Extract verify_accel_features() from cpu_realize() target/s390x: Call s390_cpu_realize_sysemu from s390_realize_cpu_model target/s390x: Have s390_realize_cpu_model() return a boolean target/s390x: Use s390_realize_cpu_model() as verify_accel_features() exec/cpu: Have cpu_exec_realize() return a boolean exec/cpu: Call cpu_exec_realizefn() once in cpu_common_realize()

xianglai li (1):
exec/cpu: Introduce the CPU address space destruction function

 include/exec/cpu-common.h     |  8 ++++
 include/hw/core/cpu.h         |  7 +++-
 target/s390x/s390x-internal.h |  4 +-
 cpu.c                         | 11 ++++-
 hw/core/cpu-common.c          | 15 +++++++
 hw/intc/apic_common.c         |  2 +
 softmmu/physmem.c             | 24 +++++++++++
 target/alpha/cpu.c            | 10 -----
 target/arm/cpu.c              | 53 ++++++++++++------------
 target/avr/cpu.c              | 10 +----
 target/cris/cpu.c             | 11 +----
 target/hexagon/cpu.c          | 11 +----
 target/hppa/cpu.c             | 20 ++-------
 target/i386/cpu-sysemu.c      | 20 ++++-----
 target/i386/cpu.c             | 77 ++++++++++++++++++-----------------
 target/i386/kvm/kvm-cpu.c     |  3 +-
 target/loongarch/cpu.c        | 11 +----
 target/m68k/cpu.c             | 11 +----
 target/microblaze/cpu.c       |  9 ----
 target/mips/cpu.c             | 27 ++++--------
 target/nios2/cpu.c            | 20 +++------
 target/openrisc/cpu.c         | 11 +----
 target/ppc/cpu_init.c         |  8 ----
 target/riscv/cpu.c            | 10 +----
 target/rx/cpu.c               | 11 +----
 target/s390x/cpu-sysemu.c     |  3 +-
 target/s390x/cpu.c            | 21 +---------
 target/s390x/cpu_models.c     | 16 +++++---
 target/sh4/cpu.c              | 11 +----
 target/sparc/cpu.c            | 10 -----
 target/tricore/cpu.c          | 10 +----
 target/xtensa/cpu.c           | 13 +-----
 32 files changed, 189 insertions(+), 299 deletions(-)
Signature · 1 line
2.41.0