Skip to content

cpus: Step toward removing global 'first_cpu'

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 Latest19 patches 7 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/19cpus: Add argument to qemu_get_cpu() to filter CPUs by QOM typecpu-common.c hw/arm/boot.c hw/arm/fsl-imx7.c +33 more+66 -615 replies
2/19cpus: Filter for target specific CPU (generic)hw/arm/boot.c hw/arm/pxa2xx_gpio.c hw/arm/sbsa-ref.c +11 more+22 -220 replies
3/19cpus: Filter for target specific CPU (arm)hw/arm/fsl-imx7.c hw/arm/sbsa-ref.c hw/arm/vexpress.c +4 more+9 -80 replies
4/19cpus: Filter for target specific CPU (loongarch)hw/loongarch/virt.c+2 -20 replies
5/19cpus: Filter for target specific CPU (mips)target/mips/tcg/sysemu/cp0_helper.c+1 -10 replies
6/19cpus: Filter for target specific CPU (s390x)hw/s390x/ipl.c hw/s390x/s390-virtio-ccw.c+2 -20 replies
7/19cpus: Filter for target specific CPU (riscv)hw/intc/sifive_plic.c hw/riscv/boot.c hw/riscv/opentitan.c+4 -40 replies
8/19cpus: Filter for target specific CPU (ppc)hw/ppc/e500.c hw/ppc/ppce500_spin.c+2 -20 replies
9/19cpus: Filter for target specific CPU (x86)hw/hyperv/hyperv.c hw/i386/kvm/xen_evtchn.c target/i386/kvm/xen-emu.c +1 more+13 -130 replies
10/19cpus: Replace first_cpu by qemu_get_cpu(0, TYPE_ARM_CPU)hw/arm/aspeed.c hw/arm/bananapi_m2u.c hw/arm/boot.c +19 more+58 -381 reply
11/19cpus: Replace first_cpu by qemu_get_cpu(0, TYPE_POWERPC_CPU)hw/ppc/e500.c hw/ppc/ppc.c hw/ppc/prep_systemio.c +6 more+21 -190 replies
12/19cpus: Replace first_cpu by qemu_get_cpu(0, TYPE_MIPS_CPU)hw/intc/mips_gic.c hw/mips/bootloader.c hw/mips/cps.c +7 more+20 -170 replies
13/19cpus: Replace first_cpu by qemu_get_cpu(0, TYPE_M68K_CPU)hw/intc/m68k_irqc.c+1 -10 replies
14/19cpus: Replace first_cpu by qemu_get_cpu(0, TYPE_S390X_CPU)hw/s390x/ipl.c+1 -10 replies
15/19cpus: Replace first_cpu by qemu_get_cpu(0, TYPE_RISCV_CPU)hw/riscv/boot.c target/riscv/arch_dump.c+3 -30 replies
16/19cpus: Replace first_cpu by qemu_get_cpu(0, TYPE_TRICORE_CPU)hw/tricore/triboard.c+1 -10 replies
17/19cpus: Replace first_cpu by qemu_get_cpu(0, TYPE_SUPERH_CPU)hw/intc/sh_intc.c+4 -20 replies
18/19cpus: Replace first_cpu by qemu_get_cpu(0, TYPE_RX_CPU)hw/rx/rx-gdbsim.c+2 -20 replies
19/19cpus: Replace first_cpu by qemu_get_cpu(0, TYPE_X86_CPU)hw/i386/kvm/clock.c hw/i386/kvmvapic.c hw/i386/microvm.c +7 more+21 -180 replies

Reviews trailers per patch

1 of 19 patches has a Reviewed-by or Acked-by.

PatchCédric Le Goater
1/19
2/19
3/19
4/19
5/19
6/19
7/19
8/19
9/19
10/19R-b
11/19
12/19
13/19
14/19
15/19
16/19
17/19
18/19
19/19

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

Read the v1 thread

Cover letter [PATCH 00/19] cpus: Step toward removing global 'first_cpu'

Heterogeneous machines have different type of CPU. In that context, both 'first_cpu' and qemu_get_cpu(index) don't make much sense.

This series first add a 'filter CPU type' argument to qemu_get_cpu(), so the behavior respects what we currently expect, then replace 'first_cpu' by a qemu_get_cpu(0) call.

Testing pass, but I'm still unsure about performance impact.

With this series applied, what is left is:

[OK]

 -  hw/core/generic-loader.c:127:        s->cpu = qemu_get_cpu(s->cpu_num, NULL);
 -  linux-user/syscall.c:8990:        if (CPU_NEXT(first_cpu)) {
 -  monitor/hmp-cmds-target.c:106:        cs = vcpu >= 0 ? qemu_get_cpu(vcpu, NULL) : mon_get_cpu(mon);
 -  stats/stats-hmp-cmds.c:150:        CPUState *cpu = qemu_get_cpu(cpu_index, NULL);
 -  system/cpus.c:754:    cpu = qemu_get_cpu(cpu_index, NULL);

[likely OK, we don't support heterogeneous accelerators]

 -  accel/kvm/kvm-all.c:3581:    kvm_arch_on_sigbus_vcpu(first_cpu, code, addr);
 -  accel/kvm/kvm-all.c:4255:    if (first_cpu) {
 -  accel/kvm/kvm-all.c:4258:        query_stats_schema_vcpu(first_cpu, &stats_args);

[need some toughts...]

 -  accel/tcg/tcg-accel-ops-rr.c:114:        qemu_cond_wait_iothread(first_cpu->halt_cond);
 -  accel/tcg/tcg-accel-ops-rr.c:200:    while (first_cpu->stopped) {
 -  accel/tcg/tcg-accel-ops-rr.c:201:        qemu_cond_wait_iothread(first_cpu->halt_cond);
 -  accel/tcg/tcg-accel-ops-rr.c:212:    cpu = first_cpu;
 -  accel/tcg/tcg-accel-ops-rr.c:242:            cpu = first_cpu;
 -  accel/tcg/tcg-accel-ops-rr.c:336:        cpu->thread_id = first_cpu->thread_id;
 -  accel/tcg/tcg-accel-ops-rr.c:92:    if (!rr_kick_vcpu_timer && CPU_NEXT(first_cpu)) {
 -  dump/win_dump.c:115:    if (cpu_memory_rw_debug(first_cpu,
 -  dump/win_dump.c:128:    if (cpu_read_ptr(x64, first_cpu,
 -  dump/win_dump.c:135:    if (cpu_memory_rw_debug(first_cpu, KiBugcheckData,
 -  dump/win_dump.c:210:    if (cpu_memory_rw_debug(first_cpu,
 -  dump/win_dump.c:258:    if (cpu_read_ptr(x64, first_cpu,
 -  dump/win_dump.c:265:    if (cpu_memory_rw_debug(first_cpu,
 -  dump/win_dump.c:286:        if (cpu_read_ptr(x64, first_cpu,
 -  dump/win_dump.c:294:        if (cpu_read_ptr(x64, first_cpu,
 -  dump/win_dump.c:378:        if (cpu_memory_rw_debug(first_cpu, Context,
 -  dump/win_dump.c:384:        if (cpu_memory_rw_debug(first_cpu, Context,
 -  dump/win_dump.c:400:        if (cpu_memory_rw_debug(first_cpu, saved_ctx[i].addr,
 -  dump/win_dump.c:410:    X86CPU *first_x86_cpu = X86_CPU(first_cpu);
 -  gdbstub/gdbstub.c:1521:    cc = CPU_GET_CLASS(first_cpu);
 -  gdbstub/gdbstub.c:298:    CPUState *cpu = first_cpu;
 -  gdbstub/system.c:338:    if (!first_cpu) {
 -  hw/acpi/cpu.c:138:            if (!cdev->cpu || cdev->cpu == first_cpu) {
 -  hw/acpi/cpu.c:150:            if (!cdev->cpu || cdev->cpu == first_cpu) {
 -  hw/acpi/cpu.c:671:            if (CPU(arch_ids->cpus[i].cpu) != first_cpu) {
 -  hw/core/generic-loader.c:134:        s->cpu = first_cpu;
 -  monitor/hmp-cmds-target.c:39:    cpu = qemu_get_cpu(cpu_index, NULL);
 -  monitor/hmp-cmds-target.c:62:        if (!first_cpu) {
 -  monitor/hmp-cmds-target.c:65:        monitor_set_cpu(mon, first_cpu->cpu_index);
 -  monitor/hmp-cmds-target.c:66:        cpu = first_cpu;
 -  replay/replay-events.c:130:    qemu_cpu_kick(first_cpu);
 -  system/cpu-timers.c:254:    } else if (first_cpu) {
 -  system/cpu-timers.c:263:        async_run_on_cpu(first_cpu, do_nothing, RUN_ON_CPU_NULL);
 -  system/memory_mapping.c:315:    first_paging_enabled_cpu = find_paging_enabled_cpu(first_cpu);
 -  system/qtest.c:548:            address_space_write(first_cpu->as, ...
 -  system/qtest.c:553:            address_space_write(first_cpu->as, ...
 -  system/qtest.c:558:            address_space_write(first_cpu->as, ...
 -  system/qtest.c:563:            address_space_write(first_cpu->as, ...
 -  system/qtest.c:582:            address_space_read(first_cpu->as, ...
 -  system/qtest.c:587:            address_space_read(first_cpu->as, ...
 -  system/qtest.c:592:            address_space_read(first_cpu->as, ...
 -  system/qtest.c:596:            address_space_read(first_cpu->as, ...
 -  system/qtest.c:617:        address_space_read(first_cpu->as, ...
 -  system/qtest.c:643:        address_space_read(first_cpu->as, ...
 -  system/qtest.c:678:        address_space_write(first_cpu->as, ...
 -  system/qtest.c:701:            address_space_write(first_cpu->as, ...
 -  system/qtest.c:735:        address_space_write(first_cpu->as, ...
 -  tests/qtest/fuzz/generic_fuzz.c:241:        mr1 = address_space_translate(first_cpu->as,
 -  tests/qtest/fuzz/qtest_wrappers.c:110:        address_space_read(first_cpu->as, ...
 -  tests/qtest/fuzz/qtest_wrappers.c:122:        address_space_read(first_cpu->as, ...
 -  tests/qtest/fuzz/qtest_wrappers.c:134:        address_space_read(first_cpu->as, ...
 -  tests/qtest/fuzz/qtest_wrappers.c:146:        address_space_read(first_cpu->as, ...
 -  tests/qtest/fuzz/qtest_wrappers.c:157:        address_space_write(first_cpu->as, ...
 -  tests/qtest/fuzz/qtest_wrappers.c:167:        address_space_write(first_cpu->as, ...
 -  tests/qtest/fuzz/qtest_wrappers.c:177:        address_space_write(first_cpu->as, ...
 -  tests/qtest/fuzz/qtest_wrappers.c:187:        address_space_write(first_cpu->as, ...
 -  tests/qtest/fuzz/qtest_wrappers.c:197:        address_space_read(first_cpu->as, ...
 -  tests/qtest/fuzz/qtest_wrappers.c:207:        address_space_read(first_cpu->as, ...
 -  tests/qtest/fuzz/qtest_wrappers.c:218:        address_space_write(first_cpu->as, ...
 -  tests/qtest/fuzz/qtest_wrappers.c:229:        address_space_write(first_cpu->as, ...
 -  tests/qtest/fuzz/qtest_wrappers.c:242:        address_space_write(first_cpu->as, ...

Regards,

Phil.

Based-on: <[email protected]>
"target: Make 'cpu-qom.h' really target agnostic" v2

Philippe Mathieu-Daudé (19):
cpus: Add argument to qemu_get_cpu() to filter CPUs by QOM type
cpus: Filter for target specific CPU (generic)
cpus: Filter for target specific CPU (arm)
cpus: Filter for target specific CPU (loongarch)
cpus: Filter for target specific CPU (mips)
cpus: Filter for target specific CPU (s390x)
cpus: Filter for target specific CPU (riscv)
cpus: Filter for target specific CPU (ppc)
cpus: Filter for target specific CPU (x86)
cpus: Replace first_cpu by qemu_get_cpu(0, TYPE_ARM_CPU)
cpus: Replace first_cpu by qemu_get_cpu(0, TYPE_POWERPC_CPU)
cpus: Replace first_cpu by qemu_get_cpu(0, TYPE_MIPS_CPU)
cpus: Replace first_cpu by qemu_get_cpu(0, TYPE_M68K_CPU)
cpus: Replace first_cpu by qemu_get_cpu(0, TYPE_S390X_CPU)
cpus: Replace first_cpu by qemu_get_cpu(0, TYPE_RISCV_CPU)
cpus: Replace first_cpu by qemu_get_cpu(0, TYPE_TRICORE_CPU)
cpus: Replace first_cpu by qemu_get_cpu(0, TYPE_SUPERH_CPU)
cpus: Replace first_cpu by qemu_get_cpu(0, TYPE_RX_CPU)
cpus: Replace first_cpu by qemu_get_cpu(0, TYPE_X86_CPU)

 include/hw/core/cpu.h               |  3 ++-
 target/mips/internal.h              |  2 +-
 cpu-common.c                        |  5 ++++-
 hw/arm/aspeed.c                     |  5 +++--
 hw/arm/bananapi_m2u.c               |  3 ++-
 hw/arm/boot.c                       | 14 +++++++-------
 hw/arm/exynos4_boards.c             |  6 ++++--
 hw/arm/fsl-imx7.c                   |  2 +-
 hw/arm/highbank.c                   |  3 ++-
 hw/arm/microbit.c                   |  3 ++-
 hw/arm/mps2-tz.c                    |  3 ++-
 hw/arm/mps2.c                       |  3 ++-
 hw/arm/msf2-som.c                   |  3 ++-
 hw/arm/musca.c                      |  3 ++-
 hw/arm/netduino2.c                  |  3 ++-
 hw/arm/netduinoplus2.c              |  2 +-
 hw/arm/olimex-stm32-h405.c          |  2 +-
 hw/arm/orangepi.c                   |  3 ++-
 hw/arm/pxa2xx_gpio.c                |  2 +-
 hw/arm/realview.c                   |  5 +++--
 hw/arm/sbsa-ref.c                   |  7 ++++---
 hw/arm/stellaris.c                  |  3 ++-
 hw/arm/stm32vldiscovery.c           |  2 +-
 hw/arm/vexpress.c                   |  5 +++--
 hw/arm/virt-acpi-build.c            |  2 +-
 hw/arm/virt.c                       | 25 ++++++++++++++-----------
 hw/arm/xilinx_zynq.c                |  3 ++-
 hw/arm/xlnx-versal-virt.c           |  2 +-
 hw/core/generic-loader.c            |  2 +-
 hw/cpu/a15mpcore.c                  |  4 ++--
 hw/cpu/a9mpcore.c                   |  2 +-
 hw/hyperv/hyperv.c                  |  2 +-
 hw/i386/kvm/clock.c                 |  4 ++--
 hw/i386/kvm/xen_evtchn.c            |  8 ++++----
 hw/i386/kvmvapic.c                  |  3 ++-
 hw/i386/microvm.c                   |  2 +-
 hw/i386/pc.c                        |  7 ++++---
 hw/i386/pc_piix.c                   |  3 ++-
 hw/i386/x86.c                       |  2 +-
 hw/intc/arm_gicv3_common.c          |  3 ++-
 hw/intc/arm_gicv3_cpuif.c           |  2 +-
 hw/intc/arm_gicv3_kvm.c             |  2 +-
 hw/intc/m68k_irqc.c                 |  2 +-
 hw/intc/mips_gic.c                  |  2 +-
 hw/intc/riscv_aclint.c              |  2 +-
 hw/intc/sh_intc.c                   |  6 ++++--
 hw/intc/sifive_plic.c               |  4 ++--
 hw/isa/lpc_ich9.c                   |  2 +-
 hw/loongarch/virt.c                 | 10 +++++-----
 hw/m68k/mcf5206.c                   |  2 +-
 hw/mips/bootloader.c                |  3 ++-
 hw/mips/cps.c                       |  5 +++--
 hw/mips/loongson3_bootp.c           |  2 +-
 hw/mips/loongson3_virt.c            |  7 ++++---
 hw/mips/malta.c                     |  2 +-
 hw/misc/mips_cpc.c                  |  4 ++--
 hw/ppc/e500.c                       |  4 ++--
 hw/ppc/ppc.c                        |  4 ++--
 hw/ppc/ppce500_spin.c               |  2 +-
 hw/ppc/prep_systemio.c              |  2 +-
 hw/ppc/spapr.c                      | 11 ++++++-----
 hw/ppc/spapr_caps.c                 | 10 +++++-----
 hw/ppc/spapr_rtas.c                 |  2 +-
 hw/ppc/spapr_vof.c                  |  2 +-
 hw/ppc/vof.c                        |  3 ++-
 hw/riscv/boot.c                     |  4 ++--
 hw/riscv/opentitan.c                |  4 ++--
 hw/rx/rx-gdbsim.c                   |  4 ++--
 hw/s390x/ipl.c                      |  4 ++--
 hw/s390x/s390-virtio-ccw.c          |  2 +-
 hw/tricore/triboard.c               |  2 +-
 monitor/hmp-cmds-target.c           |  4 ++--
 stats/stats-hmp-cmds.c              |  2 +-
 system/cpus.c                       |  2 +-
 target/arm/arch_dump.c              |  6 +++---
 target/i386/arch_dump.c             |  6 +++---
 target/i386/kvm/kvm.c               |  6 +++---
 target/i386/kvm/xen-emu.c           | 15 ++++++++-------
 target/i386/monitor.c               |  2 +-
 target/i386/tcg/sysemu/fpu_helper.c |  4 ++--
 target/mips/cpu.c                   |  2 +-
 target/mips/tcg/sysemu/cp0_helper.c | 10 +++++-----
 target/mips/tcg/sysemu/tlb_helper.c |  2 +-
 target/ppc/arch_dump.c              |  4 ++--
 target/riscv/arch_dump.c            |  4 ++--
 target/s390x/cpu_models.c           | 10 +++++-----
 86 files changed, 199 insertions(+), 163 deletions(-)
Signature · 1 line
2.41.0