i386 cleanup
Subsystems (2)
v9 cover i386 cleanup
v8 -> v9: move additional methods to CPUClass->tcg_ops
do_unaligned_access, transaction_failed and do_interrupt.
do_interrupt is a bit tricky, as the same code is reused (albeit not usually directly) for KVM under certain odd conditions.
Change arm, as the only user of do_interrupt callback for KVM, to instead call the target function directly arm_do_interrupt.
v7 -> v8: add missing CONFIG_TCGs, fix bugs
* add the prerequisite patches for "3 tcg" at the beginning of the series for convenience (already reviewed, queued by RH).
* add CONFIG_TCG to TCGCpuOperations and tcg_ops variable use
* reduce the scope of the realizefn refactoring, do not introduce a separate cpu_accel_realize, and instead use the existing cpu_exec_realizefn, there is not enough benefit to introduce a new function.
* fix bugs in user mode due to attempt to move the tcg_region_init() early, so it could be done just once in tcg_init() for both softmmu and user mode. Unfortunately it needs to remain deferred for user mode, as it needs to be done after prologue init and after the GUEST_BASE has been set.
v6 -> v7: integrate TCGCpuOperations, refactored cpu_exec_realizefn
* integrate TCGCpuOperations (Eduardo)
Taken some refactoring from Eduardo for Tcg-only operations on CPUClass.
* refactored cpu_exec_realizefn
The other main change is a refactoring of cpu_exec_realizefn, directly linked to the effort of making many cpu_exec operations TCG-only (Eduardo series above):
cpu_exec_realizefn is actually a TCG-only thing, with the exception of a couple things that can be done in base cpu code.
This changes all targets realizefn, so I guess I have to Cc:
the Multiverse? (Universe was already CCed for all accelerators).
v5 -> v6: remove MODULE_INIT_ACCEL_CPU
instead, use a call to accel_init_interfaces().
* The class lookups are now general and performed in accel/
new AccelCPUClass for new archs are supported as new ones appear in the class hierarchy, no need for stubs.
* Split the code a bit better
v4 -> v5: centralized and simplified initializations
I put in Cc: Emilio G. Cota, specifically because in patch 8 I (re)moved for user-mode the call to tcg_regions_init().
The call happens now inside the tcg AccelClass machine_init, (so earlier). This seems to work fine, but thought to get the author opinion on this.
Rebased on "tcg-cpus: split into 3 tcg variants" series (queued by Richard), to avoid some code churn:
https://lists.gnu.org/archive/html/qemu-devel/2020-10/msg04356.html
* Extended AccelClass to user-mode.
user-mode now does not call tcg_exec_init directly, instead it uses the tcg accel class, and its init_machine method.
Since user-mode does not define or use a machine state, the machine is just passed as NULL.
The immediate advantage is that now we can call current_accel() from both user mode and softmmu, so we can work out the correct class to use for accelerator initializations.
* QOMification of CpusAccelOps
simple QOMification of CpusAccelOps abstract class.
* Centralized all accel_cpu_init, so only one per cpu-arch, plus one for all accels will remain.
So we can expect accel_cpu_init() to be limited to:
softmmu/cpus.c - initializes the chosen softmmu accel ops for the cpus module. target/ARCH/cpu.c - initializes the chosen arch-specific cpu accelerator.
These changes are meant to address concerns/issues (Paolo):
1) the use of if (tcg_enabled()) and similar in the module_init call path
2) the excessive number of accel_cpu_init() to hunt down in the codebase.
* Fixed wrong use of host_cpu_class_init (Eduardo)
v3 -> v4: QOMification of X86CPUAccelClass
In this version I basically QOMified X86CPUAccel, taking the suggestions from Eduardo as the starting point,
but stopping just short of making it an actual QOM interface, using a plain abstract class, and then subclasses for the actual objects.
Initialization is still using the existing qemu initialization framework (module_call_init), which is I still think is better than the alternatives proposed, in the current state.
Possibly some improvements could be developed in the future here. In this case, effort should be put in keeping things extendible, in order not to be blocked once accelerators also become modules.
Motivation and higher level steps:
https://lists.gnu.org/archive/html/qemu-devel/2020-05/msg04628.html
Looking forward to your comments on this proposal,
Ciao,
Claudio
Claudio Fontana (23):
accel/tcg: split CpusAccel into three TCG variants accel/tcg: split tcg_start_vcpu_thread
accel/tcg: rename tcg-cpus functions to match module name
i386: move kvm accel files into kvm/
i386: move whpx accel files into whpx/
i386: move hax accel files into hax/
i386: hvf: remove stale MAINTAINERS entry for old hvf stubs
i386: move TCG accel files into tcg/
i386: move cpu dump out of helper.c into cpu-dump.c
i386: move TCG cpu class initialization out of helper.c target/riscv: remove CONFIG_TCG, as it is always TCG accel/tcg: split TCG-only code from cpu_exec_realizefn target/arm: do not use cc->do_interrupt for KVM directly
cpu: move cc->do_interrupt to tcg_ops
cpu: move cc->transaction_failed to tcg_ops
cpu: move do_unaligned_access to tcg_ops
accel: extend AccelState and AccelClass to user-mode
accel: replace struct CpusAccel with AccelOpsClass
accel: introduce AccelCPUClass extending CPUClass
i386: split cpu accelerators from cpu.c, using AccelCPUClass
cpu: call AccelCPUClass::cpu_realizefn in cpu_exec_realizefn hw/core/cpu: call qemu_init_vcpu in cpu_common_realizefn
cpu: introduce cpu_accel_instance_init
Eduardo Habkost (9):
tcg: cpu_exec_{enter,exit} helpers
tcg: make CPUClass.cpu_exec_* optional
tcg: Make CPUClass.debug_excp_handler optional
cpu: Remove unnecessary noop methods
cpu: Introduce TCGCpuOperations struct
cpu: Move synchronize_from_tb() to tcg_ops
cpu: Move cpu_exec_* to tcg_ops
cpu: Move tlb_fill to tcg_ops
cpu: Move debug_excp_handler to tcg_ops
MAINTAINERS | 19 +-
accel/accel-common.c | 105 +++++
accel/{accel.c => accel-softmmu.c} | 60 +--
accel/accel-softmmu.h | 15 +
accel/accel-user.c | 24 ++
accel/kvm/kvm-all.c | 2 -
accel/kvm/kvm-cpus.c | 26 +-
accel/kvm/kvm-cpus.h | 2 -
accel/meson.build | 4 +-
accel/qtest/qtest.c | 25 +-
accel/tcg/cpu-exec.c | 70 +++-
accel/tcg/cputlb.c | 6 +-
accel/tcg/meson.build | 9 +-
accel/tcg/tcg-all.c | 14 +-
accel/tcg/tcg-cpus-icount.c | 138 +++++++
accel/tcg/tcg-cpus-icount.h | 19 +
accel/tcg/tcg-cpus-mttcg.c | 134 +++++++
accel/tcg/tcg-cpus-mttcg.h | 19 +
accel/tcg/tcg-cpus-rr.c | 298 ++++++++++++++
accel/tcg/tcg-cpus-rr.h | 21 +
accel/tcg/tcg-cpus.c | 539 +++-----------------------
accel/tcg/tcg-cpus.h | 8 +-
accel/tcg/user-exec.c | 6 +-
accel/xen/xen-all.c | 24 +-
bsd-user/main.c | 11 +-
cpu.c | 71 ++--
hw/core/cpu.c | 30 +-
hw/i386/fw_cfg.c | 2 +-
hw/i386/intel_iommu.c | 2 +-
hw/i386/kvm/apic.c | 2 +-
hw/i386/kvm/clock.c | 2 +-
hw/i386/microvm.c | 2 +-
hw/i386/pc.c | 2 +-
hw/i386/pc_piix.c | 1 +
hw/i386/x86.c | 2 +-
hw/mips/jazz.c | 4 +-
include/hw/boards.h | 2 +-
include/hw/core/accel-cpu.h | 25 ++
include/hw/core/cpu.h | 92 ++---
include/hw/core/tcg-cpu-ops.h | 75 ++++
include/{sysemu => qemu}/accel.h | 16 +-
include/sysemu/accel-ops.h | 45 +++
include/sysemu/cpus.h | 26 +-
include/sysemu/hvf.h | 2 +-
include/sysemu/kvm.h | 2 +-
include/sysemu/kvm_int.h | 2 +-
linux-user/main.c | 7 +-
meson.build | 1 +
softmmu/cpus.c | 12 +-
softmmu/icount.c | 2 +-
softmmu/memory.c | 2 +-
softmmu/qtest.c | 2 +-
softmmu/vl.c | 8 +-
target/alpha/cpu.c | 18 +-
target/arm/cpu.c | 26 +-
target/arm/cpu64.c | 5 +-
target/arm/cpu_tcg.c | 8 +-
target/arm/helper.c | 4 +
target/arm/kvm64.c | 4 +-
target/avr/cpu.c | 13 +-
target/avr/helper.c | 4 +-
target/cris/cpu.c | 30 +-
target/cris/helper.c | 4 +-
target/hppa/cpu.c | 15 +-
target/i386/cpu-dump.c | 537 +++++++++++++++++++++++++
target/i386/cpu.c | 418 ++------------------
target/i386/cpu.h | 120 +-----
target/i386/{ => hax}/hax-all.c | 5 +-
target/i386/{ => hax}/hax-cpus.c | 29 +-
target/i386/{ => hax}/hax-cpus.h | 2 -
target/i386/{ => hax}/hax-i386.h | 6 +-
target/i386/{ => hax}/hax-interface.h | 0
target/i386/{ => hax}/hax-mem.c | 0
target/i386/{ => hax}/hax-posix.c | 0
target/i386/{ => hax}/hax-posix.h | 0
target/i386/{ => hax}/hax-windows.c | 0
target/i386/{ => hax}/hax-windows.h | 0
target/i386/hax/meson.build | 7 +
target/i386/helper-tcg.h | 112 ++++++
target/i386/helper.c | 539 +-------------------------
target/i386/host-cpu.c | 198 ++++++++++
target/i386/host-cpu.h | 19 +
target/i386/hvf/cpu.c | 65 ++++
target/i386/hvf/hvf-cpus.c | 27 +-
target/i386/hvf/hvf-cpus.h | 2 -
target/i386/hvf/hvf-i386.h | 2 +-
target/i386/hvf/hvf.c | 3 +-
target/i386/hvf/meson.build | 1 +
target/i386/hvf/x86_task.c | 2 +-
target/i386/kvm/cpu.c | 148 +++++++
target/i386/{ => kvm}/hyperv-proto.h | 0
target/i386/{ => kvm}/hyperv-stub.c | 0
target/i386/{ => kvm}/hyperv.c | 0
target/i386/{ => kvm}/hyperv.h | 0
target/i386/kvm/kvm-cpu.h | 41 ++
target/i386/{ => kvm}/kvm-stub.c | 0
target/i386/{ => kvm}/kvm.c | 3 +-
target/i386/{ => kvm}/kvm_i386.h | 0
target/i386/kvm/meson.build | 8 +
target/i386/kvm/trace-events | 7 +
target/i386/kvm/trace.h | 1 +
target/i386/machine.c | 4 +-
target/i386/meson.build | 39 +-
target/i386/{ => tcg}/bpt_helper.c | 1 +
target/i386/{ => tcg}/cc_helper.c | 1 +
target/i386/tcg/cpu.c | 173 +++++++++
target/i386/{ => tcg}/excp_helper.c | 1 +
target/i386/{ => tcg}/fpu_helper.c | 33 +-
target/i386/{ => tcg}/int_helper.c | 1 +
target/i386/{ => tcg}/mem_helper.c | 1 +
target/i386/tcg/meson.build | 14 +
target/i386/{ => tcg}/misc_helper.c | 1 +
target/i386/{ => tcg}/mpx_helper.c | 1 +
target/i386/{ => tcg}/seg_helper.c | 1 +
target/i386/{ => tcg}/smm_helper.c | 2 +
target/i386/{ => tcg}/svm_helper.c | 1 +
target/i386/{ => tcg}/tcg-stub.c | 0
target/i386/{ => tcg}/translate.c | 1 +
target/i386/trace-events | 6 -
target/i386/whpx/meson.build | 4 +
target/i386/{ => whpx}/whp-dispatch.h | 0
target/i386/{ => whpx}/whpx-all.c | 4 +-
target/i386/{ => whpx}/whpx-cpus.c | 29 +-
target/i386/{ => whpx}/whpx-cpus.h | 2 -
target/lm32/cpu.c | 13 +-
target/m68k/cpu.c | 12 +-
target/microblaze/cpu.c | 23 +-
target/mips/cpu.c | 21 +-
target/moxie/cpu.c | 10 +-
target/nios2/cpu.c | 14 +-
target/openrisc/cpu.c | 12 +-
target/ppc/translate_init.c.inc | 23 +-
target/riscv/cpu.c | 25 +-
target/rx/cpu.c | 18 +-
target/s390x/cpu.c | 15 +-
target/sh4/cpu.c | 14 +-
target/sparc/cpu.c | 18 +-
target/tilegx/cpu.c | 10 +-
target/tricore/cpu.c | 8 +-
target/unicore32/cpu.c | 14 +-
target/xtensa/cpu.c | 16 +-
141 files changed, 3007 insertions(+), 2051 deletions(-)
create mode 100644 accel/accel-common.c
rename accel/{accel.c => accel-softmmu.c} (64%)
create mode 100644 accel/accel-softmmu.h
create mode 100644 accel/accel-user.c
create mode 100644 accel/tcg/tcg-cpus-icount.c
create mode 100644 accel/tcg/tcg-cpus-icount.h
create mode 100644 accel/tcg/tcg-cpus-mttcg.c
create mode 100644 accel/tcg/tcg-cpus-mttcg.h
create mode 100644 accel/tcg/tcg-cpus-rr.c
create mode 100644 accel/tcg/tcg-cpus-rr.h
create mode 100644 include/hw/core/accel-cpu.h
create mode 100644 include/hw/core/tcg-cpu-ops.h
rename include/{sysemu => qemu}/accel.h (94%)
create mode 100644 include/sysemu/accel-ops.h
create mode 100644 target/i386/cpu-dump.c
rename target/i386/{ => hax}/hax-all.c (99%)
rename target/i386/{ => hax}/hax-cpus.c (71%)
rename target/i386/{ => hax}/hax-cpus.h (95%)
rename target/i386/{ => hax}/hax-i386.h (95%)
rename target/i386/{ => hax}/hax-interface.h (100%)
rename target/i386/{ => hax}/hax-mem.c (100%)
rename target/i386/{ => hax}/hax-posix.c (100%)
rename target/i386/{ => hax}/hax-posix.h (100%)
rename target/i386/{ => hax}/hax-windows.c (100%)
rename target/i386/{ => hax}/hax-windows.h (100%)
create mode 100644 target/i386/hax/meson.build
create mode 100644 target/i386/helper-tcg.h
create mode 100644 target/i386/host-cpu.c
create mode 100644 target/i386/host-cpu.h
create mode 100644 target/i386/hvf/cpu.c
create mode 100644 target/i386/kvm/cpu.c
rename target/i386/{ => kvm}/hyperv-proto.h (100%)
rename target/i386/{ => kvm}/hyperv-stub.c (100%)
rename target/i386/{ => kvm}/hyperv.c (100%)
rename target/i386/{ => kvm}/hyperv.h (100%)
create mode 100644 target/i386/kvm/kvm-cpu.h
rename target/i386/{ => kvm}/kvm-stub.c (100%)
rename target/i386/{ => kvm}/kvm.c (99%)
rename target/i386/{ => kvm}/kvm_i386.h (100%)
create mode 100644 target/i386/kvm/meson.build
create mode 100644 target/i386/kvm/trace-events
create mode 100644 target/i386/kvm/trace.h
rename target/i386/{ => tcg}/bpt_helper.c (99%)
rename target/i386/{ => tcg}/cc_helper.c (99%)
create mode 100644 target/i386/tcg/cpu.c
rename target/i386/{ => tcg}/excp_helper.c (99%)
rename target/i386/{ => tcg}/fpu_helper.c (99%)
rename target/i386/{ => tcg}/int_helper.c (99%)
rename target/i386/{ => tcg}/mem_helper.c (99%)
create mode 100644 target/i386/tcg/meson.build
rename target/i386/{ => tcg}/misc_helper.c (99%)
rename target/i386/{ => tcg}/mpx_helper.c (99%)
rename target/i386/{ => tcg}/seg_helper.c (99%)
rename target/i386/{ => tcg}/smm_helper.c (99%)
rename target/i386/{ => tcg}/svm_helper.c (99%)
rename target/i386/{ => tcg}/tcg-stub.c (100%)
rename target/i386/{ => tcg}/translate.c (99%)
create mode 100644 target/i386/whpx/meson.build
rename target/i386/{ => whpx}/whp-dispatch.h (100%)
rename target/i386/{ => whpx}/whpx-all.c (99%)
rename target/i386/{ => whpx}/whpx-cpus.c (73%)
rename target/i386/{ => whpx}/whpx-cpus.h (96%)Signature · 1 line
2.26.2
RFC v9 1/32 accel/tcg: split CpusAccel into three TCG variants
split up the CpusAccel tcg_cpus into three TCG variants:
tcg_cpus_rr (single threaded, round robin cpus) tcg_cpus_icount (same as rr, but with instruction counting enabled) tcg_cpus_mttcg (multi-threaded cpus)
--- accel/tcg/meson.build | 9 +- accel/tcg/tcg-all.c | 8 +- accel/tcg/tcg-cpus-icount.c | 147 +++++++++++ accel/tcg/tcg-cpus-icount.h | 17 ++ accel/tcg/tcg-cpus-mttcg.c | 117 +++++++++ accel/tcg/tcg-cpus-mttcg.h | 21 ++ accel/tcg/tcg-cpus-rr.c | 270 ++++++++++++++++++++ accel/tcg/tcg-cpus-rr.h | 20 ++ accel/tcg/tcg-cpus.c | 484 ++---------------------------------- accel/tcg/tcg-cpus.h | 13 +- softmmu/icount.c | 2 +- 11 files changed, 646 insertions(+), 462 deletions(-) create mode 100644 accel/tcg/tcg-cpus-icount.c create mode 100644 accel/tcg/tcg-cpus-icount.h create mode 100644 accel/tcg/tcg-cpus-mttcg.c create mode 100644 accel/tcg/tcg-cpus-mttcg.h create mode 100644 accel/tcg/tcg-cpus-rr.c create mode 100644 accel/tcg/tcg-cpus-rr.h
accel/tcg/meson.build +8 -1
@@ -12,4 +12,11 @@ tcg_ss.add(when: 'CONFIG_SOFTMMU', if_false: files('user-exec-stub.c')) tcg_ss.add(when: 'CONFIG_PLUGIN', if_true: [files('plugin-gen.c'), libdl]) specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_ss) -specific_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: files('tcg-all.c', 'cputlb.c', 'tcg-cpus.c')) +specific_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: files( + 'tcg-all.c', + 'cputlb.c', + 'tcg-cpus.c', + 'tcg-cpus-mttcg.c', + 'tcg-cpus-icount.c', + 'tcg-cpus-rr.c' +))
accel/tcg/tcg-all.c +7 -1
@@ -104,8 +104,14 @@ static int tcg_init(MachineState *ms)tcg_exec_init (s->tb_size *1024 *1024 ); mttcg_enabled = s->mttcg_enabled; -cpus_register_accel (&tcg_cpus); +if (mttcg_enabled) { +cpus_register_accel (&tcg_cpus_mttcg); + }else if (icount_enabled ()) { +cpus_register_accel (&tcg_cpus_icount); + }else { +cpus_register_accel (&tcg_cpus_rr); + }return 0 ; }
accel/tcg/tcg-cpus-icount.c new file +147 -0
147 lines not on this page · raw message
accel/tcg/tcg-cpus-icount.h new file +17 -0
@@ -0,0 +1,17 @@ +/* +* QEMU TCG Single Threaded vCPUs implementation using instruction counting +* +* Copyright 2020 SUSE LLC +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef TCG_CPUS_ICOUNT_H +#define TCG_CPUS_ICOUNT_H + +void handle_icount_deadline (void ); +void prepare_icount_for_run (CPUState *cpu); +void process_icount_data (CPUState *cpu); + +#endif /* TCG_CPUS_ICOUNT_H */
accel/tcg/tcg-cpus-mttcg.c new file +117 -0
117 lines not on this page · raw message
accel/tcg/tcg-cpus-mttcg.h new file +21 -0
@@ -0,0 +1,21 @@ +/* +* QEMU TCG Multi Threaded vCPUs implementation +* +* Copyright 2020 SUSE LLC +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef TCG_CPUS_MTTCG_H +#define TCG_CPUS_MTTCG_H + +/* +* In the multi-threaded case each vCPU has its own thread. The TLS +* variable current_cpu can be used deep in the code to find the +* current CPUState for a given thread. +*/ + +void *tcg_cpu_thread_fn (void *arg); + +#endif /* TCG_CPUS_MTTCG_H */
accel/tcg/tcg-cpus-rr.c new file +270 -0
270 lines not on this page · raw message
accel/tcg/tcg-cpus-rr.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* QEMU TCG Single Threaded vCPUs implementation +* +* Copyright 2020 SUSE LLC +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef TCG_CPUS_RR_H +#define TCG_CPUS_RR_H + +#define TCG_KICK_PERIOD (NANOSECONDS_PER_SECOND / 10) + +/* Kick all RR vCPUs. */ +void qemu_cpu_kick_rr_cpus (CPUState *unused); + +void *tcg_rr_cpu_thread_fn (void *arg); + +#endif /* TCG_CPUS_RR_H */
accel/tcg/tcg-cpus.c +27 -457
517 lines not on this page · raw message
accel/tcg/tcg-cpus.h +11 -2
@@ -1,5 +1,7 @@/* -* Accelerator CPUS Interface +* QEMU TCG vCPU common functionality +* +* Functionality common to all TCG vcpu variants: mttcg, rr and icount. * * Copyright 2020 SUSE LLC *
@@ -12,6 +14,13 @@#include "sysemu/cpus.h" -extern const CpusAccel tcg_cpus; +extern const CpusAccel tcg_cpus_mttcg; +extern const CpusAccel tcg_cpus_icount; +extern const CpusAccel tcg_cpus_rr; + +void tcg_start_vcpu_thread (CPUState *cpu); +void qemu_tcg_destroy_vcpu (CPUState *cpu); +int tcg_cpu_exec (CPUState *cpu); +void tcg_handle_interrupt (CPUState *cpu,int mask);#endif /* TCG_CPUS_H */
softmmu/icount.c +1 -1
@@ -396,7 +396,7 @@ void icount_start_warp_timer(void)void icount_account_warp_timer (void ) { -if (!icount_enabled () || !icount_sleep) { +if (!icount_sleep) {return ; }
Signature · 1 line
2.26.2
Re: [RFC v9 01/32] accel/tcg: split CpusAccel into three TCG variants
Quoted 6 lines · Claudio Fontana
split up the CpusAccel
tcg_cpusinto three TCG variants:
tcg_cpus_rr(single threaded, round robin cpus)tcg_cpus_icount(same as rr, but with instruction counting enabled)tcg_cpus_mttcg(multi-threaded cpus)
<snip>
Quoted 6 lines
accel/tcg/tcg-cpus-mttcg.c new file +0
-0@@ -0,0 +1,117 @@
<snip>
Quoted 7 lines
accel/tcg/tcg-cpus-mttcg.c new file +7
-0+ +/* +* In the multi-threaded case each vCPU has its own thread. The TLS +* variable current_cpu can be used deep in the code to find the +* current CPUState for a given thread. +*/ +
<snip>
accel/tcg/tcg-cpus-mttcg.c line 42
Quoted 6 lines
accel/tcg/tcg-cpus-mttcg.c new file +6
-0+ +/* +* In the multi-threaded case each vCPU has its own thread. The TLS +* variable current_cpu can be used deep in the code to find the +* current CPUState for a given thread. +*/
nit: This is overly repetitive - I think we can drop the duplication in the header. If anything the comment should probably be re-formulated at the current_cpu definition in cpus-common.
<snip>
Otherwise nice clean-up ;-)
Signature · 1 line
Alex Bennée
RFC v9 2/32 accel/tcg: split tcg_start_vcpu_thread
In reply to Claudio Fontanaafter the initial split into 3 tcg variants, we proceed to also split tcg_start_vcpu_thread.
We actually split it in 2 this time, since the icount variant just uses the round robin function.
--- accel/tcg/tcg-all.c | 5 ++++ accel/tcg/tcg-cpus-icount.c | 2 +- accel/tcg/tcg-cpus-mttcg.c | 29 +++++++++++++++++-- accel/tcg/tcg-cpus-mttcg.h | 21 -------------- accel/tcg/tcg-cpus-rr.c | 39 +++++++++++++++++++++++-- accel/tcg/tcg-cpus-rr.h | 3 +- accel/tcg/tcg-cpus.c | 58 ------------------------------------- accel/tcg/tcg-cpus.h | 1 - 8 files changed, 71 insertions(+), 87 deletions(-) delete mode 100644 accel/tcg/tcg-cpus-mttcg.h
accel/tcg/tcg-all.c +5 -0
@@ -105,6 +105,11 @@ static int tcg_init(MachineState *ms)tcg_exec_init (s->tb_size *1024 *1024 ); mttcg_enabled = s->mttcg_enabled; +/* +* Initialize TCG regions +*/ +tcg_region_init (); +if (mttcg_enabled) {cpus_register_accel (&tcg_cpus_mttcg); }else if (icount_enabled ()) {
accel/tcg/tcg-cpus-icount.c +1 -1
@@ -138,7 +138,7 @@ static void icount_handle_interrupt(CPUState *cpu, int mask) }const CpusAccel tcg_cpus_icount = { - .create_vcpu_thread = tcg_start_vcpu_thread, + .create_vcpu_thread = rr_start_vcpu_thread, .kick_vcpu_thread = qemu_cpu_kick_rr_cpus, .handle_interrupt = icount_handle_interrupt,
accel/tcg/tcg-cpus-mttcg.c +26 -3
@@ -33,7 +33,6 @@#include "hw/boards.h" #include "tcg-cpus.h" -#include "tcg-cpus-mttcg.h" /* * In the multi-threaded case each vCPU has its own thread. The TLS
@@ -41,7 +40,7 @@* current CPUState for a given thread. */ -void *tcg_cpu_thread_fn (void *arg) +static void *tcg_cpu_thread_fn (void *arg) {CPUState *cpu = arg;
@@ -109,8 +108,32 @@ static void mttcg_kick_vcpu_thread(CPUState *cpu)cpu_exit (cpu); } +static void mttcg_start_vcpu_thread (CPUState *cpu) +{ +char thread_name[VCPU_THREAD_NAME_SIZE ]; + +g_assert (tcg_enabled ()); + + parallel_cpus = (current_machine->smp.max_cpus >1 ); + + cpu->thread =g_malloc0 (sizeof (QemuThread)); + cpu->halt_cond =g_malloc0 (sizeof (QemuCond)); +qemu_cond_init (cpu->halt_cond); + +/* create a thread per vCPU with TCG (MTTCG) */ +snprintf (thread_name,VCPU_THREAD_NAME_SIZE ,"CPU %d/TCG" , + cpu->cpu_index); + +qemu_thread_create (cpu->thread, thread_name, tcg_cpu_thread_fn, + cpu,QEMU_THREAD_JOINABLE ); + +#ifdef _WIN32 + cpu->hThread =qemu_thread_get_handle (cpu->thread); +#endif +} +const CpusAccel tcg_cpus_mttcg = { - .create_vcpu_thread = tcg_start_vcpu_thread, + .create_vcpu_thread = mttcg_start_vcpu_thread, .kick_vcpu_thread = mttcg_kick_vcpu_thread, .handle_interrupt = tcg_handle_interrupt,
accel/tcg/tcg-cpus-mttcg.h deleted +0 -21
@@ -1,21 +0,0 @@ -/* -* QEMU TCG Multi Threaded vCPUs implementation -* -* Copyright 2020 SUSE LLC -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -*/ - -#ifndef TCG_CPUS_MTTCG_H -#define TCG_CPUS_MTTCG_H - -/* -* In the multi-threaded case each vCPU has its own thread. The TLS -* variable current_cpu can be used deep in the code to find the -* current CPUState for a given thread. -*/ - -void *tcg_cpu_thread_fn (void *arg); - -#endif /* TCG_CPUS_MTTCG_H */
accel/tcg/tcg-cpus-rr.c +37 -2
@@ -144,7 +144,7 @@ static void deal_with_unplugged_cpus(void)* elsewhere. */ -void *tcg_rr_cpu_thread_fn (void *arg) +static void *tcg_rr_cpu_thread_fn (void *arg) {CPUState *cpu = arg;
@@ -262,8 +262,43 @@ void *tcg_rr_cpu_thread_fn(void *arg)return NULL ; } +void rr_start_vcpu_thread (CPUState *cpu) +{ +char thread_name[VCPU_THREAD_NAME_SIZE ]; +static QemuCond *single_tcg_halt_cond; +static QemuThread *single_tcg_cpu_thread; + +g_assert (tcg_enabled ()); + parallel_cpus = false; + +if (!single_tcg_cpu_thread) { + cpu->thread =g_malloc0 (sizeof (QemuThread)); + cpu->halt_cond =g_malloc0 (sizeof (QemuCond)); +qemu_cond_init (cpu->halt_cond); + +/* share a single thread for all cpus with TCG */ +snprintf (thread_name,VCPU_THREAD_NAME_SIZE ,"ALL CPUs/TCG" ); +qemu_thread_create (cpu->thread, thread_name, + tcg_rr_cpu_thread_fn, + cpu,QEMU_THREAD_JOINABLE ); + + single_tcg_halt_cond = cpu->halt_cond; + single_tcg_cpu_thread = cpu->thread; +#ifdef _WIN32 + cpu->hThread =qemu_thread_get_handle (cpu->thread); +#endif + }else { +/* we share the thread */ + cpu->thread = single_tcg_cpu_thread; + cpu->halt_cond = single_tcg_halt_cond; + cpu->thread_id = first_cpu->thread_id; + cpu->can_do_io =1 ; + cpu->created = true; + } +} +const CpusAccel tcg_cpus_rr = { - .create_vcpu_thread = tcg_start_vcpu_thread, + .create_vcpu_thread = rr_start_vcpu_thread, .kick_vcpu_thread = qemu_cpu_kick_rr_cpus, .handle_interrupt = tcg_handle_interrupt,
accel/tcg/tcg-cpus-rr.h +2 -1
@@ -15,6 +15,7 @@/* Kick all RR vCPUs. */ void qemu_cpu_kick_rr_cpus (CPUState *unused); -void *tcg_rr_cpu_thread_fn (void *arg); +/* start the round robin vcpu thread */ +void rr_start_vcpu_thread (CPUState *cpu);#endif /* TCG_CPUS_RR_H */
accel/tcg/tcg-cpus.c +0 -58
67 lines not on this page · raw message
accel/tcg/tcg-cpus.h +0 -1
@@ -18,7 +18,6 @@ extern const CpusAccel tcg_cpus_mttcg;extern const CpusAccel tcg_cpus_icount;extern const CpusAccel tcg_cpus_rr; -void tcg_start_vcpu_thread (CPUState *cpu);void qemu_tcg_destroy_vcpu (CPUState *cpu);int tcg_cpu_exec (CPUState *cpu);void tcg_handle_interrupt (CPUState *cpu,int mask);
Signature · 1 line
2.26.2
Re: [RFC v9 02/32] accel/tcg: split tcg_start_vcpu_thread
Quoted 26 lines · Claudio Fontana
after the initial split into 3 tcg variants, we proceed to also split
tcg_start_vcpu_thread.We actually split it in 2 this time, since the icount variant just uses the round robin function.
Suggested-by Richard Henderson <[email protected]>Signed-off-by Claudio Fontana <[email protected]>Reviewed-by Richard Henderson <[email protected]>--- accel/tcg/tcg-all.c | 5 ++++ accel/tcg/tcg-cpus-icount.c | 2 +- accel/tcg/tcg-cpus-mttcg.c | 29 +++++++++++++++++-- accel/tcg/tcg-cpus-mttcg.h | 21 -------------- accel/tcg/tcg-cpus-rr.c | 39 +++++++++++++++++++++++-- accel/tcg/tcg-cpus-rr.h | 3 +- accel/tcg/tcg-cpus.c | 58 ------------------------------------- accel/tcg/tcg-cpus.h | 1 - 8 files changed, 71 insertions(+), 87 deletions(-) delete mode 100644 accel/tcg/tcg-cpus-mttcg.haccel/tcg/tcg-all.c +0
-0
accel/tcg/tcg-all.c static int tcg_init(MachineState *ms) · line 112
Quoted 8 lines
accel/tcg/tcg-all.c +5
-0@@ -105,6 +105,11 @@ static int tcg_init(MachineState *ms)tcg_exec_init (s->tb_size *1024 *1024 ); mttcg_enabled = s->mttcg_enabled; +/* +* Initialize TCG regions +*/ +tcg_region_init (); +
It might be worth noting in the commit log this is OK because the accelerator is now guaranteed to be initialised so you know the details of MTTCG when initialising the regions.
Quoted 5 lines
accel/tcg/tcg-all.c +0
-0if (mttcg_enabled) {cpus_register_accel (&tcg_cpus_mttcg); }else if (icount_enabled ()) {accel/tcg/tcg-cpus-icount.c +0
-0
<snip>
Quoted 13 lines
accel/tcg/tcg-cpus-mttcg.h deleted +0
-7@@ -1,21 +0,0 @@ -/* -* QEMU TCG Multi Threaded vCPUs implementation -* -* Copyright 2020 SUSE LLC -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory.
accel/tcg/tcg-cpus-mttcg.h line 17
Quoted 10 lines
accel/tcg/tcg-cpus-mttcg.h deleted +0
-10-*/ - -#ifndef TCG_CPUS_MTTCG_H -#define TCG_CPUS_MTTCG_H - -/* -* In the multi-threaded case each vCPU has its own thread. The TLS -* variable current_cpu can be used deep in the code to find the -* current CPUState for a given thread. -*/
Ahh gone now ;-)
Quoted 43 lines
accel/tcg/tcg-cpus-mttcg.h deleted +0
-4- -void *tcg_cpu_thread_fn (void *arg); - -#endif /* TCG_CPUS_MTTCG_H */ accel/tcg/tcg-cpus-rr.c +23
-1@@ -144,7 +144,7 @@ static void deal_with_unplugged_cpus(void)* elsewhere. */ -void *tcg_rr_cpu_thread_fn (void *arg) +static void *tcg_rr_cpu_thread_fn (void *arg) {CPUState *cpu = arg;@@ -262,8 +262,43 @@ void *tcg_rr_cpu_thread_fn(void *arg)return NULL ; } +void rr_start_vcpu_thread (CPUState *cpu) +{ +char thread_name[VCPU_THREAD_NAME_SIZE ]; +static QemuCond *single_tcg_halt_cond; +static QemuThread *single_tcg_cpu_thread; + +g_assert (tcg_enabled ()); + parallel_cpus = false; + +if (!single_tcg_cpu_thread) { + cpu->thread =g_malloc0 (sizeof (QemuThread)); + cpu->halt_cond =g_malloc0 (sizeof (QemuCond)); +qemu_cond_init (cpu->halt_cond); + +/* share a single thread for all cpus with TCG */ +snprintf (thread_name,VCPU_THREAD_NAME_SIZE ,"ALL CPUs/TCG" ); +qemu_thread_create (cpu->thread, thread_name, + tcg_rr_cpu_thread_fn, + cpu,QEMU_THREAD_JOINABLE ); + + single_tcg_halt_cond = cpu->halt_cond; + single_tcg_cpu_thread = cpu->thread;
accel/tcg/tcg-cpus-rr.c void *tcg_rr_cpu_thread_fn(void *arg) · line 296
Quoted 10 lines
accel/tcg/tcg-cpus-rr.c +10
-0+#ifdef _WIN32 + cpu->hThread =qemu_thread_get_handle (cpu->thread); +#endif + }else { +/* we share the thread */ + cpu->thread = single_tcg_cpu_thread; + cpu->halt_cond = single_tcg_halt_cond; + cpu->thread_id = first_cpu->thread_id; + cpu->can_do_io =1 ; + cpu->created = true;
I was wonder if we should be duplicating hThread here but on closer examination it looks like it's only used by HAX/WHPX accelerators so maybe this is a candidate for accelerator specific CPU data?
Otherwise LGTM:
Signature · 1 line
Alex Bennée
RFC v9 3/32 accel/tcg: rename tcg-cpus functions to match module name
In reply to Claudio Fontana--- accel/tcg/tcg-cpus-icount.c | 24 ++++++------ accel/tcg/tcg-cpus-icount.h | 6 +-- accel/tcg/tcg-cpus-mttcg.c | 10 ++--- accel/tcg/tcg-cpus-rr.c | 74 ++++++++++++++++++------------------- accel/tcg/tcg-cpus-rr.h | 2 +- accel/tcg/tcg-cpus.c | 6 +-- accel/tcg/tcg-cpus.h | 6 +-- 7 files changed, 64 insertions(+), 64 deletions(-)
accel/tcg/tcg-cpus-icount.c +12 -12
@@ -36,7 +36,7 @@#include "tcg-cpus-icount.h" #include "tcg-cpus-rr.h" -static int64_t tcg_get_icount_limit (void ) +static int64_t icount_get_limit (void ) {int64_t deadline;
@@ -68,37 +68,37 @@ static int64_t tcg_get_icount_limit(void) } } -static void notify_aio_contexts (void ) +static void icount_notify_aio_contexts (void ) {/* Wake up other AioContexts. */ qemu_clock_notify (QEMU_CLOCK_VIRTUAL );qemu_clock_run_timers (QEMU_CLOCK_VIRTUAL ); } -void handle_icount_deadline (void ) +void icount_handle_deadline (void ) {assert (qemu_in_vcpu_thread ());int64_t deadline =qemu_clock_deadline_ns_all (QEMU_CLOCK_VIRTUAL ,QEMU_TIMER_ATTR_ALL );if (deadline ==0 ) { -notify_aio_contexts (); +icount_notify_aio_contexts (); } } -void prepare_icount_for_run (CPUState *cpu) +void icount_prepare_for_run (CPUState *cpu) {int insns_left;/* -* These should always be cleared by process_icount_data after +* These should always be cleared by icount_process_data after * each vCPU execution. However u16.high can be raised -* asynchronously by cpu_exit/cpu_interrupt/tcg_handle_interrupt +* asynchronously by cpu_exit/cpu_interrupt/tcg_cpus_handle_interrupt */ g_assert (cpu_neg (cpu)->icount_decr.u16.low ==0 );g_assert (cpu->icount_extra ==0 ); - cpu->icount_budget =tcg_get_icount_limit (); + cpu->icount_budget =icount_get_limit (); insns_left =MIN (0xffff , cpu->icount_budget);cpu_neg (cpu)->icount_decr.u16.low = insns_left; cpu->icount_extra = cpu->icount_budget - insns_left;
@@ -106,11 +106,11 @@ void prepare_icount_for_run(CPUState *cpu)replay_mutex_lock ();if (cpu->icount_budget ==0 &&replay_has_checkpoint ()) { -notify_aio_contexts (); +icount_notify_aio_contexts (); } } -void process_icount_data (CPUState *cpu) +void icount_process_data (CPUState *cpu) {/* Account for executed instructions */ icount_update (cpu);
@@ -129,7 +129,7 @@ static void icount_handle_interrupt(CPUState *cpu, int mask) {int old_mask = cpu->interrupt_request; -tcg_handle_interrupt (cpu, mask); +tcg_cpus_handle_interrupt (cpu, mask);if (qemu_cpu_is_self (cpu) && !cpu->can_do_io && (mask & ~old_mask) !=0 ) {
@@ -139,7 +139,7 @@ static void icount_handle_interrupt(CPUState *cpu, int mask)const CpusAccel tcg_cpus_icount = { .create_vcpu_thread = rr_start_vcpu_thread, - .kick_vcpu_thread = qemu_cpu_kick_rr_cpus, + .kick_vcpu_thread = rr_kick_vcpu_thread, .handle_interrupt = icount_handle_interrupt, .get_virtual_clock = icount_get,
accel/tcg/tcg-cpus-icount.h +3 -3
@@ -10,8 +10,8 @@#ifndef TCG_CPUS_ICOUNT_H #define TCG_CPUS_ICOUNT_H -void handle_icount_deadline (void ); -void prepare_icount_for_run (CPUState *cpu); -void process_icount_data (CPUState *cpu); +void icount_handle_deadline (void ); +void icount_prepare_for_run (CPUState *cpu); +void icount_process_data (CPUState *cpu);#endif /* TCG_CPUS_ICOUNT_H */
accel/tcg/tcg-cpus-mttcg.c +5 -5
@@ -40,7 +40,7 @@* current CPUState for a given thread. */ -static void *tcg_cpu_thread_fn (void *arg) +static void *mttcg_cpu_thread_fn (void *arg) {CPUState *cpu = arg;
@@ -66,7 +66,7 @@ static void *tcg_cpu_thread_fn(void *arg)if (cpu_can_run (cpu)) {int r;qemu_mutex_unlock_iothread (); - r =tcg_cpu_exec (cpu); + r =tcg_cpus_exec (cpu);qemu_mutex_lock_iothread ();switch (r) {case EXCP_DEBUG :
@@ -97,7 +97,7 @@ static void *tcg_cpu_thread_fn(void *arg)qemu_wait_io_event (cpu); }while (!cpu->unplug ||cpu_can_run (cpu)); -qemu_tcg_destroy_vcpu (cpu); +tcg_cpus_destroy (cpu);qemu_mutex_unlock_iothread ();rcu_unregister_thread ();return NULL ;
@@ -124,7 +124,7 @@ static void mttcg_start_vcpu_thread(CPUState *cpu)snprintf (thread_name,VCPU_THREAD_NAME_SIZE ,"CPU %d/TCG" , cpu->cpu_index); -qemu_thread_create (cpu->thread, thread_name, tcg_cpu_thread_fn, +qemu_thread_create (cpu->thread, thread_name, mttcg_cpu_thread_fn, cpu,QEMU_THREAD_JOINABLE );#ifdef _WIN32
@@ -136,5 +136,5 @@ const CpusAccel tcg_cpus_mttcg = { .create_vcpu_thread = mttcg_start_vcpu_thread, .kick_vcpu_thread = mttcg_kick_vcpu_thread, - .handle_interrupt = tcg_handle_interrupt, + .handle_interrupt = tcg_cpus_handle_interrupt, };
accel/tcg/tcg-cpus-rr.c +37 -37
187 lines not on this page · raw message
accel/tcg/tcg-cpus-rr.h +1 -1
@@ -13,7 +13,7 @@#define TCG_KICK_PERIOD (NANOSECONDS_PER_SECOND / 10)/* Kick all RR vCPUs. */ -void qemu_cpu_kick_rr_cpus (CPUState *unused); +void rr_kick_vcpu_thread (CPUState *unused);/* start the round robin vcpu thread */ void rr_start_vcpu_thread (CPUState *cpu);
accel/tcg/tcg-cpus.c +3 -3
@@ -38,12 +38,12 @@/* common functionality among all TCG variants */ -void qemu_tcg_destroy_vcpu (CPUState *cpu) +void tcg_cpus_destroy (CPUState *cpu) {cpu_thread_signal_destroyed (cpu); } -int tcg_cpu_exec (CPUState *cpu) +int tcg_cpus_exec (CPUState *cpu) {int ret;#ifdef CONFIG_PROFILER
@@ -64,7 +64,7 @@ int tcg_cpu_exec(CPUState *cpu) }/* mask must never be zero, except for A20 change call */ -void tcg_handle_interrupt (CPUState *cpu,int mask) +void tcg_cpus_handle_interrupt (CPUState *cpu,int mask) {g_assert (qemu_mutex_iothread_locked ());
accel/tcg/tcg-cpus.h +3 -3
@@ -18,8 +18,8 @@ extern const CpusAccel tcg_cpus_mttcg;extern const CpusAccel tcg_cpus_icount;extern const CpusAccel tcg_cpus_rr; -void qemu_tcg_destroy_vcpu (CPUState *cpu); -int tcg_cpu_exec (CPUState *cpu); -void tcg_handle_interrupt (CPUState *cpu,int mask); +void tcg_cpus_destroy (CPUState *cpu); +int tcg_cpus_exec (CPUState *cpu); +void tcg_cpus_handle_interrupt (CPUState *cpu,int mask);#endif /* TCG_CPUS_H */
Signature · 1 line
2.26.2
Re: [RFC v9 03/32] accel/tcg: rename tcg-cpus functions to match module name
Quoted 27 lines · Claudio Fontana
Signed-off-by Claudio Fontana <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Richard Henderson <[email protected]>--- accel/tcg/tcg-cpus-icount.c | 24 ++++++------ accel/tcg/tcg-cpus-icount.h | 6 +-- accel/tcg/tcg-cpus-mttcg.c | 10 ++--- accel/tcg/tcg-cpus-rr.c | 74 ++++++++++++++++++------------------- accel/tcg/tcg-cpus-rr.h | 2 +- accel/tcg/tcg-cpus.c | 6 +-- accel/tcg/tcg-cpus.h | 6 +-- 7 files changed, 64 insertions(+), 64 deletions(-)accel/tcg/tcg-cpus-icount.c +1
-1@@ -36,7 +36,7 @@#include "tcg-cpus-icount.h" #include "tcg-cpus-rr.h" -static int64_t tcg_get_icount_limit (void ) +static int64_t icount_get_limit (void ) {int64_t deadline;
accel/tcg/tcg-cpus-icount.c static int64_t tcg_get_icount_limit(void) · line 76
Quoted 10 lines
accel/tcg/tcg-cpus-icount.c +1
-1@@ -68,37 +68,37 @@ static int64_t tcg_get_icount_limit(void) } } -static void notify_aio_contexts (void ) +static void icount_notify_aio_contexts (void ) {/* Wake up other AioContexts. */ qemu_clock_notify (QEMU_CLOCK_VIRTUAL );qemu_clock_run_timers (QEMU_CLOCK_VIRTUAL ); }
nit: for static functions it's probably overkill but whatever...
Signature · 1 line
Alex Bennée
RFC v9 4/32 i386: move kvm accel files into kvm/
In reply to Claudio Fontana---
MAINTAINERS | 2 +-
hw/i386/fw_cfg.c | 2 +-
hw/i386/intel_iommu.c | 2 +-
hw/i386/kvm/apic.c | 2 +-
hw/i386/kvm/clock.c | 2 +-
hw/i386/microvm.c | 2 +-
hw/i386/pc.c | 2 +-
hw/i386/x86.c | 2 +-
meson.build | 1 +
target/i386/cpu.c | 2 +-
target/i386/cpu.h | 2 +-
target/i386/helper.c | 2 +-
target/i386/{ => kvm}/hyperv-proto.h | 0
target/i386/{ => kvm}/hyperv-stub.c | 0
target/i386/{ => kvm}/hyperv.c | 0
target/i386/{ => kvm}/hyperv.h | 0
target/i386/{ => kvm}/kvm-stub.c | 0
target/i386/{ => kvm}/kvm.c | 0
target/i386/{ => kvm}/kvm_i386.h | 0
target/i386/kvm/meson.build | 3 +++
target/i386/kvm/trace-events | 7 +++++++
target/i386/kvm/trace.h | 1 +
target/i386/machine.c | 4 ++--
target/i386/meson.build | 4 +---
target/i386/trace-events | 6 ------
25 files changed, 26 insertions(+), 22 deletions(-)
rename target/i386/{ => kvm}/hyperv-proto.h (100%)
rename target/i386/{ => kvm}/hyperv-stub.c (100%)
rename target/i386/{ => kvm}/hyperv.c (100%)
rename target/i386/{ => kvm}/hyperv.h (100%)
rename target/i386/{ => kvm}/kvm-stub.c (100%)
rename target/i386/{ => kvm}/kvm.c (100%)
rename target/i386/{ => kvm}/kvm_i386.h (100%)
create mode 100644 target/i386/kvm/meson.build
create mode 100644 target/i386/kvm/trace-events
create mode 100644 target/i386/kvm/trace.hMAINTAINERS +1 -1
@@ -425,7 +425,7 @@ M: Paolo Bonzini <[email protected]> M: Marcelo Tosatti <[email protected]> L: [email protected] S: Supported -F: target/i386/kvm.c +F: target/i386/kvm/ F: scripts/kvm/vmxcap Guest CPU Cores (other accelerators)
hw/i386/fw_cfg.c +1 -1
@@ -21,7 +21,7 @@#include "hw/timer/hpet.h" #include "hw/nvram/fw_cfg.h" #include "e820_memory_layout.h" -#include "kvm_i386.h" +#include "kvm/kvm_i386.h" #include CONFIG_DEVICES struct hpet_fw_config hpet_cfg = {.count =UINT8_MAX };
hw/i386/intel_iommu.c +1 -1
@@ -37,7 +37,7 @@#include "sysemu/kvm.h" #include "sysemu/sysemu.h" #include "hw/i386/apic_internal.h" -#include "kvm_i386.h" +#include "kvm/kvm_i386.h" #include "migration/vmstate.h" #include "trace.h"
hw/i386/kvm/apic.c +1 -1
@@ -17,7 +17,7 @@#include "hw/pci/msi.h" #include "sysemu/hw_accel.h" #include "sysemu/kvm.h" -#include "target/i386/kvm_i386.h" +#include "kvm/kvm_i386.h" static inline void kvm_apic_set_reg (struct kvm_lapic_state *kapic,int reg_id,uint32_t val)
hw/i386/kvm/clock.c +1 -1
@@ -20,7 +20,7 @@#include "sysemu/kvm.h" #include "sysemu/runstate.h" #include "sysemu/hw_accel.h" -#include "kvm_i386.h" +#include "kvm/kvm_i386.h" #include "migration/vmstate.h" #include "hw/sysbus.h" #include "hw/kvm/clock.h"
hw/i386/microvm.c +1 -1
@@ -51,7 +51,7 @@#include "cpu.h" #include "elf.h" -#include "kvm_i386.h" +#include "kvm/kvm_i386.h" #include "hw/xen/start_info.h" #define MICROVM_QBOOT_FILENAME "qboot.rom"
hw/i386/pc.c +1 -1
@@ -61,7 +61,7 @@#include "sysemu/qtest.h" #include "sysemu/reset.h" #include "sysemu/runstate.h" -#include "kvm_i386.h" +#include "kvm/kvm_i386.h" #include "hw/xen/xen.h" #include "hw/xen/start_info.h" #include "ui/qemu-spice.h"
hw/i386/x86.c +1 -1
@@ -52,7 +52,7 @@#include "elf.h" #include "standard-headers/asm-x86/bootparam.h" #include CONFIG_DEVICES -#include "kvm_i386.h" +#include "kvm/kvm_i386.h" #define BIOS_FILENAME "bios.bin"
meson.build +1 -0
@@ -1467,6 +1467,7 @@ trace_events_subdirs += [ 'target/arm', 'target/hppa', 'target/i386', + 'target/i386/kvm', 'target/mips', 'target/ppc', 'target/riscv',
target/i386/cpu.c +1 -1
@@ -30,7 +30,7 @@#include "sysemu/hvf.h" #include "sysemu/cpus.h" #include "sysemu/xen.h" -#include "kvm_i386.h" +#include "kvm/kvm_i386.h" #include "sev_i386.h" #include "qemu/error-report.h"
target/i386/cpu.h +1 -1
@@ -22,7 +22,7 @@#include "sysemu/tcg.h" #include "cpu-qom.h" -#include "hyperv-proto.h" +#include "kvm/hyperv-proto.h" #include "exec/cpu-defs.h" #include "qapi/qapi-types-common.h"
target/i386/helper.c +1 -1
@@ -24,7 +24,7 @@#include "qemu/qemu-print.h" #include "sysemu/kvm.h" #include "sysemu/runstate.h" -#include "kvm_i386.h" +#include "kvm/kvm_i386.h" #ifndef CONFIG_USER_ONLY #include "sysemu/tcg.h" #include "sysemu/hw_accel.h"
target/i386/kvm/hyperv-proto.h renamed from target/i386/hyperv-proto.h +0 -0
target/i386/kvm/hyperv-stub.c renamed from target/i386/hyperv-stub.c +0 -0
target/i386/kvm/hyperv.c renamed from target/i386/hyperv.c +0 -0
target/i386/kvm/hyperv.h renamed from target/i386/hyperv.h +0 -0
target/i386/kvm/kvm-stub.c renamed from target/i386/kvm-stub.c +0 -0
target/i386/kvm/kvm.c renamed from target/i386/kvm.c +0 -0
target/i386/kvm/kvm_i386.h renamed from target/i386/kvm_i386.h +0 -0
target/i386/kvm/meson.build new file +3 -0
@@ -0,0 +1,3 @@ +i386_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c')) +i386_softmmu_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c')) +i386_softmmu_ss.add(when: 'CONFIG_HYPERV', if_true: files('hyperv.c'), if_false: files('hyperv-stub.c'))
target/i386/kvm/trace-events new file +7 -0
@@ -0,0 +1,7 @@ +# See docs/devel/tracing.txt for syntax documentation. + +# kvm.c +kvm_x86_fixup_msi_error(uint32_t gsi) "VT-d failed to remap interrupt for GSI %" PRIu32 +kvm_x86_add_msi_route(int virq) "Adding route entry for virq %d" +kvm_x86_remove_msi_route(int virq) "Removing route entry for virq %d" +kvm_x86_update_msi_routes(int num) "Updated %d MSI routes"
target/i386/kvm/trace.h new file +1 -0
@@ -0,0 +1 @@ +#include "trace/trace-target_i386_kvm.h"
target/i386/machine.c +2 -2
@@ -3,9 +3,9 @@#include "exec/exec-all.h" #include "hw/isa/isa.h" #include "migration/cpu.h" -#include "hyperv.h" +#include "kvm/hyperv.h" #include "hw/i386/x86.h" -#include "kvm_i386.h" +#include "kvm/kvm_i386.h" #include "sysemu/kvm.h" #include "sysemu/tcg.h"
target/i386/meson.build +1 -3
@@ -18,7 +18,6 @@ i386_ss.add(when: 'CONFIG_TCG', if_true: files( 'smm_helper.c', 'svm_helper.c', 'translate.c'), if_false: files('tcg-stub.c')) -i386_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c')) i386_ss.add(when: 'CONFIG_SEV', if_true: files('sev.c'), if_false: files('sev-stub.c')) i386_softmmu_ss = ss.source_set()
@@ -28,8 +27,6 @@ i386_softmmu_ss.add(files( 'machine.c', 'monitor.c', )) -i386_softmmu_ss.add(when: 'CONFIG_HYPERV', if_true: files('hyperv.c'), if_false: files('hyperv-stub.c')) -i386_softmmu_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c')) i386_softmmu_ss.add(when: 'CONFIG_WHPX', if_true: files( 'whpx-all.c', 'whpx-cpus.c',
@@ -42,6 +39,7 @@ i386_softmmu_ss.add(when: 'CONFIG_HAX', if_true: files( i386_softmmu_ss.add(when: ['CONFIG_HAX', 'CONFIG_POSIX'], if_true: files('hax-posix.c')) i386_softmmu_ss.add(when: ['CONFIG_HAX', 'CONFIG_WIN32'], if_true: files('hax-windows.c')) +subdir('kvm') subdir('hvf') target_arch += {'i386': i386_ss}
target/i386/trace-events +0 -6
@@ -1,11 +1,5 @@ # See docs/devel/tracing.txt for syntax documentation. -# kvm.c -kvm_x86_fixup_msi_error(uint32_t gsi) "VT-d failed to remap interrupt for GSI %" PRIu32 -kvm_x86_add_msi_route(int virq) "Adding route entry for virq %d" -kvm_x86_remove_msi_route(int virq) "Removing route entry for virq %d" -kvm_x86_update_msi_routes(int num) "Updated %d MSI routes" - # sev.c kvm_sev_init(void) "" kvm_memcrypt_register_region(void *addr, size_t len) "addr %p len 0x%zu"
Signature · 1 line
2.26.2
Re: [RFC v9 04/32] i386: move kvm accel files into kvm/
Quoted 1 line · Claudio Fontana
Signed-off-by Claudio Fontana <[email protected]>
Signature · 1 line
Alex Bennée
RFC v9 5/32 i386: move whpx accel files into whpx/
In reply to Claudio Fontana---
MAINTAINERS | 5 +----
target/i386/meson.build | 5 +----
target/i386/whpx/meson.build | 4 ++++
target/i386/{ => whpx}/whp-dispatch.h | 0
target/i386/{ => whpx}/whpx-all.c | 0
target/i386/{ => whpx}/whpx-cpus.c | 0
target/i386/{ => whpx}/whpx-cpus.h | 0
7 files changed, 6 insertions(+), 8 deletions(-)
create mode 100644 target/i386/whpx/meson.build
rename target/i386/{ => whpx}/whp-dispatch.h (100%)
rename target/i386/{ => whpx}/whpx-all.c (100%)
rename target/i386/{ => whpx}/whpx-cpus.c (100%)
rename target/i386/{ => whpx}/whpx-cpus.h (100%)MAINTAINERS +1 -4
@@ -451,10 +451,7 @@ F: include/sysemu/hvf.h WHPX CPUs M: Sunil Muthuswamy <[email protected]> S: Supported -F: target/i386/whpx-all.c -F: target/i386/whpx-cpus.c -F: target/i386/whp-dispatch.h -F: accel/stubs/whpx-stub.c +F: target/i386/whpx/ F: include/sysemu/whpx.h Guest CPU Cores (Xen)
target/i386/meson.build +1 -4
@@ -27,10 +27,6 @@ i386_softmmu_ss.add(files( 'machine.c', 'monitor.c', )) -i386_softmmu_ss.add(when: 'CONFIG_WHPX', if_true: files( - 'whpx-all.c', - 'whpx-cpus.c', -)) i386_softmmu_ss.add(when: 'CONFIG_HAX', if_true: files( 'hax-all.c', 'hax-mem.c',
@@ -40,6 +36,7 @@ i386_softmmu_ss.add(when: ['CONFIG_HAX', 'CONFIG_POSIX'], if_true: files('hax-po i386_softmmu_ss.add(when: ['CONFIG_HAX', 'CONFIG_WIN32'], if_true: files('hax-windows.c')) subdir('kvm') +subdir('whpx') subdir('hvf') target_arch += {'i386': i386_ss}
target/i386/whpx/meson.build new file +4 -0
@@ -0,0 +1,4 @@ +i386_softmmu_ss.add(when: 'CONFIG_WHPX', if_true: files( + 'whpx-all.c', + 'whpx-cpus.c', +))
target/i386/whpx/whp-dispatch.h renamed from target/i386/whp-dispatch.h +0 -0
target/i386/whpx/whpx-all.c renamed from target/i386/whpx-all.c +0 -0
target/i386/whpx/whpx-cpus.c renamed from target/i386/whpx-cpus.c +0 -0
target/i386/whpx/whpx-cpus.h renamed from target/i386/whpx-cpus.h +0 -0
Signature · 1 line
2.26.2
Re: [RFC v9 05/32] i386: move whpx accel files into whpx/
Quoted 21 lines · Claudio Fontana
Signed-off-by Claudio Fontana <[email protected]>--- MAINTAINERS | 5 +---- target/i386/meson.build | 5 +---- target/i386/whpx/meson.build | 4 ++++ target/i386/{ => whpx}/whp-dispatch.h | 0 target/i386/{ => whpx}/whpx-all.c | 0 target/i386/{ => whpx}/whpx-cpus.c | 0 target/i386/{ => whpx}/whpx-cpus.h | 0 7 files changed, 6 insertions(+), 8 deletions(-) create mode 100644 target/i386/whpx/meson.build rename target/i386/{ => whpx}/whp-dispatch.h (100%) rename target/i386/{ => whpx}/whpx-all.c (100%) rename target/i386/{ => whpx}/whpx-cpus.c (100%) rename target/i386/{ => whpx}/whpx-cpus.h (100%)MAINTAINERS +0
-0
MAINTAINERS F: include/sysemu/hvf.h · line 457
Quoted 7 lines
MAINTAINERS +0
-4@@ -451,10 +451,7 @@ F: include/sysemu/hvf.h WHPX CPUs M: Sunil Muthuswamy <[email protected]> S: Supported -F: target/i386/whpx-all.c -F: target/i386/whpx-cpus.c -F: target/i386/whp-dispatch.h -F: accel/stubs/whpx-stub.c
heh - we never had a stubs...
Signature · 1 line
Alex Bennée
RFC v9 6/32 i386: move hax accel files into hax/
In reply to Claudio Fontana---
MAINTAINERS | 2 +-
target/i386/{ => hax}/hax-all.c | 0
target/i386/{ => hax}/hax-cpus.c | 0
target/i386/{ => hax}/hax-cpus.h | 0
target/i386/{ => hax}/hax-i386.h | 6 +++---
target/i386/{ => hax}/hax-interface.h | 0
target/i386/{ => hax}/hax-mem.c | 0
target/i386/{ => hax}/hax-posix.c | 0
target/i386/{ => hax}/hax-posix.h | 0
target/i386/{ => hax}/hax-windows.c | 0
target/i386/{ => hax}/hax-windows.h | 0
target/i386/hax/meson.build | 7 +++++++
target/i386/meson.build | 8 +-------
13 files changed, 12 insertions(+), 11 deletions(-)
rename target/i386/{ => hax}/hax-all.c (100%)
rename target/i386/{ => hax}/hax-cpus.c (100%)
rename target/i386/{ => hax}/hax-cpus.h (100%)
rename target/i386/{ => hax}/hax-i386.h (95%)
rename target/i386/{ => hax}/hax-interface.h (100%)
rename target/i386/{ => hax}/hax-mem.c (100%)
rename target/i386/{ => hax}/hax-posix.c (100%)
rename target/i386/{ => hax}/hax-posix.h (100%)
rename target/i386/{ => hax}/hax-windows.c (100%)
rename target/i386/{ => hax}/hax-windows.h (100%)
create mode 100644 target/i386/hax/meson.buildMAINTAINERS +1 -1
@@ -491,7 +491,7 @@ W: https://github.com/intel/haxm/issues S: Maintained F: accel/stubs/hax-stub.c F: include/sysemu/hax.h -F: target/i386/hax-* +F: target/i386/hax/ Hosts -----
target/i386/hax/hax-all.c renamed from target/i386/hax-all.c +0 -0
target/i386/hax/hax-cpus.c renamed from target/i386/hax-cpus.c +0 -0
target/i386/hax/hax-cpus.h renamed from target/i386/hax-cpus.h +0 -0
target/i386/hax/hax-i386.h renamed from target/i386/hax-i386.h +3 -3
@@ -84,13 +84,13 @@ void hax_memory_init(void);#ifdef CONFIG_POSIX -#include "target/i386/hax-posix.h" +#include "hax-posix.h" #endif #ifdef CONFIG_WIN32 -#include "target/i386/hax-windows.h" +#include "hax-windows.h" #endif -#include "target/i386/hax-interface.h" +#include "hax-interface.h" #endif
target/i386/hax/hax-interface.h renamed from target/i386/hax-interface.h +0 -0
target/i386/hax/hax-mem.c renamed from target/i386/hax-mem.c +0 -0
target/i386/hax/hax-posix.c renamed from target/i386/hax-posix.c +0 -0
target/i386/hax/hax-posix.h renamed from target/i386/hax-posix.h +0 -0
target/i386/hax/hax-windows.c renamed from target/i386/hax-windows.c +0 -0
target/i386/hax/hax-windows.h renamed from target/i386/hax-windows.h +0 -0
target/i386/hax/meson.build new file +7 -0
@@ -0,0 +1,7 @@ +i386_softmmu_ss.add(when: 'CONFIG_HAX', if_true: files( + 'hax-all.c', + 'hax-mem.c', + 'hax-cpus.c', +)) +i386_softmmu_ss.add(when: ['CONFIG_HAX', 'CONFIG_POSIX'], if_true: files('hax-posix.c')) +i386_softmmu_ss.add(when: ['CONFIG_HAX', 'CONFIG_WIN32'], if_true: files('hax-windows.c'))
target/i386/meson.build +1 -7
@@ -27,15 +27,9 @@ i386_softmmu_ss.add(files( 'machine.c', 'monitor.c', )) -i386_softmmu_ss.add(when: 'CONFIG_HAX', if_true: files( - 'hax-all.c', - 'hax-mem.c', - 'hax-cpus.c', -)) -i386_softmmu_ss.add(when: ['CONFIG_HAX', 'CONFIG_POSIX'], if_true: files('hax-posix.c')) -i386_softmmu_ss.add(when: ['CONFIG_HAX', 'CONFIG_WIN32'], if_true: files('hax-windows.c')) subdir('kvm') +subdir('hax') subdir('whpx') subdir('hvf')
Signature · 1 line
2.26.2
Re: [RFC v9 06/32] i386: move hax accel files into hax/
Quoted 1 line · Claudio Fontana
Signed-off-by Claudio Fontana <[email protected]>
Signature · 1 line
Alex Bennée
RFC v9 7/32 i386: hvf: remove stale MAINTAINERS entry for old hvf stubs
In reply to Claudio Fontana--- MAINTAINERS | 1 - 1 file changed, 1 deletion(-)
MAINTAINERS +0 -1
@@ -444,7 +444,6 @@ M: Cameron Esfahani <[email protected]> M: Roman Bolshakov <[email protected]> W: https://wiki.qemu.org/Features/HVF S: Maintained -F: accel/stubs/hvf-stub.c F: target/i386/hvf/ F: include/sysemu/hvf.h
Signature · 1 line
2.26.2
Re: [RFC v9 07/32] i386: hvf: remove stale MAINTAINERS entry for old hvf stubs
Quoted 2 lines · Claudio Fontana
Signed-off-by Claudio Fontana <[email protected]>Reviewed-by Roman Bolshakov <[email protected]>
Signature · 1 line
Alex Bennée
RFC v9 8/32 i386: move TCG accel files into tcg/
In reply to Claudio Fontana---
target/i386/meson.build | 14 +-------------
target/i386/{ => tcg}/bpt_helper.c | 0
target/i386/{ => tcg}/cc_helper.c | 0
target/i386/{ => tcg}/excp_helper.c | 0
target/i386/{ => tcg}/fpu_helper.c | 0
target/i386/{ => tcg}/int_helper.c | 0
target/i386/{ => tcg}/mem_helper.c | 0
target/i386/tcg/meson.build | 13 +++++++++++++
target/i386/{ => tcg}/misc_helper.c | 0
target/i386/{ => tcg}/mpx_helper.c | 0
target/i386/{ => tcg}/seg_helper.c | 0
target/i386/{ => tcg}/smm_helper.c | 0
target/i386/{ => tcg}/svm_helper.c | 0
target/i386/{ => tcg}/tcg-stub.c | 0
target/i386/{ => tcg}/translate.c | 0
15 files changed, 14 insertions(+), 13 deletions(-)
rename target/i386/{ => tcg}/bpt_helper.c (100%)
rename target/i386/{ => tcg}/cc_helper.c (100%)
rename target/i386/{ => tcg}/excp_helper.c (100%)
rename target/i386/{ => tcg}/fpu_helper.c (100%)
rename target/i386/{ => tcg}/int_helper.c (100%)
rename target/i386/{ => tcg}/mem_helper.c (100%)
create mode 100644 target/i386/tcg/meson.build
rename target/i386/{ => tcg}/misc_helper.c (100%)
rename target/i386/{ => tcg}/mpx_helper.c (100%)
rename target/i386/{ => tcg}/seg_helper.c (100%)
rename target/i386/{ => tcg}/smm_helper.c (100%)
rename target/i386/{ => tcg}/svm_helper.c (100%)
rename target/i386/{ => tcg}/tcg-stub.c (100%)
rename target/i386/{ => tcg}/translate.c (100%)target/i386/meson.build +1 -13
@@ -5,19 +5,6 @@ i386_ss.add(files( 'helper.c', 'xsave_helper.c', )) -i386_ss.add(when: 'CONFIG_TCG', if_true: files( - 'bpt_helper.c', - 'cc_helper.c', - 'excp_helper.c', - 'fpu_helper.c', - 'int_helper.c', - 'mem_helper.c', - 'misc_helper.c', - 'mpx_helper.c', - 'seg_helper.c', - 'smm_helper.c', - 'svm_helper.c', - 'translate.c'), if_false: files('tcg-stub.c')) i386_ss.add(when: 'CONFIG_SEV', if_true: files('sev.c'), if_false: files('sev-stub.c')) i386_softmmu_ss = ss.source_set()
@@ -32,6 +19,7 @@ subdir('kvm') subdir('hax') subdir('whpx') subdir('hvf') +subdir('tcg') target_arch += {'i386': i386_ss} target_softmmu_arch += {'i386': i386_softmmu_ss}
target/i386/tcg/bpt_helper.c renamed from target/i386/bpt_helper.c +0 -0
target/i386/tcg/cc_helper.c renamed from target/i386/cc_helper.c +0 -0
target/i386/tcg/excp_helper.c renamed from target/i386/excp_helper.c +0 -0
target/i386/tcg/fpu_helper.c renamed from target/i386/fpu_helper.c +0 -0
target/i386/tcg/int_helper.c renamed from target/i386/int_helper.c +0 -0
target/i386/tcg/mem_helper.c renamed from target/i386/mem_helper.c +0 -0
target/i386/tcg/meson.build new file +13 -0
@@ -0,0 +1,13 @@ +i386_ss.add(when: 'CONFIG_TCG', if_true: files( + 'bpt_helper.c', + 'cc_helper.c', + 'excp_helper.c', + 'fpu_helper.c', + 'int_helper.c', + 'mem_helper.c', + 'misc_helper.c', + 'mpx_helper.c', + 'seg_helper.c', + 'smm_helper.c', + 'svm_helper.c', + 'translate.c'), if_false: files('tcg-stub.c'))
target/i386/tcg/misc_helper.c renamed from target/i386/misc_helper.c +0 -0
target/i386/tcg/mpx_helper.c renamed from target/i386/mpx_helper.c +0 -0
target/i386/tcg/seg_helper.c renamed from target/i386/seg_helper.c +0 -0
target/i386/tcg/smm_helper.c renamed from target/i386/smm_helper.c +0 -0
target/i386/tcg/svm_helper.c renamed from target/i386/svm_helper.c +0 -0
target/i386/tcg/tcg-stub.c renamed from target/i386/tcg-stub.c +0 -0
target/i386/tcg/translate.c renamed from target/i386/translate.c +0 -0
Signature · 1 line
2.26.2
Re: [RFC v9 08/32] i386: move TCG accel files into tcg/
Quoted 24 lines · Claudio Fontana
Signed-off-by Claudio Fontana <[email protected]>--- target/i386/meson.build | 14 +------------- target/i386/{ => tcg}/bpt_helper.c | 0 target/i386/{ => tcg}/cc_helper.c | 0 target/i386/{ => tcg}/excp_helper.c | 0 target/i386/{ => tcg}/fpu_helper.c | 0 target/i386/{ => tcg}/int_helper.c | 0 target/i386/{ => tcg}/mem_helper.c | 0 target/i386/tcg/meson.build | 13 +++++++++++++ target/i386/{ => tcg}/misc_helper.c | 0 target/i386/{ => tcg}/mpx_helper.c | 0 target/i386/{ => tcg}/seg_helper.c | 0 target/i386/{ => tcg}/smm_helper.c | 0 target/i386/{ => tcg}/svm_helper.c | 0 target/i386/{ => tcg}/tcg-stub.c | 0 target/i386/{ => tcg}/translate.c | 0 15 files changed, 14 insertions(+), 13 deletions(-) rename target/i386/{ => tcg}/bpt_helper.c (100%) rename target/i386/{ => tcg}/cc_helper.c (100%) rename target/i386/{ => tcg}/excp_helper.c (100%) rename target/i386/{ => tcg}/fpu_helper.c (100%) rename target/i386/{ => tcg}/int_helper.c (100%) rename target/i386/{ => tcg}/mem_helper.c (100%)
Quoted 8 lines
create mode 100644 target/i386/tcg/meson.build
rename target/i386/{ => tcg}/misc_helper.c (100%)
rename target/i386/{ => tcg}/mpx_helper.c (100%)
rename target/i386/{ => tcg}/seg_helper.c (100%)
rename target/i386/{ => tcg}/smm_helper.c (100%)
rename target/i386/{ => tcg}/svm_helper.c (100%)
rename target/i386/{ => tcg}/tcg-stub.c (100%)
rename target/i386/{ => tcg}/translate.c (100%)I noticed target/i386/helper-tcg.h is still in the main directory. It maybe be a straggler that is harder to separate - if so might be worth mentioning in the commit message. Otherwise:
Signature · 1 line
Alex Bennée
Re: [RFC v9 08/32] i386: move TCG accel files into tcg/
Quoted 36 lines · Alex Bennée
Quoted 24 lines · Claudio Fontana
Signed-off-by Claudio Fontana <[email protected]>--- target/i386/meson.build | 14 +------------- target/i386/{ => tcg}/bpt_helper.c | 0 target/i386/{ => tcg}/cc_helper.c | 0 target/i386/{ => tcg}/excp_helper.c | 0 target/i386/{ => tcg}/fpu_helper.c | 0 target/i386/{ => tcg}/int_helper.c | 0 target/i386/{ => tcg}/mem_helper.c | 0 target/i386/tcg/meson.build | 13 +++++++++++++ target/i386/{ => tcg}/misc_helper.c | 0 target/i386/{ => tcg}/mpx_helper.c | 0 target/i386/{ => tcg}/seg_helper.c | 0 target/i386/{ => tcg}/smm_helper.c | 0 target/i386/{ => tcg}/svm_helper.c | 0 target/i386/{ => tcg}/tcg-stub.c | 0 target/i386/{ => tcg}/translate.c | 0 15 files changed, 14 insertions(+), 13 deletions(-) rename target/i386/{ => tcg}/bpt_helper.c (100%) rename target/i386/{ => tcg}/cc_helper.c (100%) rename target/i386/{ => tcg}/excp_helper.c (100%) rename target/i386/{ => tcg}/fpu_helper.c (100%) rename target/i386/{ => tcg}/int_helper.c (100%) rename target/i386/{ => tcg}/mem_helper.c (100%)Quoted 8 lines
create mode 100644 target/i386/tcg/meson.build rename target/i386/{ => tcg}/misc_helper.c (100%) rename target/i386/{ => tcg}/mpx_helper.c (100%) rename target/i386/{ => tcg}/seg_helper.c (100%) rename target/i386/{ => tcg}/smm_helper.c (100%) rename target/i386/{ => tcg}/svm_helper.c (100%) rename target/i386/{ => tcg}/tcg-stub.c (100%) rename target/i386/{ => tcg}/translate.c (100%)
Quoted 1 line
I noticed
target/i386/helper-tcg.his still in the main directory. It
This is something to fix in
i386: move TCG cpu class initialization out of helper.c
will do, thanks!
Quoted 5 lines
maybe be a straggler that is harder to separate - if so might be worth mentioning in the commit message. Otherwise:
Reviewed-by Alex Bennée <[email protected]>
RFC v9 9/32 i386: move cpu dump out of helper.c into cpu-dump.c
In reply to Claudio Fontana--- target/i386/cpu-dump.c | 537 ++++++++++++++++++++++++++++++++++++++++ target/i386/cpu.h | 1 + target/i386/helper.c | 514 -------------------------------------- target/i386/meson.build | 1 + 4 files changed, 539 insertions(+), 514 deletions(-) create mode 100644 target/i386/cpu-dump.c
target/i386/cpu-dump.c new file +537 -0
@@ -0,0 +1,537 @@ +/* +* i386 CPU dump to FILE +* +* Copyright (c) 2003 Fabrice Bellard +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "qemu/qemu-print.h" +#ifndef CONFIG_USER_ONLY +#include "hw/i386/apic_internal.h" +#endif + +/***********************************************************/ +/* x86 debug */ + +static const char *cc_op_str[CC_OP_NB ] = { +"DYNAMIC" , +"EFLAGS" , + +"MULB" , +"MULW" , +"MULL" , +"MULQ" , + +"ADDB" , +"ADDW" , +"ADDL" , +"ADDQ" , + +"ADCB" , +"ADCW" , +"ADCL" , +"ADCQ" , + +"SUBB" , +"SUBW" , +"SUBL" , +"SUBQ" , + +"SBBB" , +"SBBW" , +"SBBL" , +"SBBQ" , + +"LOGICB" , +"LOGICW" , +"LOGICL" , +"LOGICQ" , + +"INCB" , +"INCW" , +"INCL" , +"INCQ" , + +"DECB" , +"DECW" , +"DECL" , +"DECQ" , + +"SHLB" , +"SHLW" , +"SHLL" , +"SHLQ" , + +"SARB" , +"SARW" , +"SARL" , +"SARQ" , + +"BMILGB" , +"BMILGW" , +"BMILGL" , +"BMILGQ" , + +"ADCX" , +"ADOX" , +"ADCOX" , + +"CLR" , +}; + +static void +cpu_x86_dump_seg_cache (CPUX86State *env,FILE *f, +const char *name,struct SegmentCache *sc) +{ +#ifdef TARGET_X86_64 +if (env->hflags &HF_CS64_MASK ) { +qemu_fprintf (f,"%-3s=%04x %016" PRIx64" %08x %08x" , name, + sc->selector, sc->base, sc->limit, + sc->flags &0x00ffff00 ); + } else +#endif + { +qemu_fprintf (f,"%-3s=%04x %08x %08x %08x" , name, sc->selector, + (uint32_t )sc->base, sc->limit, + sc->flags &0x00ffff00 ); + } + +if (!(env->hflags &HF_PE_MASK ) || !(sc->flags &DESC_P_MASK )) + goto done; + +qemu_fprintf (f," DPL=%d " , + (sc->flags &DESC_DPL_MASK ) >>DESC_DPL_SHIFT ); +if (sc->flags &DESC_S_MASK ) { +if (sc->flags &DESC_CS_MASK ) { +qemu_fprintf (f, (sc->flags &DESC_L_MASK ) ?"CS64" : + ((sc->flags &DESC_B_MASK ) ?"CS32" :"CS16" )); +qemu_fprintf (f," [%c%c" , (sc->flags &DESC_C_MASK ) ?'C' :'-' , + (sc->flags &DESC_R_MASK ) ?'R' :'-' ); + }else { +qemu_fprintf (f, (sc->flags &DESC_B_MASK + || env->hflags &HF_LMA_MASK ) + ?"DS " :"DS16" ); +qemu_fprintf (f," [%c%c" , (sc->flags &DESC_E_MASK ) ?'E' :'-' , + (sc->flags &DESC_W_MASK ) ?'W' :'-' ); + } +qemu_fprintf (f,"%c]" , (sc->flags &DESC_A_MASK ) ?'A' :'-' ); + }else { +static const char *sys_type_name[2 ][16 ] = { + {/* 32 bit mode */ +"Reserved" ,"TSS16-avl" ,"LDT" ,"TSS16-busy" , +"CallGate16" ,"TaskGate" ,"IntGate16" ,"TrapGate16" , +"Reserved" ,"TSS32-avl" ,"Reserved" ,"TSS32-busy" , +"CallGate32" ,"Reserved" ,"IntGate32" ,"TrapGate32" + }, + {/* 64 bit mode */ +"<hiword>" ,"Reserved" ,"LDT" ,"Reserved" ,"Reserved" , +"Reserved" ,"Reserved" ,"Reserved" ,"Reserved" , +"TSS64-avl" ,"Reserved" ,"TSS64-busy" ,"CallGate64" , +"Reserved" ,"IntGate64" ,"TrapGate64" + } + }; +qemu_fprintf (f,"%s" , + sys_type_name[(env->hflags &HF_LMA_MASK ) ?1 :0 ] + [(sc->flags &DESC_TYPE_MASK ) >>DESC_TYPE_SHIFT ]); + } +done: +qemu_fprintf (f,"\n" ); +} + +#ifndef CONFIG_USER_ONLY + +/* ARRAY_SIZE check is not required because +* DeliveryMode(dm) has a size of 3 bit. +*/ +static inline const char *dm2str (uint32_t dm) +{ +static const char *str[] = { +"Fixed" , +"..." , +"SMI" , +"..." , +"NMI" , +"INIT" , +"..." , +"ExtINT" + }; +return str[dm]; +} + +static void dump_apic_lvt (const char *name,uint32_t lvt,bool is_timer) +{ +uint32_t dm = (lvt &APIC_LVT_DELIV_MOD ) >>APIC_LVT_DELIV_MOD_SHIFT ; +qemu_printf ("%s\t 0x%08x %s %-5s %-6s %-7s %-12s %-6s" , + name, lvt, + lvt &APIC_LVT_INT_POLARITY ?"active-lo" :"active-hi" , + lvt &APIC_LVT_LEVEL_TRIGGER ?"level" :"edge" , + lvt &APIC_LVT_MASKED ?"masked" :"" , + lvt &APIC_LVT_DELIV_STS ?"pending" :"" , + !is_timer ? +"" : lvt &APIC_LVT_TIMER_PERIODIC ? +"periodic" : lvt &APIC_LVT_TIMER_TSCDEADLINE ? +"tsc-deadline" :"one-shot" , +dm2str (dm)); +if (dm !=APIC_DM_NMI ) { +qemu_printf (" (vec %u)\n" , lvt &APIC_VECTOR_MASK ); + }else { +qemu_printf ("\n" ); + } +} + +/* ARRAY_SIZE check is not required because +* destination shorthand has a size of 2 bit. +*/ +static inline const char *shorthand2str (uint32_t shorthand) +{ +const char *str[] = { +"no-shorthand" ,"self" ,"all-self" ,"all" + }; +return str[shorthand]; +} + +static inline uint8_t divider_conf (uint32_t divide_conf) +{ +uint8_t divide_val = ((divide_conf &0x8 ) >>1 ) | (divide_conf &0x3 ); + +return divide_val ==7 ?1 :2 << divide_val; +} + +static inline void mask2str (char *str,uint32_t val,uint8_t size) +{ +while (size--) { + *str++ = (val >> size) &1 ?'1' :'0' ; + } + *str =0 ; +} + +#define MAX_LOGICAL_APIC_ID_MASK_SIZE 16 + +static void dump_apic_icr (APICCommonState *s,CPUX86State *env) +{ +uint32_t icr = s->icr[0 ], icr2 = s->icr[1 ]; +uint8_t dest_shorthand = \ + (icr &APIC_ICR_DEST_SHORT ) >>APIC_ICR_DEST_SHORT_SHIFT ; +bool logical_mod = icr &APIC_ICR_DEST_MOD ; +char apic_id_str[MAX_LOGICAL_APIC_ID_MASK_SIZE +1 ]; +uint32_t dest_field; +bool x2apic; + +qemu_printf ("ICR\t 0x%08x %s %s %s %s\n" , + icr, + logical_mod ?"logical" :"physical" , + icr &APIC_ICR_TRIGGER_MOD ?"level" :"edge" , + icr &APIC_ICR_LEVEL ?"assert" :"de-assert" , +shorthand2str (dest_shorthand)); + +qemu_printf ("ICR2\t 0x%08x" , icr2); +if (dest_shorthand !=0 ) { +qemu_printf ("\n" ); +return ; + } + x2apic = env->features[FEAT_1_ECX ] &CPUID_EXT_X2APIC ; + dest_field = x2apic ? icr2 : icr2 >>APIC_ICR_DEST_SHIFT ; + +if (!logical_mod) { +if (x2apic) { +qemu_printf (" cpu %u (X2APIC ID)\n" , dest_field); + }else { +qemu_printf (" cpu %u (APIC ID)\n" , + dest_field &APIC_LOGDEST_XAPIC_ID ); + } +return ; + } + +if (s->dest_mode ==0xf ) {/* flat mode */ +mask2str (apic_id_str, icr2 >>APIC_ICR_DEST_SHIFT ,8 ); +qemu_printf (" mask %s (APIC ID)\n" , apic_id_str); + }else if (s->dest_mode ==0 ) {/* cluster mode */ +if (x2apic) { +mask2str (apic_id_str, dest_field &APIC_LOGDEST_X2APIC_ID ,16 ); +qemu_printf (" cluster %u mask %s (X2APIC ID)\n" , + dest_field >>APIC_LOGDEST_X2APIC_SHIFT , apic_id_str); + }else { +mask2str (apic_id_str, dest_field &APIC_LOGDEST_XAPIC_ID ,4 ); +qemu_printf (" cluster %u mask %s (APIC ID)\n" , + dest_field >>APIC_LOGDEST_XAPIC_SHIFT , apic_id_str); + } + } +} + +static void dump_apic_interrupt (const char *name,uint32_t *ireg_tab, +uint32_t *tmr_tab) +{ +int i, empty = true; + +qemu_printf ("%s\t " , name); +for (i =0 ; i <256 ; i++) { +if (apic_get_bit (ireg_tab, i)) { +qemu_printf ("%u%s " , i, +apic_get_bit (tmr_tab, i) ?"(level)" :"" ); + empty = false; + } + } +qemu_printf ("%s\n" , empty ?"(none)" :"" ); +} + +void x86_cpu_dump_local_apic_state (CPUState *cs,int flags) +{ +X86CPU *cpu =X86_CPU (cs); +APICCommonState *s =APIC_COMMON (cpu->apic_state); +if (!s) { +qemu_printf ("local apic state not available\n" ); +return ; + } +uint32_t *lvt = s->lvt; + +qemu_printf ("dumping local APIC state for CPU %-2u\n\n" , +CPU (cpu)->cpu_index); +dump_apic_lvt ("LVT0" , lvt[APIC_LVT_LINT0 ], false); +dump_apic_lvt ("LVT1" , lvt[APIC_LVT_LINT1 ], false); +dump_apic_lvt ("LVTPC" , lvt[APIC_LVT_PERFORM ], false); +dump_apic_lvt ("LVTERR" , lvt[APIC_LVT_ERROR ], false); +dump_apic_lvt ("LVTTHMR" , lvt[APIC_LVT_THERMAL ], false); +dump_apic_lvt ("LVTT" , lvt[APIC_LVT_TIMER ], true); + +qemu_printf ("Timer\t DCR=0x%x (divide by %u) initial_count = %u" +" current_count = %u\n" , + s->divide_conf &APIC_DCR_MASK , +divider_conf (s->divide_conf), + s->initial_count,apic_get_current_count (s)); + +qemu_printf ("SPIV\t 0x%08x APIC %s, focus=%s, spurious vec %u\n" , + s->spurious_vec, + s->spurious_vec &APIC_SPURIO_ENABLED ?"enabled" :"disabled" , + s->spurious_vec &APIC_SPURIO_FOCUS ?"on" :"off" , + s->spurious_vec &APIC_VECTOR_MASK ); + +dump_apic_icr (s, &cpu->env); + +qemu_printf ("ESR\t 0x%08x\n" , s->esr); + +dump_apic_interrupt ("ISR" , s->isr, s->tmr); +dump_apic_interrupt ("IRR" , s->irr, s->tmr); + +qemu_printf ("\nAPR 0x%02x TPR 0x%02x DFR 0x%02x LDR 0x%02x" , + s->arb_id, s->tpr, s->dest_mode, s->log_dest); +if (s->dest_mode ==0 ) { +qemu_printf ("(cluster %u: id %u)" , + s->log_dest >>APIC_LOGDEST_XAPIC_SHIFT , + s->log_dest &APIC_LOGDEST_XAPIC_ID ); + } +qemu_printf (" PPR 0x%02x\n" ,apic_get_ppr (s)); +} +#else +void x86_cpu_dump_local_apic_state (CPUState *cs,int flags) +{ +} +#endif /* !CONFIG_USER_ONLY */ + +#define DUMP_CODE_BYTES_TOTAL 50 +#define DUMP_CODE_BYTES_BACKWARD 20 + +void x86_cpu_dump_state (CPUState *cs,FILE *f,int flags) +{ +X86CPU *cpu =X86_CPU (cs); +CPUX86State *env = &cpu->env; +int eflags, i, nb; +char cc_op_name[32 ]; +static const char *seg_name[6 ] = {"ES" ,"CS" ,"SS" ,"DS" ,"FS" ,"GS" }; + + eflags =cpu_compute_eflags (env); +#ifdef TARGET_X86_64 +if (env->hflags &HF_CS64_MASK ) { +qemu_fprintf (f,"RAX=%016" PRIx64" RBX=%016" PRIx64" RCX=%016" PRIx64" RDX=%016" PRIx64"\n" +"RSI=%016" PRIx64" RDI=%016" PRIx64" RBP=%016" PRIx64" RSP=%016" PRIx64"\n" +"R8 =%016" PRIx64" R9 =%016" PRIx64" R10=%016" PRIx64" R11=%016" PRIx64"\n" +"R12=%016" PRIx64" R13=%016" PRIx64" R14=%016" PRIx64" R15=%016" PRIx64"\n" +"RIP=%016" PRIx64" RFL=%08x [%c%c%c%c%c%c%c] CPL=%d II=%d A20=%d SMM=%d HLT=%d\n" , + env->regs[R_EAX ], + env->regs[R_EBX ], + env->regs[R_ECX ], + env->regs[R_EDX ], + env->regs[R_ESI ], + env->regs[R_EDI ], + env->regs[R_EBP ], + env->regs[R_ESP ], + env->regs[8 ], + env->regs[9 ], + env->regs[10 ], + env->regs[11 ], + env->regs[12 ], + env->regs[13 ], + env->regs[14 ], + env->regs[15 ], + env->eip, eflags, + eflags &DF_MASK ?'D' :'-' , + eflags &CC_O ?'O' :'-' , + eflags &CC_S ?'S' :'-' , + eflags &CC_Z ?'Z' :'-' , + eflags &CC_A ?'A' :'-' , + eflags &CC_P ?'P' :'-' , + eflags &CC_C ?'C' :'-' , + env->hflags &HF_CPL_MASK , + (env->hflags >>HF_INHIBIT_IRQ_SHIFT ) &1 , + (env->a20_mask >>20 ) &1 , + (env->hflags >>HF_SMM_SHIFT ) &1 , + cs->halted); + } else +#endif + { +qemu_fprintf (f,"EAX=%08x EBX=%08x ECX=%08x EDX=%08x\n" +"ESI=%08x EDI=%08x EBP=%08x ESP=%08x\n" +"EIP=%08x EFL=%08x [%c%c%c%c%c%c%c] CPL=%d II=%d A20=%d SMM=%d HLT=%d\n" , + (uint32_t )env->regs[R_EAX ], + (uint32_t )env->regs[R_EBX ], + (uint32_t )env->regs[R_ECX ], + (uint32_t )env->regs[R_EDX ], + (uint32_t )env->regs[R_ESI ], + (uint32_t )env->regs[R_EDI ], + (uint32_t )env->regs[R_EBP ], + (uint32_t )env->regs[R_ESP ], + (uint32_t )env->eip, eflags, + eflags &DF_MASK ?'D' :'-' , + eflags &CC_O ?'O' :'-' , + eflags &CC_S ?'S' :'-' , + eflags &CC_Z ?'Z' :'-' , + eflags &CC_A ?'A' :'-' , + eflags &CC_P ?'P' :'-' , + eflags &CC_C ?'C' :'-' , + env->hflags &HF_CPL_MASK , + (env->hflags >>HF_INHIBIT_IRQ_SHIFT ) &1 , + (env->a20_mask >>20 ) &1 , + (env->hflags >>HF_SMM_SHIFT ) &1 , + cs->halted); + } + +for (i =0 ; i <6 ; i++) { +cpu_x86_dump_seg_cache (env, f, seg_name[i], &env->segs[i]); + } +cpu_x86_dump_seg_cache (env, f,"LDT" , &env->ldt); +cpu_x86_dump_seg_cache (env, f,"TR" , &env->tr); + +#ifdef TARGET_X86_64 +if (env->hflags &HF_LMA_MASK ) { +qemu_fprintf (f,"GDT= %016" PRIx64" %08x\n" , + env->gdt.base, env->gdt.limit); +qemu_fprintf (f,"IDT= %016" PRIx64" %08x\n" , + env->idt.base, env->idt.limit); +qemu_fprintf (f,"CR0=%08x CR2=%016" PRIx64" CR3=%016" PRIx64" CR4=%08x\n" , + (uint32_t )env->cr[0 ], + env->cr[2 ], + env->cr[3 ], + (uint32_t )env->cr[4 ]); +for (i =0 ; i <4 ; i++) +qemu_fprintf (f,"DR%d=%016" PRIx64" " , i, env->dr[i]); +qemu_fprintf (f,"\nDR6=%016" PRIx64" DR7=%016" PRIx64"\n" , + env->dr[6 ], env->dr[7 ]); + } else +#endif + { +qemu_fprintf (f,"GDT= %08x %08x\n" , + (uint32_t )env->gdt.base, env->gdt.limit); +qemu_fprintf (f,"IDT= %08x %08x\n" , + (uint32_t )env->idt.base, env->idt.limit); +qemu_fprintf (f,"CR0=%08x CR2=%08x CR3=%08x CR4=%08x\n" , + (uint32_t )env->cr[0 ], + (uint32_t )env->cr[2 ], + (uint32_t )env->cr[3 ], + (uint32_t )env->cr[4 ]); +for (i =0 ; i <4 ; i++) { +qemu_fprintf (f,"DR%d=" TARGET_FMT_lx" " , i, env->dr[i]); + } +qemu_fprintf (f,"\nDR6=" TARGET_FMT_lx" DR7=" TARGET_FMT_lx"\n" , + env->dr[6 ], env->dr[7 ]); + } +if (flags &CPU_DUMP_CCOP ) { +if ((unsigned )env->cc_op <CC_OP_NB ) +snprintf (cc_op_name,sizeof (cc_op_name),"%s" , cc_op_str[env->cc_op]); +else +snprintf (cc_op_name,sizeof (cc_op_name),"[%d]" , env->cc_op); +#ifdef TARGET_X86_64 +if (env->hflags &HF_CS64_MASK ) { +qemu_fprintf (f,"CCS=%016" PRIx64" CCD=%016" PRIx64" CCO=%-8s\n" , + env->cc_src, env->cc_dst, + cc_op_name); + } else +#endif + { +qemu_fprintf (f,"CCS=%08x CCD=%08x CCO=%-8s\n" , + (uint32_t )env->cc_src, (uint32_t )env->cc_dst, + cc_op_name); + } + } +qemu_fprintf (f,"EFER=%016" PRIx64"\n" , env->efer); +if (flags &CPU_DUMP_FPU ) { +int fptag; + fptag =0 ; +for (i =0 ; i <8 ; i++) { + fptag |= ((!env->fptags[i]) << i); + } +update_mxcsr_from_sse_status (env); +qemu_fprintf (f,"FCW=%04x FSW=%04x [ST=%d] FTW=%02x MXCSR=%08x\n" , + env->fpuc, + (env->fpus & ~0x3800 ) | (env->fpstt &0x7 ) <<11 , + env->fpstt, + fptag, + env->mxcsr); +for (i=0 ;i<8 ;i++) { +CPU_LDoubleU u; + u.d = env->fpregs[i].d; +qemu_fprintf (f,"FPR%d=%016" PRIx64" %04x" , + i, u.l.lower, u.l.upper); +if ((i &1 ) ==1 ) +qemu_fprintf (f,"\n" ); +else +qemu_fprintf (f," " ); + } +if (env->hflags &HF_CS64_MASK ) + nb =16 ; +else + nb =8 ; +for (i=0 ;i<nb;i++) { +qemu_fprintf (f,"XMM%02d=%08x%08x%08x%08x" , + i, + env->xmm_regs[i].ZMM_L (3 ), + env->xmm_regs[i].ZMM_L (2 ), + env->xmm_regs[i].ZMM_L (1 ), + env->xmm_regs[i].ZMM_L (0 )); +if ((i &1 ) ==1 ) +qemu_fprintf (f,"\n" ); +else +qemu_fprintf (f," " ); + } + } +if (flags &CPU_DUMP_CODE ) { +target_ulong base = env->segs[R_CS ].base + env->eip; +target_ulong offs =MIN (env->eip,DUMP_CODE_BYTES_BACKWARD ); +uint8_t code; +char codestr[3 ]; + +qemu_fprintf (f,"Code=" ); +for (i =0 ; i <DUMP_CODE_BYTES_TOTAL ; i++) { +if (cpu_memory_rw_debug (cs, base - offs + i, &code,1 ,0 ) ==0 ) { +snprintf (codestr,sizeof (codestr),"%02x" , code); + }else { +snprintf (codestr,sizeof (codestr),"??" ); + } +qemu_fprintf (f,"%s%s%s%s" , i >0 ?" " :"" , + i == offs ?"<" :"" , codestr, i == offs ?">" :"" ); + } +qemu_fprintf (f,"\n" ); + } +}
target/i386/cpu.h +1 -0
@@ -2232,6 +2232,7 @@ void enable_compat_apic_id_mode(void);#define APIC_DEFAULT_ADDRESS 0xfee00000#define APIC_SPACE_SIZE 0x100000 +/* cpu-dump.c */ void x86_cpu_dump_local_apic_state (CPUState *cs,int flags);/* cpu.c */
target/i386/helper.c +0 -514
526 lines not on this page · raw message
target/i386/meson.build +1 -0
@@ -4,6 +4,7 @@ i386_ss.add(files( 'gdbstub.c', 'helper.c', 'xsave_helper.c', + 'cpu-dump.c', )) i386_ss.add(when: 'CONFIG_SEV', if_true: files('sev.c'), if_false: files('sev-stub.c'))
Signature · 1 line
2.26.2
Re: [RFC v9 09/32] i386: move cpu dump out of helper.c into cpu-dump.c
Quoted 1 line · Claudio Fontana
Signed-off-by Claudio Fontana <[email protected]>
Signature · 1 line
Alex Bennée
RFC v9 10/32 i386: move TCG cpu class initialization out of helper.c
In reply to Claudio Fontana--- target/i386/cpu.c | 33 ++++------ target/i386/cpu.h | 97 ++--------------------------- target/i386/helper-tcg.h | 112 ++++++++++++++++++++++++++++++++++ target/i386/helper.c | 23 ------- target/i386/meson.build | 1 + target/i386/tcg-cpu.c | 71 +++++++++++++++++++++ target/i386/tcg-cpu.h | 15 +++++ target/i386/tcg/bpt_helper.c | 1 + target/i386/tcg/cc_helper.c | 1 + target/i386/tcg/excp_helper.c | 1 + target/i386/tcg/fpu_helper.c | 33 +++++----- target/i386/tcg/int_helper.c | 1 + target/i386/tcg/mem_helper.c | 1 + target/i386/tcg/misc_helper.c | 1 + target/i386/tcg/mpx_helper.c | 1 + target/i386/tcg/seg_helper.c | 1 + target/i386/tcg/smm_helper.c | 2 + target/i386/tcg/svm_helper.c | 1 + target/i386/tcg/translate.c | 1 + 19 files changed, 244 insertions(+), 153 deletions(-) create mode 100644 target/i386/helper-tcg.h create mode 100644 target/i386/tcg-cpu.c create mode 100644 target/i386/tcg-cpu.h
target/i386/cpu.c +11 -22
@@ -24,6 +24,8 @@#include "qemu/qemu-print.h" #include "cpu.h" +#include "tcg-cpu.h" +#include "helper-tcg.h" #include "exec/exec-all.h" #include "sysemu/kvm.h" #include "sysemu/reset.h"
@@ -1495,7 +1497,8 @@ static inline uint64_t x86_cpu_xsave_components(X86CPU *cpu) cpu->env.features[FEAT_XSAVE_COMP_LO ]; } -const char *get_register_name_32 (unsigned int reg) +/* Return name of 32-bit register, from a R_* constant */ +static const char *get_register_name_32 (unsigned int reg) {if (reg >=CPU_NB_REGS32 ) {return NULL ;
@@ -7012,13 +7015,6 @@ static void x86_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.eip = value; } -static void x86_cpu_synchronize_from_tb (CPUState *cs,TranslationBlock *tb) -{ -X86CPU *cpu =X86_CPU (cs); - - cpu->env.eip = tb->pc - tb->cs_base; -} -int x86_cpu_pending_interrupt (CPUState *cs,int interrupt_request) {X86CPU *cpu =X86_CPU (cs);
@@ -7252,17 +7248,18 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->class_by_name = x86_cpu_class_by_name; cc->parse_features = x86_cpu_parse_featurestr; cc->has_work = x86_cpu_has_work; +#ifdef CONFIG_TCG - cc->do_interrupt = x86_cpu_do_interrupt; - cc->cpu_exec_interrupt = x86_cpu_exec_interrupt; -#endif +tcg_cpu_common_class_init (cc); +#endif /* CONFIG_TCG */ + cc->dump_state = x86_cpu_dump_state; cc->set_pc = x86_cpu_set_pc; - cc->synchronize_from_tb = x86_cpu_synchronize_from_tb; cc->gdb_read_register = x86_cpu_gdb_read_register; cc->gdb_write_register = x86_cpu_gdb_write_register; cc->get_arch_id = x86_cpu_get_arch_id; cc->get_paging_enabled = x86_cpu_get_paging_enabled; +#ifndef CONFIG_USER_ONLY cc->asidx_from_attrs = x86_asidx_from_attrs; cc->get_memory_mapping = x86_cpu_get_memory_mapping;
@@ -7273,7 +7270,8 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->write_elf32_note = x86_cpu_write_elf32_note; cc->write_elf32_qemunote = x86_cpu_write_elf32_qemunote; cc->vmsd = &vmstate_x86_cpu; -#endif +#endif /* !CONFIG_USER_ONLY */ + cc->gdb_arch_name = x86_gdb_arch_name;#ifdef TARGET_X86_64 cc->gdb_core_xml_file ="i386-64bit.xml" ;
@@ -7281,15 +7279,6 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)#else cc->gdb_core_xml_file ="i386-32bit.xml" ; cc->gdb_num_core_regs =50 ; -#endif -#if defined(CONFIG_TCG ) && !defined(CONFIG_USER_ONLY ) - cc->debug_excp_handler = breakpoint_handler; -#endif - cc->cpu_exec_enter = x86_cpu_exec_enter; - cc->cpu_exec_exit = x86_cpu_exec_exit; -#ifdef CONFIG_TCG - cc->tcg_initialize = tcg_x86_init; - cc->tlb_fill = x86_cpu_tlb_fill;#endif cc->disas_set_info = x86_disas_set_info;
target/i386/cpu.h +6 -91
169 lines not on this page · raw message
target/i386/helper-tcg.h new file +112 -0
112 lines not on this page · raw message
target/i386/helper.c +0 -23
@@ -24,10 +24,8 @@#include "sysemu/runstate.h" #include "kvm/kvm_i386.h" #ifndef CONFIG_USER_ONLY -#include "sysemu/tcg.h" #include "sysemu/hw_accel.h" #include "monitor/monitor.h" -#include "hw/i386/apic_internal.h" #endif void cpu_sync_bndcs_hflags (CPUX86State *env)
@@ -572,27 +570,6 @@ void do_cpu_sipi(X86CPU *cpu) }#endif -/* Frob eflags into and out of the CPU temporary format. */ - -void x86_cpu_exec_enter (CPUState *cs) -{ -X86CPU *cpu =X86_CPU (cs); -CPUX86State *env = &cpu->env; - -CC_SRC = env->eflags & (CC_O |CC_S |CC_Z |CC_A |CC_P |CC_C ); - env->df =1 - (2 * ((env->eflags >>10 ) &1 )); -CC_OP =CC_OP_EFLAGS ; - env->eflags &= ~(DF_MASK |CC_O |CC_S |CC_Z |CC_A |CC_P |CC_C ); -} - -void x86_cpu_exec_exit (CPUState *cs) -{ -X86CPU *cpu =X86_CPU (cs); -CPUX86State *env = &cpu->env; - - env->eflags =cpu_compute_eflags (env); -} -#ifndef CONFIG_USER_ONLY uint8_t x86_ldub_phys (CPUState *cs,hwaddr addr) {
target/i386/meson.build +1 -0
@@ -6,6 +6,7 @@ i386_ss.add(files( 'xsave_helper.c', 'cpu-dump.c', )) +i386_ss.add(when: 'CONFIG_TCG', if_true: files('tcg-cpu.c')) i386_ss.add(when: 'CONFIG_SEV', if_true: files('sev.c'), if_false: files('sev-stub.c')) i386_softmmu_ss = ss.source_set()
target/i386/tcg-cpu.c new file +71 -0
71 lines not on this page · raw message
target/i386/tcg-cpu.h new file +15 -0
@@ -0,0 +1,15 @@ +/* +* i386 TCG CPU class initialization +* +* Copyright 2020 SUSE LLC +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef TCG_CPU_H +#define TCG_CPU_H + +void tcg_cpu_common_class_init (CPUClass *cc); + +#endif /* TCG_CPU_H */
target/i386/tcg/bpt_helper.c +1 -0
@@ -21,6 +21,7 @@#include "cpu.h" #include "exec/exec-all.h" #include "exec/helper-proto.h" +#include "helper-tcg.h" #ifndef CONFIG_USER_ONLY
target/i386/tcg/cc_helper.c +1 -0
@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "cpu.h" #include "exec/helper-proto.h" +#include "helper-tcg.h" const uint8_t parity_table[256 ] = {CC_P ,0 ,0 ,CC_P ,0 ,CC_P ,CC_P ,0 ,
target/i386/tcg/excp_helper.c +1 -0
@@ -23,6 +23,7 @@#include "qemu/log.h" #include "sysemu/runstate.h" #include "exec/helper-proto.h" +#include "helper-tcg.h" void helper_raise_interrupt (CPUX86State *env,int intno,int next_eip_addend) {
target/i386/tcg/fpu_helper.c +16 -17
@@ -26,6 +26,7 @@#include "exec/cpu_ldst.h" #include "fpu/softfloat.h" #include "fpu/softfloat-macros.h" +#include "helper-tcg.h" #ifdef CONFIG_SOFTMMU #include "hw/irq.h"
@@ -2986,23 +2987,21 @@ void update_mxcsr_status(CPUX86State *env)void update_mxcsr_from_sse_status (CPUX86State *env) { -if (tcg_enabled ()) { -uint8_t flags =get_float_exception_flags (&env->sse_status); -/* -* The MXCSR denormal flag has opposite semantics to -* float_flag_input_denormal (the softfloat code sets that flag -* only when flushing input denormals to zero, but SSE sets it -* only when not flushing them to zero), so is not converted -* here. -*/ - env->mxcsr |= ((flags & float_flag_invalid ?FPUS_IE :0 ) | - (flags & float_flag_divbyzero ?FPUS_ZE :0 ) | - (flags & float_flag_overflow ?FPUS_OE :0 ) | - (flags & float_flag_underflow ?FPUS_UE :0 ) | - (flags & float_flag_inexact ?FPUS_PE :0 ) | - (flags & float_flag_output_denormal ?FPUS_UE |FPUS_PE : -0 )); - } +uint8_t flags =get_float_exception_flags (&env->sse_status); +/* +* The MXCSR denormal flag has opposite semantics to +* float_flag_input_denormal (the softfloat code sets that flag +* only when flushing input denormals to zero, but SSE sets it +* only when not flushing them to zero), so is not converted +* here. +*/ + env->mxcsr |= ((flags & float_flag_invalid ?FPUS_IE :0 ) | + (flags & float_flag_divbyzero ?FPUS_ZE :0 ) | + (flags & float_flag_overflow ?FPUS_OE :0 ) | + (flags & float_flag_underflow ?FPUS_UE :0 ) | + (flags & float_flag_inexact ?FPUS_PE :0 ) | + (flags & float_flag_output_denormal ?FPUS_UE |FPUS_PE : +0 )); }void helper_update_mxcsr (CPUX86State *env)
target/i386/tcg/int_helper.c +1 -0
@@ -24,6 +24,7 @@#include "exec/helper-proto.h" #include "qapi/error.h" #include "qemu/guest-random.h" +#include "helper-tcg.h" //#define DEBUG_MULDIV
target/i386/tcg/mem_helper.c +1 -0
@@ -25,6 +25,7 @@#include "qemu/int128.h" #include "qemu/atomic128.h" #include "tcg/tcg.h" +#include "helper-tcg.h" void helper_cmpxchg8b_unlocked (CPUX86State *env,target_ulong a0) {
target/i386/tcg/misc_helper.c +1 -0
@@ -24,6 +24,7 @@#include "exec/exec-all.h" #include "exec/cpu_ldst.h" #include "exec/address-spaces.h" +#include "helper-tcg.h" void helper_outb (CPUX86State *env,uint32_t port,uint32_t data) {
target/i386/tcg/mpx_helper.c +1 -0
@@ -22,6 +22,7 @@#include "exec/helper-proto.h" #include "exec/cpu_ldst.h" #include "exec/exec-all.h" +#include "helper-tcg.h" void helper_bndck (CPUX86State *env,uint32_t fail)
target/i386/tcg/seg_helper.c +1 -0
@@ -25,6 +25,7 @@#include "exec/exec-all.h" #include "exec/cpu_ldst.h" #include "exec/log.h" +#include "helper-tcg.h" //#define DEBUG_PCALL
target/i386/tcg/smm_helper.c +2 -0
@@ -22,6 +22,8 @@#include "cpu.h" #include "exec/helper-proto.h" #include "exec/log.h" +#include "helper-tcg.h" +/* SMM support */
target/i386/tcg/svm_helper.c +1 -0
@@ -22,6 +22,7 @@#include "exec/helper-proto.h" #include "exec/exec-all.h" #include "exec/cpu_ldst.h" +#include "helper-tcg.h" /* Secure Virtual Machine helpers */
target/i386/tcg/translate.c +1 -0
@@ -28,6 +28,7 @@#include "exec/helper-proto.h" #include "exec/helper-gen.h" +#include "helper-tcg.h" #include "trace-tcg.h" #include "exec/log.h"
Signature · 1 line
2.26.2
Re: [RFC v9 10/32] i386: move TCG cpu class initialization out of helper.c
Quoted 64 lines · Claudio Fontana
Signed-off-by Claudio Fontana <[email protected]>--- target/i386/cpu.c | 33 ++++------ target/i386/cpu.h | 97 ++--------------------------- target/i386/helper-tcg.h | 112 ++++++++++++++++++++++++++++++++++ target/i386/helper.c | 23 ------- target/i386/meson.build | 1 + target/i386/tcg-cpu.c | 71 +++++++++++++++++++++ target/i386/tcg-cpu.h | 15 +++++ target/i386/tcg/bpt_helper.c | 1 + target/i386/tcg/cc_helper.c | 1 + target/i386/tcg/excp_helper.c | 1 + target/i386/tcg/fpu_helper.c | 33 +++++----- target/i386/tcg/int_helper.c | 1 + target/i386/tcg/mem_helper.c | 1 + target/i386/tcg/misc_helper.c | 1 + target/i386/tcg/mpx_helper.c | 1 + target/i386/tcg/seg_helper.c | 1 + target/i386/tcg/smm_helper.c | 2 + target/i386/tcg/svm_helper.c | 1 + target/i386/tcg/translate.c | 1 + 19 files changed, 244 insertions(+), 153 deletions(-) create mode 100644 target/i386/helper-tcg.h create mode 100644 target/i386/tcg-cpu.c create mode 100644 target/i386/tcg-cpu.htarget/i386/cpu.c +4
-8@@ -24,6 +24,8 @@#include "qemu/qemu-print.h" #include "cpu.h" +#include "tcg-cpu.h" +#include "helper-tcg.h" #include "exec/exec-all.h" #include "sysemu/kvm.h" #include "sysemu/reset.h" @@ -1495,7 +1497,8 @@ static inline uint64_t x86_cpu_xsave_components(X86CPU *cpu) cpu->env.features[FEAT_XSAVE_COMP_LO ]; } -const char *get_register_name_32 (unsigned int reg) +/* Return name of 32-bit register, from a R_* constant */ +static const char *get_register_name_32 (unsigned int reg) {if (reg >=CPU_NB_REGS32 ) {return NULL ;@@ -7012,13 +7015,6 @@ static void x86_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.eip = value; } -static void x86_cpu_synchronize_from_tb (CPUState *cs,TranslationBlock *tb) -{ -X86CPU *cpu =X86_CPU (cs); - - cpu->env.eip = tb->pc - tb->cs_base; -} -int x86_cpu_pending_interrupt (CPUState *cs,int interrupt_request) {X86CPU *cpu =X86_CPU (cs);
target/i386/cpu.c static void x86_cpu_common_class_init(ObjectClass *oc, void *data) · line 7253
Quoted 9 lines
target/i386/cpu.c +2
-3@@ -7252,17 +7248,18 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->class_by_name = x86_cpu_class_by_name; cc->parse_features = x86_cpu_parse_featurestr; cc->has_work = x86_cpu_has_work; +#ifdef CONFIG_TCG - cc->do_interrupt = x86_cpu_do_interrupt; - cc->cpu_exec_interrupt = x86_cpu_exec_interrupt; -#endif +tcg_cpu_common_class_init (cc);
Are we likely to have clashing names here as other arches get converted? tcg_x86_cpu_common_class_init or x86_cpu_common_class_init?
<snip>
Quoted 6 lines
target/i386/tcg-cpu.c new file +0
-0@@ -0,0 +1,71 @@
<snip>
Quoted 4 lines
target/i386/tcg-cpu.c new file +4
-0+ +void tcg_cpu_common_class_init (CPUClass *cc) +{ + cc->do_interrupt = x86_cpu_do_interrupt;
target/i386/tcg-cpu.c line 71
Quoted 10 lines
target/i386/tcg-cpu.c new file +10
-0+ cc->cpu_exec_interrupt = x86_cpu_exec_interrupt; + cc->synchronize_from_tb = x86_cpu_synchronize_from_tb; + cc->cpu_exec_enter = x86_cpu_exec_enter; + cc->cpu_exec_exit = x86_cpu_exec_exit; + cc->tcg_initialize = tcg_x86_init; + cc->tlb_fill = x86_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY + cc->debug_excp_handler = breakpoint_handler; +#endif +}
Oh I see this moves down to target/i386/tcg/ eventually. Maybe we should just create the new file in place so it's easier to follow the changes as we convert to a proper abstracted class?
Signature · 1 line
Alex Bennée
Re: [RFC v9 10/32] i386: move TCG cpu class initialization out of helper.c
Quoted 71 lines · Alex Bennée
Quoted 68 lines · Claudio Fontana
Signed-off-by Claudio Fontana <[email protected]>--- target/i386/cpu.c | 33 ++++------ target/i386/cpu.h | 97 ++--------------------------- target/i386/helper-tcg.h | 112 ++++++++++++++++++++++++++++++++++ target/i386/helper.c | 23 ------- target/i386/meson.build | 1 + target/i386/tcg-cpu.c | 71 +++++++++++++++++++++ target/i386/tcg-cpu.h | 15 +++++ target/i386/tcg/bpt_helper.c | 1 + target/i386/tcg/cc_helper.c | 1 + target/i386/tcg/excp_helper.c | 1 + target/i386/tcg/fpu_helper.c | 33 +++++----- target/i386/tcg/int_helper.c | 1 + target/i386/tcg/mem_helper.c | 1 + target/i386/tcg/misc_helper.c | 1 + target/i386/tcg/mpx_helper.c | 1 + target/i386/tcg/seg_helper.c | 1 + target/i386/tcg/smm_helper.c | 2 + target/i386/tcg/svm_helper.c | 1 + target/i386/tcg/translate.c | 1 + 19 files changed, 244 insertions(+), 153 deletions(-) create mode 100644 target/i386/helper-tcg.h create mode 100644 target/i386/tcg-cpu.c create mode 100644 target/i386/tcg-cpu.htarget/i386/cpu.c +5
-8@@ -24,6 +24,8 @@#include "qemu/qemu-print.h" #include "cpu.h" +#include "tcg-cpu.h" +#include "helper-tcg.h" #include "exec/exec-all.h" #include "sysemu/kvm.h" #include "sysemu/reset.h" @@ -1495,7 +1497,8 @@ static inline uint64_t x86_cpu_xsave_components(X86CPU *cpu) cpu->env.features[FEAT_XSAVE_COMP_LO ]; } -const char *get_register_name_32 (unsigned int reg) +/* Return name of 32-bit register, from a R_* constant */ +static const char *get_register_name_32 (unsigned int reg) {if (reg >=CPU_NB_REGS32 ) {return NULL ;@@ -7012,13 +7015,6 @@ static void x86_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.eip = value; } -static void x86_cpu_synchronize_from_tb (CPUState *cs,TranslationBlock *tb) -{ -X86CPU *cpu =X86_CPU (cs); - - cpu->env.eip = tb->pc - tb->cs_base; -} -int x86_cpu_pending_interrupt (CPUState *cs,int interrupt_request) {X86CPU *cpu =X86_CPU (cs);@@ -7252,17 +7248,18 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->class_by_name = x86_cpu_class_by_name; cc->parse_features = x86_cpu_parse_featurestr; cc->has_work = x86_cpu_has_work; +
Quoted 8 lines
target/i386/cpu.c static void x86_cpu_common_class_init(ObjectClass *oc, void *data) · line 7253
Quoted 5 lines
target/i386/cpu.c +1
-3#ifdef CONFIG_TCG - cc->do_interrupt = x86_cpu_do_interrupt; - cc->cpu_exec_interrupt = x86_cpu_exec_interrupt; -#endif +tcg_cpu_common_class_init (cc);Are we likely to have clashing names here as other arches get converted?
tcg_x86_cpu_common_class_initorx86_cpu_common_class_init?
well, not in the same binary I presume? But I can add an x86 in front.
Quoted 19 lines
<snip>
Quoted 6 lines
target/i386/tcg-cpu.c new file +0
-0@@ -0,0 +1,71 @@<snip>
Quoted 10 lines
target/i386/tcg-cpu.c new file +10
-0+ +void tcg_cpu_common_class_init (CPUClass *cc) +{ + cc->do_interrupt = x86_cpu_do_interrupt; + cc->cpu_exec_interrupt = x86_cpu_exec_interrupt; + cc->synchronize_from_tb = x86_cpu_synchronize_from_tb; + cc->cpu_exec_enter = x86_cpu_exec_enter; + cc->cpu_exec_exit = x86_cpu_exec_exit; + cc->tcg_initialize = tcg_x86_init; + cc->tlb_fill = x86_cpu_tlb_fill;
Quoted 9 lines
target/i386/tcg-cpu.c line 71
Quoted 4 lines
target/i386/tcg-cpu.c new file +4
-0+#ifndef CONFIG_USER_ONLY + cc->debug_excp_handler = breakpoint_handler; +#endif +}Oh I see this moves down to target/i386/tcg/ eventually. Maybe we should just create the new file in place so it's easier to follow the changes as we convert to a proper abstracted class?
Yes, will do.
Thanks,
C
RFC v9 11/32 tcg: cpu_exec_{enter,exit} helpers
In reply to Claudio FontanaFrom: Eduardo Habkost <[email protected]>
Move invocation of CPUClass.cpu_exec_*() to separate helpers, to make it easier to refactor that code later.
--- accel/tcg/cpu-exec.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
accel/tcg/cpu-exec.c +18 -5
@@ -236,9 +236,22 @@ static void cpu_exec_nocache(CPUState *cpu, int max_cycles, }#endif +static void cpu_exec_enter (CPUState *cpu) +{ +CPUClass *cc =CPU_GET_CLASS (cpu); + + cc->cpu_exec_enter (cpu); +} + +static void cpu_exec_exit (CPUState *cpu) +{ +CPUClass *cc =CPU_GET_CLASS (cpu); + + cc->cpu_exec_exit (cpu); +} +void cpu_exec_step_atomic (CPUState *cpu) { -CPUClass *cc =CPU_GET_CLASS (cpu);TranslationBlock *tb;target_ulong cs_base, pc;uint32_t flags;
@@ -257,11 +270,11 @@ void cpu_exec_step_atomic(CPUState *cpu)/* Since we got here, we know that parallel_cpus must be true. */ parallel_cpus = false; - cc->cpu_exec_enter (cpu); +cpu_exec_enter (cpu);/* execute the generated code */ trace_exec_tb (tb, pc);cpu_tb_exec (cpu, tb); - cc->cpu_exec_exit (cpu); +cpu_exec_exit (cpu); }else {/* * The mmap_lock is dropped by tb_gen_code if it runs out of
@@ -713,7 +726,7 @@ int cpu_exec(CPUState *cpu)rcu_read_lock (); - cc->cpu_exec_enter (cpu); +cpu_exec_enter (cpu);/* Calculate difference between guest clock and host clock. * This delay includes the delay of the last cycle, so
@@ -775,7 +788,7 @@ int cpu_exec(CPUState *cpu) } } - cc->cpu_exec_exit (cpu); +cpu_exec_exit (cpu);rcu_read_unlock ();return ret;
Signature · 1 line
2.26.2
Re: [RFC v9 11/32] tcg: cpu_exec_{enter,exit} helpers
Quoted 7 lines · Claudio Fontana
From: Eduardo Habkost <[email protected]>
Move invocation of CPUClass.cpu_exec_*() to separate helpers, to make it easier to refactor that code later.
Signed-off-by Eduardo Habkost <[email protected]>Signed-off-by Claudio Fontana <[email protected]>
Signature · 1 line
Alex Bennée
RFC v9 12/32 tcg: make CPUClass.cpu_exec_* optional
In reply to Claudio FontanaFrom: Eduardo Habkost <[email protected]>
This will let us simplify the code that initializes CPU class methods, when we move cpu_exec_*() to a separate struct.
--- accel/tcg/cpu-exec.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
accel/tcg/cpu-exec.c +8 -3
@@ -240,14 +240,18 @@ static void cpu_exec_enter(CPUState *cpu) {CPUClass *cc =CPU_GET_CLASS (cpu); - cc->cpu_exec_enter (cpu); +if (cc->cpu_exec_enter) { + cc->cpu_exec_enter (cpu); + } }static void cpu_exec_exit (CPUState *cpu) {CPUClass *cc =CPU_GET_CLASS (cpu); - cc->cpu_exec_exit (cpu); +if (cc->cpu_exec_exit) { + cc->cpu_exec_exit (cpu); + } }void cpu_exec_step_atomic (CPUState *cpu)
@@ -619,7 +623,8 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,True when it is, and we should restart on a new TB, and via longjmp via cpu_loop_exit. */ else { -if (cc->cpu_exec_interrupt (cpu, interrupt_request)) { +if (cc->cpu_exec_interrupt && + cc->cpu_exec_interrupt (cpu, interrupt_request)) {if (need_replay_interrupt (interrupt_request)) {replay_interrupt (); }
Signature · 1 line
2.26.2
Re: [RFC v9 12/32] tcg: make CPUClass.cpu_exec_* optional
Quoted 6 lines · Claudio Fontana
From: Eduardo Habkost <[email protected]>
This will let us simplify the code that initializes CPU class methods, when we move cpu_exec_*() to a separate struct.
Signed-off-by Eduardo Habkost <[email protected]>Signed-off-by Claudio Fontana <[email protected]>
Signature · 1 line
Alex Bennée
RFC v9 13/32 tcg: Make CPUClass.debug_excp_handler optional
In reply to Claudio FontanaFrom: Eduardo Habkost <[email protected]>
--- accel/tcg/cpu-exec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
accel/tcg/cpu-exec.c +3 -1
@@ -482,7 +482,9 @@ static inline void cpu_handle_debug_exception(CPUState *cpu) } } - cc->debug_excp_handler (cpu); +if (cc->debug_excp_handler) { + cc->debug_excp_handler (cpu); + } }static inline bool cpu_handle_exception (CPUState *cpu,int *ret)
Signature · 1 line
2.26.2
Re: [RFC v9 13/32] tcg: Make CPUClass.debug_excp_handler optional
Quoted 4 lines · Claudio Fontana
From: Eduardo Habkost <[email protected]>
Signed-off-by Eduardo Habkost <[email protected]>Signed-off-by Claudio Fontana <[email protected]>
Signature · 1 line
Alex Bennée
RFC v9 14/32 cpu: Remove unnecessary noop methods
In reply to Claudio FontanaFrom: Eduardo Habkost <[email protected]>
--- hw/core/cpu.c | 13 ------------- 1 file changed, 13 deletions(-)
hw/core/cpu.c +0 -13
@@ -199,15 +199,6 @@ static bool cpu_common_virtio_is_big_endian(CPUState *cpu)return target_words_bigendian (); } -static void cpu_common_noop (CPUState *cpu) -{ -} - -static bool cpu_common_exec_interrupt (CPUState *cpu,int int_req) -{ -return false; -} -#if !defined(CONFIG_USER_ONLY )GuestPanicInformation *cpu_get_crash_info (CPUState *cpu) {
@@ -410,11 +401,7 @@ static void cpu_class_init(ObjectClass *klass, void *data) k->gdb_read_register = cpu_common_gdb_read_register; k->gdb_write_register = cpu_common_gdb_write_register; k->virtio_is_big_endian = cpu_common_virtio_is_big_endian; - k->debug_excp_handler = cpu_common_noop; k->debug_check_watchpoint = cpu_common_debug_check_watchpoint; - k->cpu_exec_enter = cpu_common_noop; - k->cpu_exec_exit = cpu_common_noop; - k->cpu_exec_interrupt = cpu_common_exec_interrupt; k->adjust_watchpoint_address = cpu_adjust_watchpoint_address;set_bit (DEVICE_CATEGORY_CPU , dc->categories); dc->realize = cpu_common_realizefn;
Signature · 1 line
2.26.2
Re: [RFC v9 14/32] cpu: Remove unnecessary noop methods
Quoted 4 lines · Claudio Fontana
From: Eduardo Habkost <[email protected]>
Signed-off-by Eduardo Habkost <[email protected]>Signed-off-by Claudio Fontana <[email protected]>
Signature · 1 line
Alex Bennée
RFC v9 15/32 cpu: Introduce TCGCpuOperations struct
In reply to Claudio FontanaFrom: Eduardo Habkost <[email protected]>
The TCG-specific CPU methods will be moved to a separate struct, to make it easier to move accel-specific code outside generic CPU code in the future. Start by moving tcg_initialize().
The new CPUClass.tcg_opts field may eventually become a pointer, but keep it an embedded struct for now, to make code conversion easier.
[claudio: make the tcg code build for CONFIG_TCG only]
--- MAINTAINERS | 1 + cpu.c | 6 +++++- include/hw/core/cpu.h | 9 ++++++++- include/hw/core/tcg-cpu-ops.h | 25 +++++++++++++++++++++++++ target/alpha/cpu.c | 2 +- target/arm/cpu.c | 2 +- target/avr/cpu.c | 2 +- target/cris/cpu.c | 12 ++++++------ target/hppa/cpu.c | 2 +- target/i386/tcg-cpu.c | 2 +- target/lm32/cpu.c | 2 +- target/m68k/cpu.c | 2 +- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 2 +- target/moxie/cpu.c | 2 +- target/nios2/cpu.c | 2 +- target/openrisc/cpu.c | 2 +- target/ppc/translate_init.c.inc | 2 +- target/riscv/cpu.c | 2 +- target/rx/cpu.c | 2 +- target/s390x/cpu.c | 2 +- target/sh4/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/tilegx/cpu.c | 2 +- target/tricore/cpu.c | 2 +- target/unicore32/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- 27 files changed, 67 insertions(+), 30 deletions(-) create mode 100644 include/hw/core/tcg-cpu-ops.h
MAINTAINERS +1 -0
@@ -1535,6 +1535,7 @@ F: qapi/machine.json F: qapi/machine-target.json F: include/hw/boards.h F: include/hw/core/cpu.h +F: include/hw/core/tcg-cpu-ops.h F: include/hw/cpu/cluster.h F: include/sysemu/numa.h T: git https://github.com/ehabkost/qemu.git machine-next
cpu.c +5 -1
@@ -174,14 +174,18 @@ void cpu_exec_initfn(CPUState *cpu)void cpu_exec_realizefn (CPUState *cpu,Error **errp) {CPUClass *cc =CPU_GET_CLASS (cpu); +#ifdef CONFIG_TCG static bool tcg_target_initialized; +#endif /* CONFIG_TCG */ cpu_list_add (cpu); +#ifdef CONFIG_TCG if (tcg_enabled () && !tcg_target_initialized) { tcg_target_initialized = true; - cc->tcg_initialize (); + cc->tcg_ops.initialize (); } +#endif /* CONFIG_TCG */ tlb_init (cpu);qemu_plugin_vcpu_init_hook (cpu);
include/hw/core/cpu.h +8 -1
@@ -76,6 +76,10 @@ typedef struct CPUWatchpoint CPUWatchpoint;struct TranslationBlock ; +#ifdef CONFIG_TCG +#include "tcg-cpu-ops.h" +#endif /* CONFIG_TCG */ +/** * CPUClass: * @class_by_name: Callback to map -cpu command line model name to an
@@ -221,12 +225,15 @@ struct CPUClass {void (*disas_set_info)(CPUState *cpu,disassemble_info *info);vaddr (*adjust_watchpoint_address)(CPUState *cpu,vaddr addr,int len); -void (*tcg_initialize)(void );const char *deprecation_note;/* Keep non-pointer data at the end to minimize holes. */ int gdb_num_core_regs;bool gdb_stop_before_watchpoint; + +#ifdef CONFIG_TCG +TcgCpuOperations tcg_ops; +#endif /* CONFIG_TCG */ };/*
include/hw/core/tcg-cpu-ops.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* TCG-Specific operations that are not meaningful for hardware accelerators +* +* Copyright 2020 SUSE LLC +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef TCG_CPU_OPS_H +#define TCG_CPU_OPS_H + +/** +* struct TcgCpuOperations: TCG operations specific to a CPU class +*/ +typedef struct TcgCpuOperations { +/** +* @initialize: Initalize TCG state +* +* Called when the first CPU is realized. +*/ +void (*initialize)(void ); +}TcgCpuOperations ; + +#endif /* TCG_CPU_OPS_H */
target/alpha/cpu.c +1 -1
@@ -231,7 +231,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) dc->vmsd = &vmstate_alpha_cpu;#endif cc->disas_set_info = alpha_cpu_disas_set_info; - cc->tcg_initialize = alpha_translate_init; + cc->tcg_ops.initialize = alpha_translate_init; cc->gdb_num_core_regs =67 ; }
target/arm/cpu.c +1 -1
@@ -2261,7 +2261,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_stop_before_watchpoint = true; cc->disas_set_info = arm_disas_set_info;#ifdef CONFIG_TCG - cc->tcg_initialize = arm_translate_init; + cc->tcg_ops.initialize = arm_translate_init; cc->tlb_fill = arm_cpu_tlb_fill; cc->debug_excp_handler = arm_debug_excp_handler; cc->debug_check_watchpoint = arm_debug_check_watchpoint;
target/avr/cpu.c +1 -1
@@ -206,7 +206,7 @@ static void avr_cpu_class_init(ObjectClass *oc, void *data) cc->tlb_fill = avr_cpu_tlb_fill; cc->vmsd = &vms_avr_cpu; cc->disas_set_info = avr_cpu_disas_set_info; - cc->tcg_initialize = avr_cpu_tcg_init; + cc->tcg_ops.initialize = avr_cpu_tcg_init; cc->synchronize_from_tb = avr_cpu_synchronize_from_tb; cc->gdb_read_register = avr_cpu_gdb_read_register; cc->gdb_write_register = avr_cpu_gdb_write_register;
target/cris/cpu.c +6 -6
@@ -201,7 +201,7 @@ static void crisv8_cpu_class_init(ObjectClass *oc, void *data) ccc->vr =8 ; cc->do_interrupt = crisv10_cpu_do_interrupt; cc->gdb_read_register = crisv10_cpu_gdb_read_register; - cc->tcg_initialize = cris_initialize_crisv10_tcg; + cc->tcg_ops.initialize = cris_initialize_crisv10_tcg; }static void crisv9_cpu_class_init (ObjectClass *oc,void *data)
@@ -212,7 +212,7 @@ static void crisv9_cpu_class_init(ObjectClass *oc, void *data) ccc->vr =9 ; cc->do_interrupt = crisv10_cpu_do_interrupt; cc->gdb_read_register = crisv10_cpu_gdb_read_register; - cc->tcg_initialize = cris_initialize_crisv10_tcg; + cc->tcg_ops.initialize = cris_initialize_crisv10_tcg; }static void crisv10_cpu_class_init (ObjectClass *oc,void *data)
@@ -223,7 +223,7 @@ static void crisv10_cpu_class_init(ObjectClass *oc, void *data) ccc->vr =10 ; cc->do_interrupt = crisv10_cpu_do_interrupt; cc->gdb_read_register = crisv10_cpu_gdb_read_register; - cc->tcg_initialize = cris_initialize_crisv10_tcg; + cc->tcg_ops.initialize = cris_initialize_crisv10_tcg; }static void crisv11_cpu_class_init (ObjectClass *oc,void *data)
@@ -234,7 +234,7 @@ static void crisv11_cpu_class_init(ObjectClass *oc, void *data) ccc->vr =11 ; cc->do_interrupt = crisv10_cpu_do_interrupt; cc->gdb_read_register = crisv10_cpu_gdb_read_register; - cc->tcg_initialize = cris_initialize_crisv10_tcg; + cc->tcg_ops.initialize = cris_initialize_crisv10_tcg; }static void crisv17_cpu_class_init (ObjectClass *oc,void *data)
@@ -245,7 +245,7 @@ static void crisv17_cpu_class_init(ObjectClass *oc, void *data) ccc->vr =17 ; cc->do_interrupt = crisv10_cpu_do_interrupt; cc->gdb_read_register = crisv10_cpu_gdb_read_register; - cc->tcg_initialize = cris_initialize_crisv10_tcg; + cc->tcg_ops.initialize = cris_initialize_crisv10_tcg; }static void crisv32_cpu_class_init (ObjectClass *oc,void *data)
@@ -284,7 +284,7 @@ static void cris_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_stop_before_watchpoint = true; cc->disas_set_info = cris_disas_set_info; - cc->tcg_initialize = cris_initialize_tcg; + cc->tcg_ops.initialize = cris_initialize_tcg; }#define DEFINE_CRIS_CPU_TYPE (cpu_model, initfn) \
target/hppa/cpu.c +1 -1
@@ -153,7 +153,7 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *data)#endif cc->do_unaligned_access = hppa_cpu_do_unaligned_access; cc->disas_set_info = hppa_cpu_disas_set_info; - cc->tcg_initialize = hppa_translate_init; + cc->tcg_ops.initialize = hppa_translate_init; cc->gdb_num_core_regs =128 ; }
target/i386/tcg-cpu.c +1 -1
@@ -63,7 +63,7 @@ void tcg_cpu_common_class_init(CPUClass *cc) cc->synchronize_from_tb = x86_cpu_synchronize_from_tb; cc->cpu_exec_enter = x86_cpu_exec_enter; cc->cpu_exec_exit = x86_cpu_exec_exit; - cc->tcg_initialize = tcg_x86_init; + cc->tcg_ops.initialize = tcg_x86_init; cc->tlb_fill = x86_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY cc->debug_excp_handler = breakpoint_handler;
target/lm32/cpu.c +1 -1
@@ -237,7 +237,7 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_stop_before_watchpoint = true; cc->debug_excp_handler = lm32_debug_excp_handler; cc->disas_set_info = lm32_cpu_disas_set_info; - cc->tcg_initialize = lm32_translate_init; + cc->tcg_ops.initialize = lm32_translate_init; }#define DEFINE_LM32_CPU_TYPE (cpu_model, initfn) \
target/m68k/cpu.c +1 -1
@@ -289,7 +289,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) cc->get_phys_page_debug = m68k_cpu_get_phys_page_debug;#endif cc->disas_set_info = m68k_cpu_disas_set_info; - cc->tcg_initialize = m68k_tcg_init; + cc->tcg_ops.initialize = m68k_tcg_init; cc->gdb_num_core_regs =18 ;
target/microblaze/cpu.c +1 -1
@@ -335,7 +335,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_num_core_regs =32 +27 ; cc->disas_set_info = mb_disas_set_info; - cc->tcg_initialize = mb_tcg_init; + cc->tcg_ops.initialize = mb_tcg_init; }static const TypeInfo mb_cpu_type_info = {
target/mips/cpu.c +1 -1
@@ -249,7 +249,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data)#endif cc->disas_set_info = mips_cpu_disas_set_info;#ifdef CONFIG_TCG - cc->tcg_initialize = mips_tcg_init; + cc->tcg_ops.initialize = mips_tcg_init; cc->tlb_fill = mips_cpu_tlb_fill;#endif
target/moxie/cpu.c +1 -1
@@ -116,7 +116,7 @@ static void moxie_cpu_class_init(ObjectClass *oc, void *data) cc->vmsd = &vmstate_moxie_cpu;#endif cc->disas_set_info = moxie_cpu_disas_set_info; - cc->tcg_initialize = moxie_translate_init; + cc->tcg_ops.initialize = moxie_translate_init; }static void moxielite_initfn (Object *obj)
target/nios2/cpu.c +1 -1
@@ -205,7 +205,7 @@ static void nios2_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_read_register = nios2_cpu_gdb_read_register; cc->gdb_write_register = nios2_cpu_gdb_write_register; cc->gdb_num_core_regs =49 ; - cc->tcg_initialize = nios2_tcg_init; + cc->tcg_ops.initialize = nios2_tcg_init; }static const TypeInfo nios2_cpu_type_info = {
target/openrisc/cpu.c +1 -1
@@ -166,7 +166,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data) dc->vmsd = &vmstate_openrisc_cpu;#endif cc->gdb_num_core_regs =32 +3 ; - cc->tcg_initialize = openrisc_translate_init; + cc->tcg_ops.initialize = openrisc_translate_init; cc->disas_set_info = openrisc_disas_set_info; }
target/ppc/translate_init.c.inc +1 -1
@@ -10945,7 +10945,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->virtio_is_big_endian = ppc_cpu_is_big_endian; #endif #ifdef CONFIG_TCG - cc->tcg_initialize = ppc_translate_init; + cc->tcg_ops.initialize = ppc_translate_init; cc->tlb_fill = ppc_cpu_tlb_fill; #endif #ifndef CONFIG_USER_ONLY
target/riscv/cpu.c +1 -1
@@ -562,7 +562,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data) cc->vmsd = &vmstate_riscv_cpu;#endif #ifdef CONFIG_TCG - cc->tcg_initialize = riscv_translate_init; + cc->tcg_ops.initialize = riscv_translate_init; cc->tlb_fill = riscv_cpu_tlb_fill;#endif device_class_set_props (dc, riscv_cpu_properties);
target/rx/cpu.c +1 -1
@@ -194,7 +194,7 @@ static void rx_cpu_class_init(ObjectClass *klass, void *data) cc->gdb_write_register = rx_cpu_gdb_write_register; cc->get_phys_page_debug = rx_cpu_get_phys_page_debug; cc->disas_set_info = rx_cpu_disas_set_info; - cc->tcg_initialize = rx_translate_init; + cc->tcg_ops.initialize = rx_translate_init; cc->tlb_fill = rx_cpu_tlb_fill; cc->gdb_num_core_regs =26 ;
target/s390x/cpu.c +1 -1
@@ -512,7 +512,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data)#endif cc->disas_set_info = s390_cpu_disas_set_info;#ifdef CONFIG_TCG - cc->tcg_initialize = s390x_translate_init; + cc->tcg_ops.initialize = s390x_translate_init; cc->tlb_fill = s390_cpu_tlb_fill;#endif
target/sh4/cpu.c +1 -1
@@ -231,7 +231,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) cc->get_phys_page_debug = superh_cpu_get_phys_page_debug;#endif cc->disas_set_info = superh_cpu_disas_set_info; - cc->tcg_initialize = sh4_translate_init; + cc->tcg_ops.initialize = sh4_translate_init; cc->gdb_num_core_regs =59 ;
target/sparc/cpu.c +1 -1
@@ -879,7 +879,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data) cc->vmsd = &vmstate_sparc_cpu;#endif cc->disas_set_info = cpu_sparc_disas_set_info; - cc->tcg_initialize = sparc_tcg_init; + cc->tcg_ops.initialize = sparc_tcg_init;#if defined(TARGET_SPARC64 ) && !defined(TARGET_ABI32 ) cc->gdb_num_core_regs =86 ;
target/tilegx/cpu.c +1 -1
@@ -153,7 +153,7 @@ static void tilegx_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = tilegx_cpu_set_pc; cc->tlb_fill = tilegx_cpu_tlb_fill; cc->gdb_num_core_regs =0 ; - cc->tcg_initialize = tilegx_tcg_init; + cc->tcg_ops.initialize = tilegx_tcg_init; }static const TypeInfo tilegx_cpu_type_info = {
target/tricore/cpu.c +1 -1
@@ -164,7 +164,7 @@ static void tricore_cpu_class_init(ObjectClass *c, void *data) cc->set_pc = tricore_cpu_set_pc; cc->synchronize_from_tb = tricore_cpu_synchronize_from_tb; cc->get_phys_page_debug = tricore_cpu_get_phys_page_debug; - cc->tcg_initialize = tricore_tcg_init; + cc->tcg_ops.initialize = tricore_tcg_init; cc->tlb_fill = tricore_cpu_tlb_fill; }
target/unicore32/cpu.c +1 -1
@@ -137,7 +137,7 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = uc32_cpu_set_pc; cc->tlb_fill = uc32_cpu_tlb_fill; cc->get_phys_page_debug = uc32_cpu_get_phys_page_debug; - cc->tcg_initialize = uc32_translate_init; + cc->tcg_ops.initialize = uc32_translate_init; dc->vmsd = &vmstate_uc32_cpu; }
target/xtensa/cpu.c +1 -1
@@ -209,7 +209,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data)#endif cc->debug_excp_handler = xtensa_breakpoint_handler; cc->disas_set_info = xtensa_cpu_disas_set_info; - cc->tcg_initialize = xtensa_translate_init; + cc->tcg_ops.initialize = xtensa_translate_init; dc->vmsd = &vmstate_xtensa_cpu; }
Signature · 1 line
2.26.2
Re: [RFC v9 15/32] cpu: Introduce TCGCpuOperations struct
Quoted 10 lines · Claudio Fontana
From: Eduardo Habkost <[email protected]>
The TCG-specific CPU methods will be moved to a separate struct, to make it easier to move accel-specific code outside generic CPU code in the future. Start by moving
tcg_initialize().The new CPUClass.tcg_opts field may eventually become a pointer, but keep it an embedded struct for now, to make code conversion easier.
Quoted 6 lines
Signed-off-by Eduardo Habkost <[email protected]>[claudio: make the tcg code build for
CONFIG_TCGonly]Signed-off-by Claudio Fontana <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Signature · 1 line
Alex Bennée
RFC v9 16/32 target/riscv: remove CONFIG_TCG, as it is always TCG
In reply to Claudio Fontanafor now only TCG is allowed as an accelerator for riscv, so remove the CONFIG_TCG use.
--- target/riscv/cpu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
target/riscv/cpu.c +1 -2
@@ -561,10 +561,9 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data)/* For now, mark unmigratable: */ cc->vmsd = &vmstate_riscv_cpu;#endif -#ifdef CONFIG_TCG cc->tcg_ops.initialize = riscv_translate_init; cc->tlb_fill = riscv_cpu_tlb_fill; -#endif +device_class_set_props (dc, riscv_cpu_properties); }
Signature · 1 line
2.26.2
Re: [RFC v9 16/32] target/riscv: remove CONFIG_TCG, as it is always TCG
Quoted 5 lines · Claudio Fontana
for now only TCG is allowed as an accelerator for riscv, so remove the
CONFIG_TCGuse.Signed-off-by Claudio Fontana <[email protected]>
Alistair
Quoted 24 lines
--- target/riscv/cpu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)target/riscv/cpu.c +1
-3@@ -561,10 +561,9 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data)/* For now, mark unmigratable: */ cc->vmsd = &vmstate_riscv_cpu;#endif -#ifdef CONFIG_TCG cc->tcg_ops.initialize = riscv_translate_init; cc->tlb_fill = riscv_cpu_tlb_fill; -#endif +device_class_set_props (dc, riscv_cpu_properties); } --2.26.2
RFC v9 17/32 accel/tcg: split TCG-only code from cpu_exec_realizefn
In reply to Claudio Fontanamove away TCG-only code, make it compile only on TCG.
--- accel/tcg/cpu-exec.c | 28 +++++++++++++++++ cpu.c | 70 ++++++++++++++++++++----------------------- hw/core/cpu.c | 6 +++- include/hw/core/cpu.h | 8 +++++ 4 files changed, 74 insertions(+), 38 deletions(-)
accel/tcg/cpu-exec.c +28 -0
@@ -801,6 +801,34 @@ int cpu_exec(CPUState *cpu)return ret; } +void tcg_exec_realizefn (CPUState *cpu,Error **errp) +{ +static bool tcg_target_initialized; +CPUClass *cc =CPU_GET_CLASS (cpu); + +if (!tcg_target_initialized) { + tcg_target_initialized = true; + cc->tcg_ops.initialize (); + } +tlb_init (cpu); +qemu_plugin_vcpu_init_hook (cpu); + +#ifndef CONFIG_USER_ONLY +tcg_iommu_init_notifier_list (cpu); +#endif /* !CONFIG_USER_ONLY */ +} + +/* undo the initializations in reverse order */ +void tcg_exec_unrealizefn (CPUState *cpu) +{ +#ifndef CONFIG_USER_ONLY +tcg_iommu_free_notifier_list (cpu); +#endif /* !CONFIG_USER_ONLY */ + +qemu_plugin_vcpu_exit_hook (cpu); +tlb_destroy (cpu); +} +#ifndef CONFIG_USER_ONLY void dump_drift_info (void )
cpu.c +33 -37
93 lines not on this page · raw message
hw/core/cpu.c +5 -1
@@ -199,6 +199,10 @@ static bool cpu_common_virtio_is_big_endian(CPUState *cpu)return target_words_bigendian (); } +/* +* XXX the following #if is always true because this is a common_ss +* module, so target CONFIG_* is never defined. +*/ #if !defined(CONFIG_USER_ONLY )GuestPanicInformation *cpu_get_crash_info (CPUState *cpu) {
@@ -340,9 +344,9 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp)static void cpu_common_unrealizefn (DeviceState *dev) {CPUState *cpu =CPU (dev); +/* NOTE: latest generic point before the cpu is fully unrealized */ trace_fini_vcpu (cpu); -qemu_plugin_vcpu_exit_hook (cpu);cpu_exec_unrealizefn (cpu); }
include/hw/core/cpu.h +8 -0
@@ -1119,10 +1119,18 @@ AddressSpace *cpu_get_address_space(CPUState *cpu, int asidx); void QEMU_NORETURN cpu_abort(CPUState *cpu, const char *fmt, ...) GCC_FMT_ATTR(2, 3);extern Property cpu_common_props[]; + +/* $(top_srcdir)/cpu.c */ void cpu_exec_initfn (CPUState *cpu);void cpu_exec_realizefn (CPUState *cpu,Error **errp);void cpu_exec_unrealizefn (CPUState *cpu); +#ifdef CONFIG_TCG +/* accel/tcg/cpu-exec.c */ +void tcg_exec_realizefn (CPUState *cpu,Error **errp); +void tcg_exec_unrealizefn (CPUState *cpu); +#endif /* CONFIG_TCG */ +/** * target_words_bigendian: * Returns true if the (default) endianness of the target is big endian,
Signature · 1 line
2.26.2
Re: [RFC v9 17/32] accel/tcg: split TCG-only code from cpu_exec_realizefn
Quoted 16 lines · Claudio Fontana
move away TCG-only code, make it compile only on TCG.
Signed-off-by Claudio Fontana <[email protected]>--- accel/tcg/cpu-exec.c | 28 +++++++++++++++++ cpu.c | 70 ++++++++++++++++++++----------------------- hw/core/cpu.c | 6 +++- include/hw/core/cpu.h | 8 +++++ 4 files changed, 74 insertions(+), 38 deletions(-)accel/tcg/cpu-exec.c +0
-0@@ -801,6 +801,34 @@ int cpu_exec(CPUState *cpu)return ret;
accel/tcg/cpu-exec.c int cpu_exec(CPUState *cpu) · line 811
Quoted 10 lines
accel/tcg/cpu-exec.c +8
-0} +void tcg_exec_realizefn (CPUState *cpu,Error **errp) +{ +static bool tcg_target_initialized; +CPUClass *cc =CPU_GET_CLASS (cpu); + +if (!tcg_target_initialized) { + tcg_target_initialized = true; + cc->tcg_ops.initialize ();
nit: it makes no difference but stylistically it makes sense to set tcg_target_initialized after we have in fact initialised.
Also we've dropped the tcg_enabled() check, if indeed it will always be true should we not assert it to ensure the statement for tcg_exec_init remains the case: "Must be called before using the QEMU cpus."
Otherwise LGTM:
Signature · 1 line
Alex Bennée
Re: [RFC v9 17/32] accel/tcg: split TCG-only code from cpu_exec_realizefn
Quoted 33 lines · Alex Bennée
Quoted 16 lines · Claudio Fontana
move away TCG-only code, make it compile only on TCG.
Signed-off-by Claudio Fontana <[email protected]>--- accel/tcg/cpu-exec.c | 28 +++++++++++++++++ cpu.c | 70 ++++++++++++++++++++----------------------- hw/core/cpu.c | 6 +++- include/hw/core/cpu.h | 8 +++++ 4 files changed, 74 insertions(+), 38 deletions(-)accel/tcg/cpu-exec.c +0
-0@@ -801,6 +801,34 @@ int cpu_exec(CPUState *cpu)return ret;accel/tcg/cpu-exec.c int cpu_exec(CPUState *cpu) · line 811
Quoted 10 lines
accel/tcg/cpu-exec.c +8
-0} +void tcg_exec_realizefn (CPUState *cpu,Error **errp) +{ +static bool tcg_target_initialized; +CPUClass *cc =CPU_GET_CLASS (cpu); + +if (!tcg_target_initialized) { + tcg_target_initialized = true; + cc->tcg_ops.initialize ();nit: it makes no difference but stylistically it makes sense to set
tcg_target_initializedafter we have in fact initialised.
Quoted 1 line
Also we've dropped the
tcg_enabled()check,
The tcg_enabled() check should be there, not here but in cpu_exec_realizefn,
if (tcg_enabled()) {
tcg_exec_realizefn(...)
}
will check, thanks!
Quoted 8 lines
if indeed it will always be
true should we not assert it to ensure the statement fortcg_exec_initremains the case: "Must be called before using the QEMU cpus."Otherwise LGTM:
Reviewed-by Alex Bennée <[email protected]>
RFC v9 18/32 cpu: Move synchronize_from_tb() to tcg_ops
In reply to Claudio FontanaFrom: Eduardo Habkost <[email protected]>
--- accel/tcg/cpu-exec.c | 4 ++-- include/hw/core/cpu.h | 8 -------- include/hw/core/tcg-cpu-ops.h | 14 +++++++++++--- target/arm/cpu.c | 2 +- target/avr/cpu.c | 2 +- target/hppa/cpu.c | 2 +- target/i386/tcg-cpu.c | 2 +- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 2 +- target/riscv/cpu.c | 2 +- target/rx/cpu.c | 2 +- target/sh4/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/tricore/cpu.c | 2 +- 14 files changed, 24 insertions(+), 24 deletions(-)
accel/tcg/cpu-exec.c +2 -2
@@ -192,8 +192,8 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb) TARGET_FMT_lx"] %s\n" , last_tb->tc.ptr, last_tb->pc, lookup_symbol(last_tb->pc)); -if (cc->synchronize_from_tb) { - cc->synchronize_from_tb (cpu, last_tb); +if (cc->tcg_ops.synchronize_from_tb) { + cc->tcg_ops.synchronize_from_tb (cpu, last_tb); }else {assert (cc->set_pc); cc->set_pc (cpu, last_tb->pc);
include/hw/core/cpu.h +0 -8
@@ -110,13 +110,6 @@ struct TranslationBlock;* If the target behaviour here is anything other than "set * the PC register to the value passed in" then the target must * also implement the synchronize_from_tb hook. -* @synchronize_from_tb: Callback for synchronizing state from a TCG -* #TranslationBlock. This is called when we abandon execution -* of a TB before starting it, and must set all parts of the CPU -* state which the previous TB in the chain may not have updated. -* This always includes at least the program counter; some targets -* will need to do more. If this hook is not implemented then the -* default is to call @set_pc(tb->pc). * @tlb_fill: Callback for handling a softmmu tlb miss or user-only * address fault. For system mode, if the access is valid, call * tlb_set_page and return true; if the access is invalid, and
@@ -193,7 +186,6 @@ struct CPUClass {void (*get_memory_mapping)(CPUState *cpu,MemoryMappingList *list,Error **errp);void (*set_pc)(CPUState *cpu,vaddr value); -void (*synchronize_from_tb)(CPUState *cpu,struct TranslationBlock *tb);bool (*tlb_fill)(CPUState *cpu,vaddr address,int size,MMUAccessType access_type,int mmu_idx,bool probe,uintptr_t retaddr);
include/hw/core/tcg-cpu-ops.h +11 -3
@@ -10,9 +10,6 @@ #ifndef TCG_CPU_OPS_H #define TCG_CPU_OPS_H -/** - * struct TcgCpuOperations: TCG operations specific to a CPU class - */ typedef struct TcgCpuOperations { /** * @initialize: Initalize TCG state
@@ -20,6 +17,17 @@ typedef struct TcgCpuOperations {* Called when the first CPU is realized. */ void (*initialize)(void ); +/** +* @synchronize_from_tb: Synchronize state from a TCG #TranslationBlock +* +* This is called when we abandon execution of a TB before +* starting it, and must set all parts of the CPU state which +* the previous TB in the chain may not have updated. This +* will need to do more. If this hook is not implemented then +* the default is to call +* @set_pc(tb->pc). +*/ + void (*synchronize_from_tb)(CPUState *cpu, struct TranslationBlock *tb); } TcgCpuOperations;#endif /* TCG_CPU_OPS_H */
target/arm/cpu.c +1 -1
@@ -2242,7 +2242,6 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->cpu_exec_interrupt = arm_cpu_exec_interrupt; cc->dump_state = arm_cpu_dump_state; cc->set_pc = arm_cpu_set_pc; - cc->synchronize_from_tb = arm_cpu_synchronize_from_tb; cc->gdb_read_register = arm_cpu_gdb_read_register; cc->gdb_write_register = arm_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY
@@ -2262,6 +2261,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->disas_set_info = arm_disas_set_info;#ifdef CONFIG_TCG cc->tcg_ops.initialize = arm_translate_init; + cc->tcg_ops.synchronize_from_tb = arm_cpu_synchronize_from_tb; cc->tlb_fill = arm_cpu_tlb_fill; cc->debug_excp_handler = arm_debug_excp_handler; cc->debug_check_watchpoint = arm_debug_check_watchpoint;
target/avr/cpu.c +1 -1
@@ -207,7 +207,7 @@ static void avr_cpu_class_init(ObjectClass *oc, void *data) cc->vmsd = &vms_avr_cpu; cc->disas_set_info = avr_cpu_disas_set_info; cc->tcg_ops.initialize = avr_cpu_tcg_init; - cc->synchronize_from_tb = avr_cpu_synchronize_from_tb; + cc->tcg_ops.synchronize_from_tb = avr_cpu_synchronize_from_tb; cc->gdb_read_register = avr_cpu_gdb_read_register; cc->gdb_write_register = avr_cpu_gdb_write_register; cc->gdb_num_core_regs =35 ;
target/hppa/cpu.c +1 -1
@@ -143,7 +143,7 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *data) cc->cpu_exec_interrupt = hppa_cpu_exec_interrupt; cc->dump_state = hppa_cpu_dump_state; cc->set_pc = hppa_cpu_set_pc; - cc->synchronize_from_tb = hppa_cpu_synchronize_from_tb; + cc->tcg_ops.synchronize_from_tb = hppa_cpu_synchronize_from_tb; cc->gdb_read_register = hppa_cpu_gdb_read_register; cc->gdb_write_register = hppa_cpu_gdb_write_register; cc->tlb_fill = hppa_cpu_tlb_fill;
target/i386/tcg-cpu.c +1 -1
@@ -60,7 +60,7 @@ void tcg_cpu_common_class_init(CPUClass *cc) { cc->do_interrupt = x86_cpu_do_interrupt; cc->cpu_exec_interrupt = x86_cpu_exec_interrupt; - cc->synchronize_from_tb = x86_cpu_synchronize_from_tb; + cc->tcg_ops.synchronize_from_tb = x86_cpu_synchronize_from_tb; cc->cpu_exec_enter = x86_cpu_exec_enter; cc->cpu_exec_exit = x86_cpu_exec_exit; cc->tcg_ops.initialize = tcg_x86_init;
target/microblaze/cpu.c +1 -1
@@ -322,7 +322,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data) cc->cpu_exec_interrupt = mb_cpu_exec_interrupt; cc->dump_state = mb_cpu_dump_state; cc->set_pc = mb_cpu_set_pc; - cc->synchronize_from_tb = mb_cpu_synchronize_from_tb; + cc->tcg_ops.synchronize_from_tb = mb_cpu_synchronize_from_tb; cc->gdb_read_register = mb_cpu_gdb_read_register; cc->gdb_write_register = mb_cpu_gdb_write_register; cc->tlb_fill = mb_cpu_tlb_fill;
target/mips/cpu.c +1 -1
@@ -238,7 +238,6 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->cpu_exec_interrupt = mips_cpu_exec_interrupt; cc->dump_state = mips_cpu_dump_state; cc->set_pc = mips_cpu_set_pc; - cc->synchronize_from_tb = mips_cpu_synchronize_from_tb; cc->gdb_read_register = mips_cpu_gdb_read_register; cc->gdb_write_register = mips_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY
@@ -250,6 +249,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->disas_set_info = mips_cpu_disas_set_info;#ifdef CONFIG_TCG cc->tcg_ops.initialize = mips_tcg_init; + cc->tcg_ops.synchronize_from_tb = mips_cpu_synchronize_from_tb; cc->tlb_fill = mips_cpu_tlb_fill;#endif
target/riscv/cpu.c +1 -1
@@ -543,7 +543,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data) cc->cpu_exec_interrupt = riscv_cpu_exec_interrupt; cc->dump_state = riscv_cpu_dump_state; cc->set_pc = riscv_cpu_set_pc; - cc->synchronize_from_tb = riscv_cpu_synchronize_from_tb; + cc->tcg_ops.synchronize_from_tb = riscv_cpu_synchronize_from_tb; cc->gdb_read_register = riscv_cpu_gdb_read_register; cc->gdb_write_register = riscv_cpu_gdb_write_register; cc->gdb_num_core_regs =33 ;
target/rx/cpu.c +1 -1
@@ -189,7 +189,7 @@ static void rx_cpu_class_init(ObjectClass *klass, void *data) cc->cpu_exec_interrupt = rx_cpu_exec_interrupt; cc->dump_state = rx_cpu_dump_state; cc->set_pc = rx_cpu_set_pc; - cc->synchronize_from_tb = rx_cpu_synchronize_from_tb; + cc->tcg_ops.synchronize_from_tb = rx_cpu_synchronize_from_tb; cc->gdb_read_register = rx_cpu_gdb_read_register; cc->gdb_write_register = rx_cpu_gdb_write_register; cc->get_phys_page_debug = rx_cpu_get_phys_page_debug;
target/sh4/cpu.c +1 -1
@@ -222,7 +222,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) cc->cpu_exec_interrupt = superh_cpu_exec_interrupt; cc->dump_state = superh_cpu_dump_state; cc->set_pc = superh_cpu_set_pc; - cc->synchronize_from_tb = superh_cpu_synchronize_from_tb; + cc->tcg_ops.synchronize_from_tb = superh_cpu_synchronize_from_tb; cc->gdb_read_register = superh_cpu_gdb_read_register; cc->gdb_write_register = superh_cpu_gdb_write_register; cc->tlb_fill = superh_cpu_tlb_fill;
target/sparc/cpu.c +1 -1
@@ -868,7 +868,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data) cc->memory_rw_debug = sparc_cpu_memory_rw_debug;#endif cc->set_pc = sparc_cpu_set_pc; - cc->synchronize_from_tb = sparc_cpu_synchronize_from_tb; + cc->tcg_ops.synchronize_from_tb = sparc_cpu_synchronize_from_tb; cc->gdb_read_register = sparc_cpu_gdb_read_register; cc->gdb_write_register = sparc_cpu_gdb_write_register; cc->tlb_fill = sparc_cpu_tlb_fill;
target/tricore/cpu.c +1 -1
@@ -162,7 +162,7 @@ static void tricore_cpu_class_init(ObjectClass *c, void *data) cc->dump_state = tricore_cpu_dump_state; cc->set_pc = tricore_cpu_set_pc; - cc->synchronize_from_tb = tricore_cpu_synchronize_from_tb; + cc->tcg_ops.synchronize_from_tb = tricore_cpu_synchronize_from_tb; cc->get_phys_page_debug = tricore_cpu_get_phys_page_debug; cc->tcg_ops.initialize = tricore_tcg_init; cc->tlb_fill = tricore_cpu_tlb_fill;
Signature · 1 line
2.26.2
Re: [RFC v9 18/32] cpu: Move synchronize_from_tb() to tcg_ops
Quoted 7 lines · Claudio Fontana
From: Eduardo Habkost <[email protected]>
Signed-off-by Eduardo Habkost <[email protected]>[claudio: wrapped in CONFIG_TCG]Signed-off-by Claudio Fontana <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>---
...
include/hw/core/tcg-cpu-ops.h line 11
Quoted 7 lines
include/hw/core/tcg-cpu-ops.h +0
-0@@ -10,9 +10,6 @@#ifndef TCG_CPU_OPS_H #define TCG_CPU_OPS_H
Missing for TranslationBlock:
#include "hw/core/cpu.h"
include/hw/core/tcg-cpu-ops.h line 15
Quoted 4 lines
include/hw/core/tcg-cpu-ops.h +0
-3-/** -* struct TcgCpuOperations: TCG operations specific to a CPU class -*/
Why remove the comment?
Quoted 19 lines
include/hw/core/tcg-cpu-ops.h +11
-0typedef struct TcgCpuOperations { /** * @initialize: Initalize TCG state@@ -20,6 +17,17 @@ typedef struct TcgCpuOperations {* Called when the first CPU is realized. */ void (*initialize)(void ); +/** +* @synchronize_from_tb: Synchronize state from a TCG #TranslationBlock +* +* This is called when we abandon execution of a TB before +* starting it, and must set all parts of the CPU state which +* the previous TB in the chain may not have updated. This +* will need to do more. If this hook is not implemented then +* the default is to call +* @set_pc(tb->pc). +*/ +void (*synchronize_from_tb)(CPUState *cpu,struct TranslationBlock *tb); } TcgCpuOperations;
...
Re: [RFC v9 18/32] cpu: Move synchronize_from_tb() to tcg_ops
Hi Philippe,
Quoted 19 lines · Philippe Mathieu-Daudé
Quoted 7 lines · Claudio Fontana
From: Eduardo Habkost <[email protected]>
Signed-off-by Eduardo Habkost <[email protected]>[claudio: wrapped in CONFIG_TCG]Signed-off-by Claudio Fontana <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>---
...
include/hw/core/tcg-cpu-ops.h line 11
Quoted 7 lines
include/hw/core/tcg-cpu-ops.h +0
-0@@ -10,9 +10,6 @@#ifndef TCG_CPU_OPS_H #define TCG_CPU_OPS_H Missing for TranslationBlock:
Quoted 1 line
#include "hw/core/cpu.h"
this file though is only included from hw/core/cpu.h itself under CONFIG_TCG..
Quoted 7 lines
include/hw/core/tcg-cpu-ops.h line 15
Quoted 5 lines
include/hw/core/tcg-cpu-ops.h +0
-3-/** -* struct TcgCpuOperations: TCG operations specific to a CPU class -*/ Why remove the comment?
a mistake, will fix.
Quoted 23 lines
Quoted 20 lines
include/hw/core/tcg-cpu-ops.h +11
-0typedef struct TcgCpuOperations { /** * @initialize: Initalize TCG state@@ -20,6 +17,17 @@ typedef struct TcgCpuOperations {* Called when the first CPU is realized. */ void (*initialize)(void ); +/** +* @synchronize_from_tb: Synchronize state from a TCG #TranslationBlock +* +* This is called when we abandon execution of a TB before +* starting it, and must set all parts of the CPU state which +* the previous TB in the chain may not have updated. This +* will need to do more. If this hook is not implemented then +* the default is to call +* @set_pc(tb->pc). +*/ +void (*synchronize_from_tb)(CPUState *cpu,struct TranslationBlock *tb); } TcgCpuOperations;...
Re: [RFC v9 18/32] cpu: Move synchronize_from_tb() to tcg_ops
Quoted 22 lines · Claudio Fontana
Hi Philippe,
Quoted 19 lines · Philippe Mathieu-Daudé
Quoted 7 lines · Claudio Fontana
From: Eduardo Habkost <[email protected]>
Signed-off-by Eduardo Habkost <[email protected]>[claudio: wrapped in CONFIG_TCG]Signed-off-by Claudio Fontana <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>---
...
include/hw/core/tcg-cpu-ops.h line 11
Quoted 7 lines
include/hw/core/tcg-cpu-ops.h +0
-0@@ -10,9 +10,6 @@#ifndef TCG_CPU_OPS_H #define TCG_CPU_OPS_H Missing for TranslationBlock:
Quoted 4 lines
Quoted 1 line
#include "hw/core/cpu.h"this file though is only included from
hw/core/cpu.hitself underCONFIG_TCG..
1/ we never know how it will be included, includes should
be self-contained IMO.
2/ my editor isn't that smart and can't figure out the types.
Re: [RFC v9 18/32] cpu: Move synchronize_from_tb() to tcg_ops
In reply to Claudio FontanaQuoted 82 lines · Claudio Fontana
From: Eduardo Habkost <[email protected]>
Signed-off-by Eduardo Habkost <[email protected]>[claudio: wrapped in CONFIG_TCG]Signed-off-by Claudio Fontana <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>--- accel/tcg/cpu-exec.c | 4 ++-- include/hw/core/cpu.h | 8 -------- include/hw/core/tcg-cpu-ops.h | 14 +++++++++++--- target/arm/cpu.c | 2 +- target/avr/cpu.c | 2 +- target/hppa/cpu.c | 2 +- target/i386/tcg-cpu.c | 2 +- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 2 +- target/riscv/cpu.c | 2 +- target/rx/cpu.c | 2 +- target/sh4/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/tricore/cpu.c | 2 +- 14 files changed, 24 insertions(+), 24 deletions(-)accel/tcg/cpu-exec.c +2
-2@@ -192,8 +192,8 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb) TARGET_FMT_lx"] %s\n" , last_tb->tc.ptr, last_tb->pc, lookup_symbol(last_tb->pc)); -if (cc->synchronize_from_tb) { - cc->synchronize_from_tb (cpu, last_tb); +if (cc->tcg_ops.synchronize_from_tb) { + cc->tcg_ops.synchronize_from_tb (cpu, last_tb); }else {assert (cc->set_pc); cc->set_pc (cpu, last_tb->pc);include/hw/core/cpu.h +0
-8@@ -110,13 +110,6 @@ struct TranslationBlock;* If the target behaviour here is anything other than "set * the PC register to the value passed in" then the target must * also implement the synchronize_from_tb hook. -* @synchronize_from_tb: Callback for synchronizing state from a TCG -* #TranslationBlock. This is called when we abandon execution -* of a TB before starting it, and must set all parts of the CPU -* state which the previous TB in the chain may not have updated. -* This always includes at least the program counter; some targets -* will need to do more. If this hook is not implemented then the -* default is to call @set_pc(tb->pc). * @tlb_fill: Callback for handling a softmmu tlb miss or user-only * address fault. For system mode, if the access is valid, call * tlb_set_page and return true; if the access is invalid, and @@ -193,7 +186,6 @@ struct CPUClass {void (*get_memory_mapping)(CPUState *cpu,MemoryMappingList *list,Error **errp);void (*set_pc)(CPUState *cpu,vaddr value); -void (*synchronize_from_tb)(CPUState *cpu,struct TranslationBlock *tb);bool (*tlb_fill)(CPUState *cpu,vaddr address,int size,MMUAccessType access_type,int mmu_idx,bool probe,uintptr_t retaddr);include/hw/core/tcg-cpu-ops.h +0
-3@@ -10,9 +10,6 @@ #ifndef TCG_CPU_OPS_H #define TCG_CPU_OPS_H -/** - * struct TcgCpuOperations: TCG operations specific to a CPU class - */ typedef struct TcgCpuOperations { /** * @initialize: Initalize TCG state@@ -20,6 +17,17 @@ typedef struct TcgCpuOperations {* Called when the first CPU is realized. */ void (*initialize)(void );
include/hw/core/tcg-cpu-ops.h typedef struct TcgCpuOperations { · line 29
Quoted 10 lines
include/hw/core/tcg-cpu-ops.h +10
-0+/** +* @synchronize_from_tb: Synchronize state from a TCG #TranslationBlock +* +* This is called when we abandon execution of a TB before +* starting it, and must set all parts of the CPU state which +* the previous TB in the chain may not have updated. This +* will need to do more. If this hook is not implemented then +* the default is to call +* @set_pc(tb->pc). +*/
We could clean-up the comment here to better fit the javadoc style API documentation format, i.e.:
/**
* synchronize_from_tb: Synchronize current TCG execution state
* @cpu: current cpu
* @tb: about to be executed #TranslationBlock
*
* This is called when we abandon execution of a TB before
* starting it, and must set all parts of the CPU state which
* the previous TB in the chain may not have updated. This
* will need to do more. If this hook is not implemented then
* the default is to call @set_pc(tb->pc).
*/
<snip>
Otherwise:
Signature · 1 line
Alex Bennée
Re: [RFC v9 18/32] cpu: Move synchronize_from_tb() to tcg_ops
Quoted 10 lines · Alex Bennée
Quoted 7 lines · Claudio Fontana
From: Eduardo Habkost <[email protected]>
Signed-off-by Eduardo Habkost <[email protected]>[claudio: wrapped in CONFIG_TCG]Signed-off-by Claudio Fontana <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>---
[...]
Quoted 18 lines
Quoted 4 lines
include/hw/core/tcg-cpu-ops.h +0
-0@@ -20,6 +17,17 @@ typedef struct TcgCpuOperations {* Called when the first CPU is realized. */ void (*initialize)(void );include/hw/core/tcg-cpu-ops.h typedef struct TcgCpuOperations { · line 29
Quoted 10 lines
include/hw/core/tcg-cpu-ops.h +10
-0+/** +* @synchronize_from_tb: Synchronize state from a TCG #TranslationBlock +* +* This is called when we abandon execution of a TB before +* starting it, and must set all parts of the CPU state which +* the previous TB in the chain may not have updated. This +* will need to do more. If this hook is not implemented then +* the default is to call +* @set_pc(tb->pc). +*/ We could clean-up the comment here to better fit the javadoc style API documentation format, i.e.:
Quoted 11 lines
/**
*synchronize_from_tb: Synchronize current TCG execution state
* @cpu: current cpu
* @tb: about to be executed #TranslationBlock
*
* This is called when we abandon execution of a TB before
* starting it, and must set all parts of the CPU state which
* the previous TB in the chain may not have updated. This
* will need to do more. If this hook is not implemented then
* the default is to call @set_pc(tb->pc).
*/
Would this work with kernel-doc? This will be parsed as a portion of the documentation of struct TcgCpuOperations, so I was not expecting kernel-doc to treat the "@cpu: ..." and "@tb: ..." lines as valid.
Signature · 1 line
Eduardo
Re: [RFC v9 18/32] cpu: Move synchronize_from_tb() to tcg_ops
Quoted 42 lines · Eduardo Habkost
Quoted 10 lines · Alex Bennée
Quoted 7 lines · Claudio Fontana
From: Eduardo Habkost <[email protected]>
Signed-off-by Eduardo Habkost <[email protected]>[claudio: wrapped in CONFIG_TCG]Signed-off-by Claudio Fontana <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>---
[...]
Quoted 18 lines
Quoted 4 lines
include/hw/core/tcg-cpu-ops.h +0
-0@@ -20,6 +17,17 @@ typedef struct TcgCpuOperations {* Called when the first CPU is realized. */ void (*initialize)(void );include/hw/core/tcg-cpu-ops.h typedef struct TcgCpuOperations { · line 29
Quoted 10 lines
include/hw/core/tcg-cpu-ops.h +10
-0+/** +* @synchronize_from_tb: Synchronize state from a TCG #TranslationBlock +* +* This is called when we abandon execution of a TB before +* starting it, and must set all parts of the CPU state which +* the previous TB in the chain may not have updated. This +* will need to do more. If this hook is not implemented then +* the default is to call +* @set_pc(tb->pc). +*/ We could clean-up the comment here to better fit the javadoc style API documentation format, i.e.:
Quoted 11 lines
/**
*synchronize_from_tb: Synchronize current TCG execution state
* @cpu: current cpu
* @tb: about to be executed #TranslationBlock
*
* This is called when we abandon execution of a TB before
* starting it, and must set all parts of the CPU state which
* the previous TB in the chain may not have updated. This
* will need to do more. If this hook is not implemented then
* the default is to call @set_pc(tb->pc).
*/
Quoted 4 lines
Would this work with kernel-doc? This will be parsed as a portion of the documentation of struct TcgCpuOperations, so I was not expecting kernel-doc to treat the "@cpu: ..." and "@tb: ..." lines as valid.
Hmm looking at the guides it seems they wouldn't be processed:
I must admit I had previously just used exec-all.h as my template for what a well formed function document comment is meant to look like. It seems for it to work properly you need to use function pointer typedefs and document those.
However looking at which headers we convert into docs at the moment this is all moot as we don't process these headers at the moment. IOW ignore this request ;-)
Signature · 1 line
Alex Bennée
RFC v9 19/32 cpu: Move cpu_exec_* to tcg_ops
In reply to Claudio FontanaFrom: Eduardo Habkost <[email protected]>
--- accel/tcg/cpu-exec.c | 12 ++++++------ include/hw/core/cpu.h | 6 ------ include/hw/core/tcg-cpu-ops.h | 9 +++++++++ target/alpha/cpu.c | 3 ++- target/arm/cpu.c | 2 +- target/arm/cpu64.c | 5 ++++- target/arm/cpu_tcg.c | 5 ++++- target/avr/cpu.c | 2 +- target/cris/cpu.c | 2 +- target/hppa/cpu.c | 2 +- target/i386/tcg-cpu.c | 6 +++--- target/lm32/cpu.c | 2 +- target/m68k/cpu.c | 2 +- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 2 +- target/nios2/cpu.c | 2 +- target/openrisc/cpu.c | 2 +- target/ppc/translate_init.c.inc | 10 +++++----- target/riscv/cpu.c | 2 +- target/rx/cpu.c | 2 +- target/s390x/cpu.c | 2 +- target/sh4/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/tilegx/cpu.c | 2 +- target/unicore32/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- 26 files changed, 51 insertions(+), 41 deletions(-)
accel/tcg/cpu-exec.c +6 -6
@@ -240,8 +240,8 @@ static void cpu_exec_enter(CPUState *cpu) {CPUClass *cc =CPU_GET_CLASS (cpu); -if (cc->cpu_exec_enter) { - cc->cpu_exec_enter (cpu); +if (cc->tcg_ops.cpu_exec_enter) { + cc->tcg_ops.cpu_exec_enter (cpu); } }
@@ -249,8 +249,8 @@ static void cpu_exec_exit(CPUState *cpu) {CPUClass *cc =CPU_GET_CLASS (cpu); -if (cc->cpu_exec_exit) { - cc->cpu_exec_exit (cpu); +if (cc->tcg_ops.cpu_exec_exit) { + cc->tcg_ops.cpu_exec_exit (cpu); } }
@@ -625,8 +625,8 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,True when it is, and we should restart on a new TB, and via longjmp via cpu_loop_exit. */ else { -if (cc->cpu_exec_interrupt && - cc->cpu_exec_interrupt (cpu, interrupt_request)) { +if (cc->tcg_ops.cpu_exec_interrupt && + cc->tcg_ops.cpu_exec_interrupt (cpu, interrupt_request)) {if (need_replay_interrupt (interrupt_request)) {replay_interrupt (); }
include/hw/core/cpu.h +0 -6
@@ -146,9 +146,6 @@ struct TranslationBlock;* @gdb_get_dynamic_xml: Callback to return dynamically generated XML for the * gdb stub. Returns a pointer to the XML contents for the specified XML file * or NULL if the CPU doesn't have a dynamically generated content for it. -* @cpu_exec_enter: Callback for cpu_exec preparation. -* @cpu_exec_exit: Callback for cpu_exec cleanup. -* @cpu_exec_interrupt: Callback for processing interrupts in cpu_exec. * @disas_set_info: Setup architecture specific components of disassembly info * @adjust_watchpoint_address: Perform a target-specific adjustment to an * address before attempting to match it against watchpoints.
@@ -211,9 +208,6 @@ struct CPUClass {const char *gdb_core_xml_file; gchar * (*gdb_arch_name)(CPUState *cpu);const char * (*gdb_get_dynamic_xml)(CPUState *cpu,const char *xmlname); -void (*cpu_exec_enter)(CPUState *cpu); -void (*cpu_exec_exit)(CPUState *cpu); -bool (*cpu_exec_interrupt)(CPUState *cpu,int interrupt_request);void (*disas_set_info)(CPUState *cpu,disassemble_info *info);vaddr (*adjust_watchpoint_address)(CPUState *cpu,vaddr addr,int len);
include/hw/core/tcg-cpu-ops.h +9 -0
@@ -10,6 +10,9 @@ #ifndef TCG_CPU_OPS_H #define TCG_CPU_OPS_H +/** + * struct TcgCpuOperations: TCG operations specific to a CPU class + */ typedef struct TcgCpuOperations { /** * @initialize: Initalize TCG state
@@ -28,6 +31,12 @@ typedef struct TcgCpuOperations {* @set_pc(tb->pc). */ void (*synchronize_from_tb)(CPUState *cpu,struct TranslationBlock *tb); +/** @cpu_exec_enter: Callback for cpu_exec preparation */ +void (*cpu_exec_enter)(CPUState *cpu); +/** @cpu_exec_exit: Callback for cpu_exec cleanup */ +void (*cpu_exec_exit)(CPUState *cpu); +/** @cpu_exec_interrupt: Callback for processing interrupts in cpu_exec */ + bool (*cpu_exec_interrupt)(CPUState *cpu, int interrupt_request); } TcgCpuOperations;#endif /* TCG_CPU_OPS_H */
target/alpha/cpu.c +2 -1
@@ -218,7 +218,6 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = alpha_cpu_class_by_name; cc->has_work = alpha_cpu_has_work; cc->do_interrupt = alpha_cpu_do_interrupt; - cc->cpu_exec_interrupt = alpha_cpu_exec_interrupt; cc->dump_state = alpha_cpu_dump_state; cc->set_pc = alpha_cpu_set_pc; cc->gdb_read_register = alpha_cpu_gdb_read_register;
@@ -234,6 +233,8 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) cc->tcg_ops.initialize = alpha_translate_init; cc->gdb_num_core_regs =67 ; + + cc->tcg_ops.cpu_exec_interrupt = alpha_cpu_exec_interrupt; }#define DEFINE_ALPHA_CPU_TYPE (base_type, cpu_model, initfn) \
target/arm/cpu.c +1 -1
@@ -2239,7 +2239,6 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = arm_cpu_class_by_name; cc->has_work = arm_cpu_has_work; - cc->cpu_exec_interrupt = arm_cpu_exec_interrupt; cc->dump_state = arm_cpu_dump_state; cc->set_pc = arm_cpu_set_pc; cc->gdb_read_register = arm_cpu_gdb_read_register;
@@ -2261,6 +2260,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->disas_set_info = arm_disas_set_info;#ifdef CONFIG_TCG cc->tcg_ops.initialize = arm_translate_init; + cc->tcg_ops.cpu_exec_interrupt = arm_cpu_exec_interrupt; cc->tcg_ops.synchronize_from_tb = arm_cpu_synchronize_from_tb; cc->tlb_fill = arm_cpu_tlb_fill; cc->debug_excp_handler = arm_debug_excp_handler;
target/arm/cpu64.c +4 -1
@@ -784,7 +784,10 @@ static void aarch64_cpu_class_init(ObjectClass *oc, void *data) {CPUClass *cc =CPU_CLASS (oc); - cc->cpu_exec_interrupt = arm_cpu_exec_interrupt; +#ifdef CONFIG_TCG + cc->tcg_ops.cpu_exec_interrupt = arm_cpu_exec_interrupt; +#endif /* CONFIG_TCG */ + cc->gdb_read_register = aarch64_cpu_gdb_read_register; cc->gdb_write_register = aarch64_cpu_gdb_write_register; cc->gdb_num_core_regs =34 ;
target/arm/cpu_tcg.c +4 -1
@@ -628,7 +628,10 @@ static void arm_v7m_class_init(ObjectClass *oc, void *data) cc->do_interrupt = arm_v7m_cpu_do_interrupt;#endif - cc->cpu_exec_interrupt = arm_v7m_cpu_exec_interrupt; +#ifdef CONFIG_TCG + cc->tcg_ops.cpu_exec_interrupt = arm_v7m_cpu_exec_interrupt; +#endif /* CONFIG_TCG */ + cc->gdb_core_xml_file ="arm-m-profile.xml" ; }
target/avr/cpu.c +1 -1
@@ -198,7 +198,7 @@ static void avr_cpu_class_init(ObjectClass *oc, void *data) cc->has_work = avr_cpu_has_work; cc->do_interrupt = avr_cpu_do_interrupt; - cc->cpu_exec_interrupt = avr_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt = avr_cpu_exec_interrupt; cc->dump_state = avr_cpu_dump_state; cc->set_pc = avr_cpu_set_pc; cc->memory_rw_debug = avr_cpu_memory_rw_debug;
target/cris/cpu.c +1 -1
@@ -269,7 +269,7 @@ static void cris_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = cris_cpu_class_by_name; cc->has_work = cris_cpu_has_work; cc->do_interrupt = cris_cpu_do_interrupt; - cc->cpu_exec_interrupt = cris_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt = cris_cpu_exec_interrupt; cc->dump_state = cris_cpu_dump_state; cc->set_pc = cris_cpu_set_pc; cc->gdb_read_register = cris_cpu_gdb_read_register;
target/hppa/cpu.c +1 -1
@@ -140,7 +140,7 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = hppa_cpu_class_by_name; cc->has_work = hppa_cpu_has_work; cc->do_interrupt = hppa_cpu_do_interrupt; - cc->cpu_exec_interrupt = hppa_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt = hppa_cpu_exec_interrupt; cc->dump_state = hppa_cpu_dump_state; cc->set_pc = hppa_cpu_set_pc; cc->tcg_ops.synchronize_from_tb = hppa_cpu_synchronize_from_tb;
target/i386/tcg-cpu.c +3 -3
@@ -59,10 +59,10 @@ static void x86_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb)void tcg_cpu_common_class_init (CPUClass *cc) { cc->do_interrupt = x86_cpu_do_interrupt; - cc->cpu_exec_interrupt = x86_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt = x86_cpu_exec_interrupt; cc->tcg_ops.synchronize_from_tb = x86_cpu_synchronize_from_tb; - cc->cpu_exec_enter = x86_cpu_exec_enter; - cc->cpu_exec_exit = x86_cpu_exec_exit; + cc->tcg_ops.cpu_exec_enter = x86_cpu_exec_enter; + cc->tcg_ops.cpu_exec_exit = x86_cpu_exec_exit; cc->tcg_ops.initialize = tcg_x86_init; cc->tlb_fill = x86_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY
target/lm32/cpu.c +1 -1
@@ -223,7 +223,7 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = lm32_cpu_class_by_name; cc->has_work = lm32_cpu_has_work; cc->do_interrupt = lm32_cpu_do_interrupt; - cc->cpu_exec_interrupt = lm32_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt = lm32_cpu_exec_interrupt; cc->dump_state = lm32_cpu_dump_state; cc->set_pc = lm32_cpu_set_pc; cc->gdb_read_register = lm32_cpu_gdb_read_register;
target/m68k/cpu.c +1 -1
@@ -278,7 +278,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) cc->class_by_name = m68k_cpu_class_by_name; cc->has_work = m68k_cpu_has_work; cc->do_interrupt = m68k_cpu_do_interrupt; - cc->cpu_exec_interrupt = m68k_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt = m68k_cpu_exec_interrupt; cc->dump_state = m68k_cpu_dump_state; cc->set_pc = m68k_cpu_set_pc; cc->gdb_read_register = m68k_cpu_gdb_read_register;
target/microblaze/cpu.c +1 -1
@@ -319,7 +319,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data) cc->has_work = mb_cpu_has_work; cc->do_interrupt = mb_cpu_do_interrupt; cc->do_unaligned_access = mb_cpu_do_unaligned_access; - cc->cpu_exec_interrupt = mb_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt = mb_cpu_exec_interrupt; cc->dump_state = mb_cpu_dump_state; cc->set_pc = mb_cpu_set_pc; cc->tcg_ops.synchronize_from_tb = mb_cpu_synchronize_from_tb;
target/mips/cpu.c +1 -1
@@ -235,7 +235,6 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->class_by_name = mips_cpu_class_by_name; cc->has_work = mips_cpu_has_work; cc->do_interrupt = mips_cpu_do_interrupt; - cc->cpu_exec_interrupt = mips_cpu_exec_interrupt; cc->dump_state = mips_cpu_dump_state; cc->set_pc = mips_cpu_set_pc; cc->gdb_read_register = mips_cpu_gdb_read_register;
@@ -249,6 +248,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->disas_set_info = mips_cpu_disas_set_info;#ifdef CONFIG_TCG cc->tcg_ops.initialize = mips_tcg_init; + cc->tcg_ops.cpu_exec_interrupt = mips_cpu_exec_interrupt; cc->tcg_ops.synchronize_from_tb = mips_cpu_synchronize_from_tb; cc->tlb_fill = mips_cpu_tlb_fill;#endif
target/nios2/cpu.c +1 -1
@@ -193,7 +193,7 @@ static void nios2_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = nios2_cpu_class_by_name; cc->has_work = nios2_cpu_has_work; cc->do_interrupt = nios2_cpu_do_interrupt; - cc->cpu_exec_interrupt = nios2_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt = nios2_cpu_exec_interrupt; cc->dump_state = nios2_cpu_dump_state; cc->set_pc = nios2_cpu_set_pc; cc->disas_set_info = nios2_cpu_disas_set_info;
target/openrisc/cpu.c +1 -1
@@ -155,7 +155,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = openrisc_cpu_class_by_name; cc->has_work = openrisc_cpu_has_work; cc->do_interrupt = openrisc_cpu_do_interrupt; - cc->cpu_exec_interrupt = openrisc_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt = openrisc_cpu_exec_interrupt; cc->dump_state = openrisc_cpu_dump_state; cc->set_pc = openrisc_cpu_set_pc; cc->gdb_read_register = openrisc_cpu_gdb_read_register;
target/ppc/translate_init.c.inc +5 -5
@@ -10909,7 +10909,6 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->parse_features = ppc_cpu_parse_featurestr; cc->has_work = ppc_cpu_has_work; cc->do_interrupt = ppc_cpu_do_interrupt; - cc->cpu_exec_interrupt = ppc_cpu_exec_interrupt; cc->dump_state = ppc_cpu_dump_state; cc->dump_statistics = ppc_cpu_dump_statistics; cc->set_pc = ppc_cpu_set_pc;
@@ -10946,12 +10945,13 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) #endif #ifdef CONFIG_TCG cc->tcg_ops.initialize = ppc_translate_init; + cc->tcg_ops.cpu_exec_interrupt = ppc_cpu_exec_interrupt; cc->tlb_fill = ppc_cpu_tlb_fill; -#endif #ifndef CONFIG_USER_ONLY - cc->cpu_exec_enter = ppc_cpu_exec_enter; - cc->cpu_exec_exit = ppc_cpu_exec_exit; -#endif + cc->tcg_ops.cpu_exec_enter = ppc_cpu_exec_enter; + cc->tcg_ops.cpu_exec_exit = ppc_cpu_exec_exit; +#endif /* !CONFIG_USER_ONLY */ +#endif /* CONFIG_TCG */ cc->disas_set_info = ppc_disas_set_info;
target/riscv/cpu.c +1 -1
@@ -540,7 +540,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data) cc->class_by_name = riscv_cpu_class_by_name; cc->has_work = riscv_cpu_has_work; cc->do_interrupt = riscv_cpu_do_interrupt; - cc->cpu_exec_interrupt = riscv_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt = riscv_cpu_exec_interrupt; cc->dump_state = riscv_cpu_dump_state; cc->set_pc = riscv_cpu_set_pc; cc->tcg_ops.synchronize_from_tb = riscv_cpu_synchronize_from_tb;
target/rx/cpu.c +1 -1
@@ -186,7 +186,7 @@ static void rx_cpu_class_init(ObjectClass *klass, void *data) cc->class_by_name = rx_cpu_class_by_name; cc->has_work = rx_cpu_has_work; cc->do_interrupt = rx_cpu_do_interrupt; - cc->cpu_exec_interrupt = rx_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt = rx_cpu_exec_interrupt; cc->dump_state = rx_cpu_dump_state; cc->set_pc = rx_cpu_set_pc; cc->tcg_ops.synchronize_from_tb = rx_cpu_synchronize_from_tb;
target/s390x/cpu.c +1 -1
@@ -505,7 +505,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->get_crash_info = s390_cpu_get_crash_info; cc->write_elf64_note = s390_cpu_write_elf64_note;#ifdef CONFIG_TCG - cc->cpu_exec_interrupt = s390_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt = s390_cpu_exec_interrupt; cc->debug_excp_handler = s390x_cpu_debug_excp_handler; cc->do_unaligned_access = s390x_cpu_do_unaligned_access;#endif
target/sh4/cpu.c +1 -1
@@ -219,7 +219,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = superh_cpu_class_by_name; cc->has_work = superh_cpu_has_work; cc->do_interrupt = superh_cpu_do_interrupt; - cc->cpu_exec_interrupt = superh_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt = superh_cpu_exec_interrupt; cc->dump_state = superh_cpu_dump_state; cc->set_pc = superh_cpu_set_pc; cc->tcg_ops.synchronize_from_tb = superh_cpu_synchronize_from_tb;
target/sparc/cpu.c +1 -1
@@ -862,7 +862,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data) cc->parse_features = sparc_cpu_parse_features; cc->has_work = sparc_cpu_has_work; cc->do_interrupt = sparc_cpu_do_interrupt; - cc->cpu_exec_interrupt = sparc_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt = sparc_cpu_exec_interrupt; cc->dump_state = sparc_cpu_dump_state;#if !defined(TARGET_SPARC64 ) && !defined(CONFIG_USER_ONLY ) cc->memory_rw_debug = sparc_cpu_memory_rw_debug;
target/tilegx/cpu.c +1 -1
@@ -148,7 +148,7 @@ static void tilegx_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = tilegx_cpu_class_by_name; cc->has_work = tilegx_cpu_has_work; cc->do_interrupt = tilegx_cpu_do_interrupt; - cc->cpu_exec_interrupt = tilegx_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt = tilegx_cpu_exec_interrupt; cc->dump_state = tilegx_cpu_dump_state; cc->set_pc = tilegx_cpu_set_pc; cc->tlb_fill = tilegx_cpu_tlb_fill;
target/unicore32/cpu.c +1 -1
@@ -132,7 +132,7 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = uc32_cpu_class_by_name; cc->has_work = uc32_cpu_has_work; cc->do_interrupt = uc32_cpu_do_interrupt; - cc->cpu_exec_interrupt = uc32_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt = uc32_cpu_exec_interrupt; cc->dump_state = uc32_cpu_dump_state; cc->set_pc = uc32_cpu_set_pc; cc->tlb_fill = uc32_cpu_tlb_fill;
target/xtensa/cpu.c +1 -1
@@ -195,7 +195,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = xtensa_cpu_class_by_name; cc->has_work = xtensa_cpu_has_work; cc->do_interrupt = xtensa_cpu_do_interrupt; - cc->cpu_exec_interrupt = xtensa_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt = xtensa_cpu_exec_interrupt; cc->dump_state = xtensa_cpu_dump_state; cc->set_pc = xtensa_cpu_set_pc; cc->gdb_read_register = xtensa_cpu_gdb_read_register;
Signature · 1 line
2.26.2
Re: [RFC v9 19/32] cpu: Move cpu_exec_* to tcg_ops
Quoted 7 lines · Claudio Fontana
From: Eduardo Habkost <[email protected]>
Signed-off-by Eduardo Habkost <[email protected]>[claudio: wrapped in CONFIG_TCG]Signed-off-by Claudio Fontana <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>---
...
include/hw/core/tcg-cpu-ops.h line 15
Quoted 11 lines
include/hw/core/tcg-cpu-ops.h +3
-0@@ -10,6 +10,9 @@#ifndef TCG_CPU_OPS_H #define TCG_CPU_OPS_H +/** +* struct TcgCpuOperations: TCG operations specific to a CPU class +*/
Oh, added back ;)
Quoted 14 lines
include/hw/core/tcg-cpu-ops.h +6
-0typedef struct TcgCpuOperations { /** * @initialize: Initalize TCG state@@ -28,6 +31,12 @@ typedef struct TcgCpuOperations {* @set_pc(tb->pc). */ void (*synchronize_from_tb)(CPUState *cpu,struct TranslationBlock *tb); +/** @cpu_exec_enter: Callback for cpu_exec preparation */ +void (*cpu_exec_enter)(CPUState *cpu); +/** @cpu_exec_exit: Callback for cpu_exec cleanup */ +void (*cpu_exec_exit)(CPUState *cpu); +/** @cpu_exec_interrupt: Callback for processing interrupts in cpu_exec */ +bool (*cpu_exec_interrupt)(CPUState *cpu,int interrupt_request); } TcgCpuOperations;
Re: [RFC v9 19/32] cpu: Move cpu_exec_* to tcg_ops
Quoted 18 lines · Philippe Mathieu-Daudé
Quoted 7 lines · Claudio Fontana
From: Eduardo Habkost <[email protected]>
Signed-off-by Eduardo Habkost <[email protected]>[claudio: wrapped in CONFIG_TCG]Signed-off-by Claudio Fontana <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>---
...
Quoted 8 lines
include/hw/core/tcg-cpu-ops.h +0
-0@@ -10,6 +10,9 @@#ifndef TCG_CPU_OPS_H #define TCG_CPU_OPS_H
Quoted 5 lines
include/hw/core/tcg-cpu-ops.h line 15
Quoted 3 lines
include/hw/core/tcg-cpu-ops.h +3
-0+/** +* struct TcgCpuOperations: TCG operations specific to a CPU class +*/ Oh, added back ;)
Fixed this "back and forth", thanks!
Claudio
Quoted 16 lines
Quoted 15 lines
include/hw/core/tcg-cpu-ops.h +6
-0typedef struct TcgCpuOperations { /** * @initialize: Initalize TCG state@@ -28,6 +31,12 @@ typedef struct TcgCpuOperations {* @set_pc(tb->pc). */ void (*synchronize_from_tb)(CPUState *cpu,struct TranslationBlock *tb); +/** @cpu_exec_enter: Callback for cpu_exec preparation */ +void (*cpu_exec_enter)(CPUState *cpu); +/** @cpu_exec_exit: Callback for cpu_exec cleanup */ +void (*cpu_exec_exit)(CPUState *cpu); +/** @cpu_exec_interrupt: Callback for processing interrupts in cpu_exec */ +bool (*cpu_exec_interrupt)(CPUState *cpu,int interrupt_request); } TcgCpuOperations;
Re: [RFC v9 19/32] cpu: Move cpu_exec_* to tcg_ops
In reply to Claudio FontanaQuoted 6 lines · Claudio Fontana
From: Eduardo Habkost <[email protected]>
Signed-off-by Eduardo Habkost <[email protected]>[claudio: wrapped in CONFIG_TCG]Signed-off-by Claudio Fontana <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Signature · 1 line
Alex Bennée
RFC v9 20/32 cpu: Move tlb_fill to tcg_ops
In reply to Claudio FontanaFrom: Eduardo Habkost <[email protected]>
--- accel/tcg/cputlb.c | 6 +++--- accel/tcg/user-exec.c | 6 +++--- include/hw/core/cpu.h | 9 --------- include/hw/core/tcg-cpu-ops.h | 12 ++++++++++++ target/alpha/cpu.c | 2 +- target/arm/cpu.c | 2 +- target/avr/cpu.c | 2 +- target/cris/cpu.c | 2 +- target/hppa/cpu.c | 2 +- target/i386/tcg-cpu.c | 2 +- target/lm32/cpu.c | 2 +- target/m68k/cpu.c | 2 +- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 2 +- target/moxie/cpu.c | 2 +- target/nios2/cpu.c | 2 +- target/openrisc/cpu.c | 2 +- target/ppc/translate_init.c.inc | 2 +- target/riscv/cpu.c | 2 +- target/rx/cpu.c | 2 +- target/s390x/cpu.c | 2 +- target/sh4/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/tilegx/cpu.c | 2 +- target/tricore/cpu.c | 2 +- target/unicore32/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- 27 files changed, 41 insertions(+), 38 deletions(-)
accel/tcg/cputlb.c +3 -3
@@ -1286,7 +1286,7 @@ static void tlb_fill(CPUState *cpu, target_ulong addr, int size,* This is not a probe, so only valid return is success; failure * should result in exception + longjmp to the cpu loop. */ - ok = cc->tlb_fill (cpu, addr, size, access_type, mmu_idx, false, retaddr); + ok = cc->tcg_ops.tlb_fill (cpu, addr, size, access_type, mmu_idx, false, retaddr);assert (ok); }
@@ -1557,8 +1557,8 @@ static int probe_access_internal(CPUArchState *env, target_ulong addr,CPUState *cs =env_cpu (env);CPUClass *cc =CPU_GET_CLASS (cs); -if (!cc->tlb_fill (cs, addr, fault_size, access_type, - mmu_idx, nonfault, retaddr)) { +if (!cc->tcg_ops.tlb_fill (cs, addr, fault_size, access_type, + mmu_idx, nonfault, retaddr)) {/* Non-faulting page table read failed. */ *phost =NULL ;return TLB_INVALID_MASK ;
accel/tcg/user-exec.c +3 -3
@@ -186,7 +186,7 @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info,clear_helper_retaddr (); cc =CPU_GET_CLASS (cpu); - cc->tlb_fill (cpu, address,0 , access_type,MMU_USER_IDX , false, pc); + cc->tcg_ops.tlb_fill (cpu, address,0 , access_type,MMU_USER_IDX , false, pc);g_assert_not_reached (); }
@@ -216,8 +216,8 @@ static int probe_access_internal(CPUArchState *env, target_ulong addr, }else {CPUState *cpu =env_cpu (env);CPUClass *cc =CPU_GET_CLASS (cpu); - cc->tlb_fill (cpu, addr, fault_size, access_type, -MMU_USER_IDX , false, ra); + cc->tcg_ops.tlb_fill (cpu, addr, fault_size, access_type, +MMU_USER_IDX , false, ra);g_assert_not_reached (); } }
include/hw/core/cpu.h +0 -9
@@ -110,12 +110,6 @@ struct TranslationBlock;* If the target behaviour here is anything other than "set * the PC register to the value passed in" then the target must * also implement the synchronize_from_tb hook. -* @tlb_fill: Callback for handling a softmmu tlb miss or user-only -* address fault. For system mode, if the access is valid, call -* tlb_set_page and return true; if the access is invalid, and -* probe is true, return false; otherwise raise an exception and -* do not return. For user-only mode, always raise an exception -* and do not return. * @get_phys_page_debug: Callback for obtaining a physical address. * @get_phys_page_attrs_debug: Callback for obtaining a physical address and the * associated memory transaction attributes to use for the access.
@@ -183,9 +177,6 @@ struct CPUClass {void (*get_memory_mapping)(CPUState *cpu,MemoryMappingList *list,Error **errp);void (*set_pc)(CPUState *cpu,vaddr value); -bool (*tlb_fill)(CPUState *cpu,vaddr address,int size, -MMUAccessType access_type,int mmu_idx, -bool probe,uintptr_t retaddr);hwaddr (*get_phys_page_debug)(CPUState *cpu,vaddr addr);hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu,vaddr addr,MemTxAttrs *attrs);
include/hw/core/tcg-cpu-ops.h +12 -0
@@ -37,6 +37,18 @@ typedef struct TcgCpuOperations {void (*cpu_exec_exit)(CPUState *cpu);/** @cpu_exec_interrupt: Callback for processing interrupts in cpu_exec */ bool (*cpu_exec_interrupt)(CPUState *cpu,int interrupt_request); +/** +* @tlb_fill: Handle a softmmu tlb miss or user-only address fault +* +* For system mode, if the access is valid, call tlb_set_page +* and return true; if the access is invalid, and probe is +* true, return false; otherwise raise an exception and do +* not return. For user-only mode, always raise an exception +* and do not return. +*/ +bool (*tlb_fill)(CPUState *cpu,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, + bool probe, uintptr_t retaddr); } TcgCpuOperations;#endif /* TCG_CPU_OPS_H */
target/alpha/cpu.c +1 -1
@@ -222,7 +222,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = alpha_cpu_set_pc; cc->gdb_read_register = alpha_cpu_gdb_read_register; cc->gdb_write_register = alpha_cpu_gdb_write_register; - cc->tlb_fill = alpha_cpu_tlb_fill; + cc->tcg_ops.tlb_fill = alpha_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY cc->do_transaction_failed = alpha_cpu_do_transaction_failed; cc->do_unaligned_access = alpha_cpu_do_unaligned_access;
target/arm/cpu.c +1 -1
@@ -2262,7 +2262,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->tcg_ops.initialize = arm_translate_init; cc->tcg_ops.cpu_exec_interrupt = arm_cpu_exec_interrupt; cc->tcg_ops.synchronize_from_tb = arm_cpu_synchronize_from_tb; - cc->tlb_fill = arm_cpu_tlb_fill; + cc->tcg_ops.tlb_fill = arm_cpu_tlb_fill; cc->debug_excp_handler = arm_debug_excp_handler; cc->debug_check_watchpoint = arm_debug_check_watchpoint; cc->do_unaligned_access = arm_cpu_do_unaligned_access;
target/avr/cpu.c +1 -1
@@ -203,7 +203,7 @@ static void avr_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = avr_cpu_set_pc; cc->memory_rw_debug = avr_cpu_memory_rw_debug; cc->get_phys_page_debug = avr_cpu_get_phys_page_debug; - cc->tlb_fill = avr_cpu_tlb_fill; + cc->tcg_ops.tlb_fill = avr_cpu_tlb_fill; cc->vmsd = &vms_avr_cpu; cc->disas_set_info = avr_cpu_disas_set_info; cc->tcg_ops.initialize = avr_cpu_tcg_init;
target/cris/cpu.c +1 -1
@@ -274,7 +274,7 @@ static void cris_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = cris_cpu_set_pc; cc->gdb_read_register = cris_cpu_gdb_read_register; cc->gdb_write_register = cris_cpu_gdb_write_register; - cc->tlb_fill = cris_cpu_tlb_fill; + cc->tcg_ops.tlb_fill = cris_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = cris_cpu_get_phys_page_debug; dc->vmsd = &vmstate_cris_cpu;
target/hppa/cpu.c +1 -1
@@ -146,7 +146,7 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *data) cc->tcg_ops.synchronize_from_tb = hppa_cpu_synchronize_from_tb; cc->gdb_read_register = hppa_cpu_gdb_read_register; cc->gdb_write_register = hppa_cpu_gdb_write_register; - cc->tlb_fill = hppa_cpu_tlb_fill; + cc->tcg_ops.tlb_fill = hppa_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = hppa_cpu_get_phys_page_debug; dc->vmsd = &vmstate_hppa_cpu;
target/i386/tcg-cpu.c +1 -1
@@ -64,7 +64,7 @@ void tcg_cpu_common_class_init(CPUClass *cc) cc->tcg_ops.cpu_exec_enter = x86_cpu_exec_enter; cc->tcg_ops.cpu_exec_exit = x86_cpu_exec_exit; cc->tcg_ops.initialize = tcg_x86_init; - cc->tlb_fill = x86_cpu_tlb_fill; + cc->tcg_ops.tlb_fill = x86_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY cc->debug_excp_handler = breakpoint_handler;#endif
target/lm32/cpu.c +1 -1
@@ -228,7 +228,7 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = lm32_cpu_set_pc; cc->gdb_read_register = lm32_cpu_gdb_read_register; cc->gdb_write_register = lm32_cpu_gdb_write_register; - cc->tlb_fill = lm32_cpu_tlb_fill; + cc->tcg_ops.tlb_fill = lm32_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = lm32_cpu_get_phys_page_debug; cc->vmsd = &vmstate_lm32_cpu;
target/m68k/cpu.c +1 -1
@@ -283,7 +283,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) cc->set_pc = m68k_cpu_set_pc; cc->gdb_read_register = m68k_cpu_gdb_read_register; cc->gdb_write_register = m68k_cpu_gdb_write_register; - cc->tlb_fill = m68k_cpu_tlb_fill; + cc->tcg_ops.tlb_fill = m68k_cpu_tlb_fill;#if defined(CONFIG_SOFTMMU ) cc->do_transaction_failed = m68k_cpu_transaction_failed; cc->get_phys_page_debug = m68k_cpu_get_phys_page_debug;
target/microblaze/cpu.c +1 -1
@@ -325,7 +325,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data) cc->tcg_ops.synchronize_from_tb = mb_cpu_synchronize_from_tb; cc->gdb_read_register = mb_cpu_gdb_read_register; cc->gdb_write_register = mb_cpu_gdb_write_register; - cc->tlb_fill = mb_cpu_tlb_fill; + cc->tcg_ops.tlb_fill = mb_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY cc->do_transaction_failed = mb_cpu_transaction_failed; cc->get_phys_page_debug = mb_cpu_get_phys_page_debug;
target/mips/cpu.c +1 -1
@@ -250,7 +250,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->tcg_ops.initialize = mips_tcg_init; cc->tcg_ops.cpu_exec_interrupt = mips_cpu_exec_interrupt; cc->tcg_ops.synchronize_from_tb = mips_cpu_synchronize_from_tb; - cc->tlb_fill = mips_cpu_tlb_fill; + cc->tcg_ops.tlb_fill = mips_cpu_tlb_fill;#endif cc->gdb_num_core_regs =73 ;
target/moxie/cpu.c +1 -1
@@ -110,7 +110,7 @@ static void moxie_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = moxie_cpu_do_interrupt; cc->dump_state = moxie_cpu_dump_state; cc->set_pc = moxie_cpu_set_pc; - cc->tlb_fill = moxie_cpu_tlb_fill; + cc->tcg_ops.tlb_fill = moxie_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = moxie_cpu_get_phys_page_debug; cc->vmsd = &vmstate_moxie_cpu;
target/nios2/cpu.c +1 -1
@@ -197,7 +197,7 @@ static void nios2_cpu_class_init(ObjectClass *oc, void *data) cc->dump_state = nios2_cpu_dump_state; cc->set_pc = nios2_cpu_set_pc; cc->disas_set_info = nios2_cpu_disas_set_info; - cc->tlb_fill = nios2_cpu_tlb_fill; + cc->tcg_ops.tlb_fill = nios2_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY cc->do_unaligned_access = nios2_cpu_do_unaligned_access; cc->get_phys_page_debug = nios2_cpu_get_phys_page_debug;
target/openrisc/cpu.c +1 -1
@@ -160,7 +160,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = openrisc_cpu_set_pc; cc->gdb_read_register = openrisc_cpu_gdb_read_register; cc->gdb_write_register = openrisc_cpu_gdb_write_register; - cc->tlb_fill = openrisc_cpu_tlb_fill; + cc->tcg_ops.tlb_fill = openrisc_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = openrisc_cpu_get_phys_page_debug; dc->vmsd = &vmstate_openrisc_cpu;
target/ppc/translate_init.c.inc +1 -1
@@ -10946,7 +10946,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) #ifdef CONFIG_TCG cc->tcg_ops.initialize = ppc_translate_init; cc->tcg_ops.cpu_exec_interrupt = ppc_cpu_exec_interrupt; - cc->tlb_fill = ppc_cpu_tlb_fill; + cc->tcg_ops.tlb_fill = ppc_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->tcg_ops.cpu_exec_enter = ppc_cpu_exec_enter; cc->tcg_ops.cpu_exec_exit = ppc_cpu_exec_exit;
target/riscv/cpu.c +1 -1
@@ -562,7 +562,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data) cc->vmsd = &vmstate_riscv_cpu;#endif cc->tcg_ops.initialize = riscv_translate_init; - cc->tlb_fill = riscv_cpu_tlb_fill; + cc->tcg_ops.tlb_fill = riscv_cpu_tlb_fill;device_class_set_props (dc, riscv_cpu_properties); }
target/rx/cpu.c +1 -1
@@ -195,7 +195,7 @@ static void rx_cpu_class_init(ObjectClass *klass, void *data) cc->get_phys_page_debug = rx_cpu_get_phys_page_debug; cc->disas_set_info = rx_cpu_disas_set_info; cc->tcg_ops.initialize = rx_translate_init; - cc->tlb_fill = rx_cpu_tlb_fill; + cc->tcg_ops.tlb_fill = rx_cpu_tlb_fill; cc->gdb_num_core_regs =26 ; cc->gdb_core_xml_file ="rx-core.xml" ;
target/s390x/cpu.c +1 -1
@@ -513,7 +513,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->disas_set_info = s390_cpu_disas_set_info;#ifdef CONFIG_TCG cc->tcg_ops.initialize = s390x_translate_init; - cc->tlb_fill = s390_cpu_tlb_fill; + cc->tcg_ops.tlb_fill = s390_cpu_tlb_fill;#endif cc->gdb_num_core_regs =S390_NUM_CORE_REGS ;
target/sh4/cpu.c +1 -1
@@ -225,7 +225,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) cc->tcg_ops.synchronize_from_tb = superh_cpu_synchronize_from_tb; cc->gdb_read_register = superh_cpu_gdb_read_register; cc->gdb_write_register = superh_cpu_gdb_write_register; - cc->tlb_fill = superh_cpu_tlb_fill; + cc->tcg_ops.tlb_fill = superh_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY cc->do_unaligned_access = superh_cpu_do_unaligned_access; cc->get_phys_page_debug = superh_cpu_get_phys_page_debug;
target/sparc/cpu.c +1 -1
@@ -871,7 +871,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data) cc->tcg_ops.synchronize_from_tb = sparc_cpu_synchronize_from_tb; cc->gdb_read_register = sparc_cpu_gdb_read_register; cc->gdb_write_register = sparc_cpu_gdb_write_register; - cc->tlb_fill = sparc_cpu_tlb_fill; + cc->tcg_ops.tlb_fill = sparc_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY cc->do_transaction_failed = sparc_cpu_do_transaction_failed; cc->do_unaligned_access = sparc_cpu_do_unaligned_access;
target/tilegx/cpu.c +1 -1
@@ -151,7 +151,7 @@ static void tilegx_cpu_class_init(ObjectClass *oc, void *data) cc->tcg_ops.cpu_exec_interrupt = tilegx_cpu_exec_interrupt; cc->dump_state = tilegx_cpu_dump_state; cc->set_pc = tilegx_cpu_set_pc; - cc->tlb_fill = tilegx_cpu_tlb_fill; + cc->tcg_ops.tlb_fill = tilegx_cpu_tlb_fill; cc->gdb_num_core_regs =0 ; cc->tcg_ops.initialize = tilegx_tcg_init; }
target/tricore/cpu.c +1 -1
@@ -165,7 +165,7 @@ static void tricore_cpu_class_init(ObjectClass *c, void *data) cc->tcg_ops.synchronize_from_tb = tricore_cpu_synchronize_from_tb; cc->get_phys_page_debug = tricore_cpu_get_phys_page_debug; cc->tcg_ops.initialize = tricore_tcg_init; - cc->tlb_fill = tricore_cpu_tlb_fill; + cc->tcg_ops.tlb_fill = tricore_cpu_tlb_fill; }#define DEFINE_TRICORE_CPU_TYPE (cpu_model, initfn) \
target/unicore32/cpu.c +1 -1
@@ -135,7 +135,7 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data) cc->tcg_ops.cpu_exec_interrupt = uc32_cpu_exec_interrupt; cc->dump_state = uc32_cpu_dump_state; cc->set_pc = uc32_cpu_set_pc; - cc->tlb_fill = uc32_cpu_tlb_fill; + cc->tcg_ops.tlb_fill = uc32_cpu_tlb_fill; cc->get_phys_page_debug = uc32_cpu_get_phys_page_debug; cc->tcg_ops.initialize = uc32_translate_init; dc->vmsd = &vmstate_uc32_cpu;
target/xtensa/cpu.c +1 -1
@@ -201,7 +201,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_read_register = xtensa_cpu_gdb_read_register; cc->gdb_write_register = xtensa_cpu_gdb_write_register; cc->gdb_stop_before_watchpoint = true; - cc->tlb_fill = xtensa_cpu_tlb_fill; + cc->tcg_ops.tlb_fill = xtensa_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY cc->do_unaligned_access = xtensa_cpu_do_unaligned_access; cc->get_phys_page_debug = xtensa_cpu_get_phys_page_debug;
Signature · 1 line
2.26.2
Re: [RFC v9 20/32] cpu: Move tlb_fill to tcg_ops
Quoted 121 lines · Claudio Fontana
From: Eduardo Habkost <[email protected]>
Signed-off-by Eduardo Habkost <[email protected]>[claudio: wrapped in CONFIG_TCG]Signed-off-by Claudio Fontana <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>--- accel/tcg/cputlb.c | 6 +++--- accel/tcg/user-exec.c | 6 +++--- include/hw/core/cpu.h | 9 --------- include/hw/core/tcg-cpu-ops.h | 12 ++++++++++++ target/alpha/cpu.c | 2 +- target/arm/cpu.c | 2 +- target/avr/cpu.c | 2 +- target/cris/cpu.c | 2 +- target/hppa/cpu.c | 2 +- target/i386/tcg-cpu.c | 2 +- target/lm32/cpu.c | 2 +- target/m68k/cpu.c | 2 +- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 2 +- target/moxie/cpu.c | 2 +- target/nios2/cpu.c | 2 +- target/openrisc/cpu.c | 2 +- target/ppc/translate_init.c.inc | 2 +- target/riscv/cpu.c | 2 +- target/rx/cpu.c | 2 +- target/s390x/cpu.c | 2 +- target/sh4/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/tilegx/cpu.c | 2 +- target/tricore/cpu.c | 2 +- target/unicore32/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- 27 files changed, 41 insertions(+), 38 deletions(-)accel/tcg/cputlb.c +3
-3@@ -1286,7 +1286,7 @@ static void tlb_fill(CPUState *cpu, target_ulong addr, int size,* This is not a probe, so only valid return is success; failure * should result in exception + longjmp to the cpu loop. */ - ok = cc->tlb_fill (cpu, addr, size, access_type, mmu_idx, false, retaddr); + ok = cc->tcg_ops.tlb_fill (cpu, addr, size, access_type, mmu_idx, false, retaddr);assert (ok); }@@ -1557,8 +1557,8 @@ static int probe_access_internal(CPUArchState *env, target_ulong addr,CPUState *cs =env_cpu (env);CPUClass *cc =CPU_GET_CLASS (cs); -if (!cc->tlb_fill (cs, addr, fault_size, access_type, - mmu_idx, nonfault, retaddr)) { +if (!cc->tcg_ops.tlb_fill (cs, addr, fault_size, access_type, + mmu_idx, nonfault, retaddr)) {/* Non-faulting page table read failed. */ *phost =NULL ;return TLB_INVALID_MASK ;accel/tcg/user-exec.c +3
-3@@ -186,7 +186,7 @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info,clear_helper_retaddr (); cc =CPU_GET_CLASS (cpu); - cc->tlb_fill (cpu, address,0 , access_type,MMU_USER_IDX , false, pc); + cc->tcg_ops.tlb_fill (cpu, address,0 , access_type,MMU_USER_IDX , false, pc);g_assert_not_reached (); }@@ -216,8 +216,8 @@ static int probe_access_internal(CPUArchState *env, target_ulong addr, }else {CPUState *cpu =env_cpu (env);CPUClass *cc =CPU_GET_CLASS (cpu); - cc->tlb_fill (cpu, addr, fault_size, access_type, -MMU_USER_IDX , false, ra); + cc->tcg_ops.tlb_fill (cpu, addr, fault_size, access_type, +MMU_USER_IDX , false, ra);g_assert_not_reached (); } }include/hw/core/cpu.h +0
-9@@ -110,12 +110,6 @@ struct TranslationBlock;* If the target behaviour here is anything other than "set * the PC register to the value passed in" then the target must * also implement the synchronize_from_tb hook. -* @tlb_fill: Callback for handling a softmmu tlb miss or user-only -* address fault. For system mode, if the access is valid, call -* tlb_set_page and return true; if the access is invalid, and -* probe is true, return false; otherwise raise an exception and -* do not return. For user-only mode, always raise an exception -* and do not return. * @get_phys_page_debug: Callback for obtaining a physical address. * @get_phys_page_attrs_debug: Callback for obtaining a physical address and the * associated memory transaction attributes to use for the access. @@ -183,9 +177,6 @@ struct CPUClass {void (*get_memory_mapping)(CPUState *cpu,MemoryMappingList *list,Error **errp);void (*set_pc)(CPUState *cpu,vaddr value); -bool (*tlb_fill)(CPUState *cpu,vaddr address,int size, -MMUAccessType access_type,int mmu_idx, -bool probe,uintptr_t retaddr);hwaddr (*get_phys_page_debug)(CPUState *cpu,vaddr addr);hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu,vaddr addr,MemTxAttrs *attrs);include/hw/core/tcg-cpu-ops.h +2
-0@@ -37,6 +37,18 @@ typedef struct TcgCpuOperations {void (*cpu_exec_exit)(CPUState *cpu);/** @cpu_exec_interrupt: Callback for processing interrupts in cpu_exec */ bool (*cpu_exec_interrupt)(CPUState *cpu,int interrupt_request); +/** +* @tlb_fill: Handle a softmmu tlb miss or user-only address fault
include/hw/core/tcg-cpu-ops.h typedef struct TcgCpuOperations { · line 51
Quoted 10 lines
include/hw/core/tcg-cpu-ops.h +10
-0+* +* For system mode, if the access is valid, call tlb_set_page +* and return true; if the access is invalid, and probe is +* true, return false; otherwise raise an exception and do +* not return. For user-only mode, always raise an exception +* and do not return. +*/ +bool (*tlb_fill)(CPUState *cpu,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr);
As per previous patch, here is a chance to clean-up the comment.
Otherwise:
Signature · 1 line
Alex Bennée
Re: [RFC v9 20/32] cpu: Move tlb_fill to tcg_ops
Quoted 128 lines · Alex Bennée
Quoted 125 lines · Claudio Fontana
From: Eduardo Habkost <[email protected]>
Signed-off-by Eduardo Habkost <[email protected]>[claudio: wrapped in CONFIG_TCG]Signed-off-by Claudio Fontana <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>--- accel/tcg/cputlb.c | 6 +++--- accel/tcg/user-exec.c | 6 +++--- include/hw/core/cpu.h | 9 --------- include/hw/core/tcg-cpu-ops.h | 12 ++++++++++++ target/alpha/cpu.c | 2 +- target/arm/cpu.c | 2 +- target/avr/cpu.c | 2 +- target/cris/cpu.c | 2 +- target/hppa/cpu.c | 2 +- target/i386/tcg-cpu.c | 2 +- target/lm32/cpu.c | 2 +- target/m68k/cpu.c | 2 +- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 2 +- target/moxie/cpu.c | 2 +- target/nios2/cpu.c | 2 +- target/openrisc/cpu.c | 2 +- target/ppc/translate_init.c.inc | 2 +- target/riscv/cpu.c | 2 +- target/rx/cpu.c | 2 +- target/s390x/cpu.c | 2 +- target/sh4/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/tilegx/cpu.c | 2 +- target/tricore/cpu.c | 2 +- target/unicore32/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- 27 files changed, 41 insertions(+), 38 deletions(-)accel/tcg/cputlb.c +3
-3@@ -1286,7 +1286,7 @@ static void tlb_fill(CPUState *cpu, target_ulong addr, int size,* This is not a probe, so only valid return is success; failure * should result in exception + longjmp to the cpu loop. */ - ok = cc->tlb_fill (cpu, addr, size, access_type, mmu_idx, false, retaddr); + ok = cc->tcg_ops.tlb_fill (cpu, addr, size, access_type, mmu_idx, false, retaddr);assert (ok); }@@ -1557,8 +1557,8 @@ static int probe_access_internal(CPUArchState *env, target_ulong addr,CPUState *cs =env_cpu (env);CPUClass *cc =CPU_GET_CLASS (cs); -if (!cc->tlb_fill (cs, addr, fault_size, access_type, - mmu_idx, nonfault, retaddr)) { +if (!cc->tcg_ops.tlb_fill (cs, addr, fault_size, access_type, + mmu_idx, nonfault, retaddr)) {/* Non-faulting page table read failed. */ *phost =NULL ;return TLB_INVALID_MASK ;accel/tcg/user-exec.c +3
-3@@ -186,7 +186,7 @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info,clear_helper_retaddr (); cc =CPU_GET_CLASS (cpu); - cc->tlb_fill (cpu, address,0 , access_type,MMU_USER_IDX , false, pc); + cc->tcg_ops.tlb_fill (cpu, address,0 , access_type,MMU_USER_IDX , false, pc);g_assert_not_reached (); }@@ -216,8 +216,8 @@ static int probe_access_internal(CPUArchState *env, target_ulong addr, }else {CPUState *cpu =env_cpu (env);CPUClass *cc =CPU_GET_CLASS (cpu); - cc->tlb_fill (cpu, addr, fault_size, access_type, -MMU_USER_IDX , false, ra); + cc->tcg_ops.tlb_fill (cpu, addr, fault_size, access_type, +MMU_USER_IDX , false, ra);g_assert_not_reached (); } }include/hw/core/cpu.h +0
-9@@ -110,12 +110,6 @@ struct TranslationBlock;* If the target behaviour here is anything other than "set * the PC register to the value passed in" then the target must * also implement the synchronize_from_tb hook. -* @tlb_fill: Callback for handling a softmmu tlb miss or user-only -* address fault. For system mode, if the access is valid, call -* tlb_set_page and return true; if the access is invalid, and -* probe is true, return false; otherwise raise an exception and -* do not return. For user-only mode, always raise an exception -* and do not return. * @get_phys_page_debug: Callback for obtaining a physical address. * @get_phys_page_attrs_debug: Callback for obtaining a physical address and the * associated memory transaction attributes to use for the access. @@ -183,9 +177,6 @@ struct CPUClass {void (*get_memory_mapping)(CPUState *cpu,MemoryMappingList *list,Error **errp);void (*set_pc)(CPUState *cpu,vaddr value); -bool (*tlb_fill)(CPUState *cpu,vaddr address,int size, -MMUAccessType access_type,int mmu_idx, -bool probe,uintptr_t retaddr);hwaddr (*get_phys_page_debug)(CPUState *cpu,vaddr addr);hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu,vaddr addr,MemTxAttrs *attrs);include/hw/core/tcg-cpu-ops.h +6
-0@@ -37,6 +37,18 @@ typedef struct TcgCpuOperations {void (*cpu_exec_exit)(CPUState *cpu);/** @cpu_exec_interrupt: Callback for processing interrupts in cpu_exec */ bool (*cpu_exec_interrupt)(CPUState *cpu,int interrupt_request); +/** +* @tlb_fill: Handle a softmmu tlb miss or user-only address fault +* +* For system mode, if the access is valid, call tlb_set_page +* and return true; if the access is invalid, and probe is +* true, return false; otherwise raise an exception and do
Quoted 8 lines
include/hw/core/tcg-cpu-ops.h typedef struct TcgCpuOperations { · line 51
Quoted 6 lines
include/hw/core/tcg-cpu-ops.h +6
-0+* not return. For user-only mode, always raise an exception +* and do not return. +*/ +bool (*tlb_fill)(CPUState *cpu,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr);As per previous patch, here is a chance to clean-up the comment.
Could you provide the text? I think you understand this better than I do...
Quoted 5 lines
Otherwise:
Reviewed-by Alex Bennée <[email protected]>
Thanks!
Claudio
Re: [RFC v9 20/32] cpu: Move tlb_fill to tcg_ops
Quoted 139 lines · Claudio Fontana
Quoted 128 lines · Alex Bennée
Quoted 125 lines · Claudio Fontana
From: Eduardo Habkost <[email protected]>
Signed-off-by Eduardo Habkost <[email protected]>[claudio: wrapped in CONFIG_TCG]Signed-off-by Claudio Fontana <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>--- accel/tcg/cputlb.c | 6 +++--- accel/tcg/user-exec.c | 6 +++--- include/hw/core/cpu.h | 9 --------- include/hw/core/tcg-cpu-ops.h | 12 ++++++++++++ target/alpha/cpu.c | 2 +- target/arm/cpu.c | 2 +- target/avr/cpu.c | 2 +- target/cris/cpu.c | 2 +- target/hppa/cpu.c | 2 +- target/i386/tcg-cpu.c | 2 +- target/lm32/cpu.c | 2 +- target/m68k/cpu.c | 2 +- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 2 +- target/moxie/cpu.c | 2 +- target/nios2/cpu.c | 2 +- target/openrisc/cpu.c | 2 +- target/ppc/translate_init.c.inc | 2 +- target/riscv/cpu.c | 2 +- target/rx/cpu.c | 2 +- target/s390x/cpu.c | 2 +- target/sh4/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/tilegx/cpu.c | 2 +- target/tricore/cpu.c | 2 +- target/unicore32/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- 27 files changed, 41 insertions(+), 38 deletions(-)accel/tcg/cputlb.c +3
-3@@ -1286,7 +1286,7 @@ static void tlb_fill(CPUState *cpu, target_ulong addr, int size,* This is not a probe, so only valid return is success; failure * should result in exception + longjmp to the cpu loop. */ - ok = cc->tlb_fill (cpu, addr, size, access_type, mmu_idx, false, retaddr); + ok = cc->tcg_ops.tlb_fill (cpu, addr, size, access_type, mmu_idx, false, retaddr);assert (ok); }@@ -1557,8 +1557,8 @@ static int probe_access_internal(CPUArchState *env, target_ulong addr,CPUState *cs =env_cpu (env);CPUClass *cc =CPU_GET_CLASS (cs); -if (!cc->tlb_fill (cs, addr, fault_size, access_type, - mmu_idx, nonfault, retaddr)) { +if (!cc->tcg_ops.tlb_fill (cs, addr, fault_size, access_type, + mmu_idx, nonfault, retaddr)) {/* Non-faulting page table read failed. */ *phost =NULL ;return TLB_INVALID_MASK ;accel/tcg/user-exec.c +3
-3@@ -186,7 +186,7 @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info,clear_helper_retaddr (); cc =CPU_GET_CLASS (cpu); - cc->tlb_fill (cpu, address,0 , access_type,MMU_USER_IDX , false, pc); + cc->tcg_ops.tlb_fill (cpu, address,0 , access_type,MMU_USER_IDX , false, pc);g_assert_not_reached (); }@@ -216,8 +216,8 @@ static int probe_access_internal(CPUArchState *env, target_ulong addr, }else {CPUState *cpu =env_cpu (env);CPUClass *cc =CPU_GET_CLASS (cpu); - cc->tlb_fill (cpu, addr, fault_size, access_type, -MMU_USER_IDX , false, ra); + cc->tcg_ops.tlb_fill (cpu, addr, fault_size, access_type, +MMU_USER_IDX , false, ra);g_assert_not_reached (); } }include/hw/core/cpu.h +0
-9@@ -110,12 +110,6 @@ struct TranslationBlock;* If the target behaviour here is anything other than "set * the PC register to the value passed in" then the target must * also implement the synchronize_from_tb hook. -* @tlb_fill: Callback for handling a softmmu tlb miss or user-only -* address fault. For system mode, if the access is valid, call -* tlb_set_page and return true; if the access is invalid, and -* probe is true, return false; otherwise raise an exception and -* do not return. For user-only mode, always raise an exception -* and do not return. * @get_phys_page_debug: Callback for obtaining a physical address. * @get_phys_page_attrs_debug: Callback for obtaining a physical address and the * associated memory transaction attributes to use for the access. @@ -183,9 +177,6 @@ struct CPUClass {void (*get_memory_mapping)(CPUState *cpu,MemoryMappingList *list,Error **errp);void (*set_pc)(CPUState *cpu,vaddr value); -bool (*tlb_fill)(CPUState *cpu,vaddr address,int size, -MMUAccessType access_type,int mmu_idx, -bool probe,uintptr_t retaddr);hwaddr (*get_phys_page_debug)(CPUState *cpu,vaddr addr);hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu,vaddr addr,MemTxAttrs *attrs);include/hw/core/tcg-cpu-ops.h +6
-0@@ -37,6 +37,18 @@ typedef struct TcgCpuOperations {void (*cpu_exec_exit)(CPUState *cpu);/** @cpu_exec_interrupt: Callback for processing interrupts in cpu_exec */ bool (*cpu_exec_interrupt)(CPUState *cpu,int interrupt_request); +/** +* @tlb_fill: Handle a softmmu tlb miss or user-only address fault +* +* For system mode, if the access is valid, call tlb_set_page +* and return true; if the access is invalid, and probe is +* true, return false; otherwise raise an exception and do Quoted 8 lines
include/hw/core/tcg-cpu-ops.h typedef struct TcgCpuOperations { · line 51
Quoted 6 lines
include/hw/core/tcg-cpu-ops.h +6
-0+* not return. For user-only mode, always raise an exception +* and do not return. +*/ +bool (*tlb_fill)(CPUState *cpu,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr);As per previous patch, here is a chance to clean-up the comment.
Quoted 2 lines
Could you provide the text? I think you understand this better than I do...
As Eduardo pointed out the kernel-doc pass won't work with in-line functions unless they are extracted and typedefed which seems excessive considering we don't currently generate docs from these headers. Ignore the request.
Quoted 11 lines
Quoted 7 lines
Otherwise:
Reviewed-by Alex Bennée <[email protected]>Thanks!
Claudio
Signature · 1 line
Alex Bennée
RFC v9 21/32 cpu: Move debug_excp_handler to tcg_ops
In reply to Claudio FontanaFrom: Eduardo Habkost <[email protected]>
--- accel/tcg/cpu-exec.c | 4 ++-- include/hw/core/cpu.h | 2 -- include/hw/core/tcg-cpu-ops.h | 2 ++ target/arm/cpu.c | 2 +- target/i386/tcg-cpu.c | 2 +- target/lm32/cpu.c | 2 +- target/s390x/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-)
accel/tcg/cpu-exec.c +2 -2
@@ -482,8 +482,8 @@ static inline void cpu_handle_debug_exception(CPUState *cpu) } } -if (cc->debug_excp_handler) { - cc->debug_excp_handler (cpu); +if (cc->tcg_ops.debug_excp_handler) { + cc->tcg_ops.debug_excp_handler (cpu); } }
include/hw/core/cpu.h +0 -2
@@ -121,7 +121,6 @@ struct TranslationBlock;* @gdb_write_register: Callback for letting GDB write a register. * @debug_check_watchpoint: Callback: return true if the architectural * watchpoint whose address has matched should really fire. -* @debug_excp_handler: Callback for handling debug exceptions. * @write_elf64_note: Callback for writing a CPU-specific ELF note to a * 64-bit VM coredump. * @write_elf32_qemunote: Callback for writing a CPU- and QEMU-specific ELF
@@ -184,7 +183,6 @@ struct CPUClass {int (*gdb_read_register)(CPUState *cpu,GByteArray *buf,int reg);int (*gdb_write_register)(CPUState *cpu,uint8_t *buf,int reg);bool (*debug_check_watchpoint)(CPUState *cpu,CPUWatchpoint *wp); -void (*debug_excp_handler)(CPUState *cpu);int (*write_elf64_note)(WriteCoreDumpFunction f,CPUState *cpu,int cpuid,void *opaque);
include/hw/core/tcg-cpu-ops.h +2 -0
@@ -49,6 +49,8 @@ typedef struct TcgCpuOperations {bool (*tlb_fill)(CPUState *cpu,vaddr address,int size,MMUAccessType access_type,int mmu_idx,bool probe,uintptr_t retaddr); +/** @debug_excp_handler: Callback for handling debug exceptions */ + void (*debug_excp_handler)(CPUState *cpu); } TcgCpuOperations;#endif /* TCG_CPU_OPS_H */
target/arm/cpu.c +1 -1
@@ -2263,7 +2263,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->tcg_ops.cpu_exec_interrupt = arm_cpu_exec_interrupt; cc->tcg_ops.synchronize_from_tb = arm_cpu_synchronize_from_tb; cc->tcg_ops.tlb_fill = arm_cpu_tlb_fill; - cc->debug_excp_handler = arm_debug_excp_handler; + cc->tcg_ops.debug_excp_handler = arm_debug_excp_handler; cc->debug_check_watchpoint = arm_debug_check_watchpoint; cc->do_unaligned_access = arm_cpu_do_unaligned_access;#if !defined(CONFIG_USER_ONLY )
target/i386/tcg-cpu.c +1 -1
@@ -66,6 +66,6 @@ void tcg_cpu_common_class_init(CPUClass *cc) cc->tcg_ops.initialize = tcg_x86_init; cc->tcg_ops.tlb_fill = x86_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY - cc->debug_excp_handler = breakpoint_handler; + cc->tcg_ops.debug_excp_handler = breakpoint_handler;#endif }
target/lm32/cpu.c +1 -1
@@ -235,7 +235,7 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data)#endif cc->gdb_num_core_regs =32 +7 ; cc->gdb_stop_before_watchpoint = true; - cc->debug_excp_handler = lm32_debug_excp_handler; + cc->tcg_ops.debug_excp_handler = lm32_debug_excp_handler; cc->disas_set_info = lm32_cpu_disas_set_info; cc->tcg_ops.initialize = lm32_translate_init; }
target/s390x/cpu.c +1 -1
@@ -506,7 +506,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->write_elf64_note = s390_cpu_write_elf64_note;#ifdef CONFIG_TCG cc->tcg_ops.cpu_exec_interrupt = s390_cpu_exec_interrupt; - cc->debug_excp_handler = s390x_cpu_debug_excp_handler; + cc->tcg_ops.debug_excp_handler = s390x_cpu_debug_excp_handler; cc->do_unaligned_access = s390x_cpu_do_unaligned_access;#endif #endif
target/xtensa/cpu.c +1 -1
@@ -207,7 +207,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data) cc->get_phys_page_debug = xtensa_cpu_get_phys_page_debug; cc->do_transaction_failed = xtensa_cpu_do_transaction_failed;#endif - cc->debug_excp_handler = xtensa_breakpoint_handler; + cc->tcg_ops.debug_excp_handler = xtensa_breakpoint_handler; cc->disas_set_info = xtensa_cpu_disas_set_info; cc->tcg_ops.initialize = xtensa_translate_init; dc->vmsd = &vmstate_xtensa_cpu;
Signature · 1 line
2.26.2
Re: [RFC v9 21/32] cpu: Move debug_excp_handler to tcg_ops
Quoted 4 lines · Claudio Fontana
From: Eduardo Habkost <[email protected]>
Signed-off-by Eduardo Habkost <[email protected]>Signed-off-by Claudio Fontana <[email protected]>
Signature · 1 line
Alex Bennée
RFC v9 22/32 target/arm: do not use cc->do_interrupt for KVM directly
In reply to Claudio Fontanacc->do_interrupt is in theory a TCG callback used in accel/tcg only, to prepare the emulated architecture to take an interrupt as defined in the hardware specifications,
but in reality the _do_interrupt style of functions in targets are also occasionally reused by KVM to prepare the architecture state in a similar way where userspace code has identified that it needs to deliver an exception to the guest.
In the case of ARM, that includes:
1) the vcpu thread got a SIGBUS indicating a memory error, and we need to deliver a Synchronous External Abort to the guest to let it know about the error.
2) the kernel told us about a debug exception (breakpoint, watchpoint) but it is not for one of QEMU's own gdbstub breakpoints/watchpoints so it must be a breakpoint the guest itself has set up, therefore we need to deliver it to the guest.
So in order to reuse code, the same arm_do_interrupt function is used. This is all fine, but we need to avoid calling it using the callback registered in CPUClass, since that one is now TCG-only.
Fortunately this is easily solved by replacing calls to CPUClass::do_interrupt() with explicit calls to arm_do_interrupt().
--- target/arm/helper.c | 4 ++++ target/arm/kvm64.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-)
target/arm/helper.c +4 -0
@@ -9895,6 +9895,10 @@ static void handle_semihosting(CPUState *cs)* Do any appropriate logging, handle PSCI calls, and then hand off * to the AArch64-entry or AArch32-entry function depending on the * target exception level's register width. +* +* Note: this is used for both TCG (as the do_interrupt tcg op), +* and KVM to re-inject guest debug exceptions, and to +* inject a Synchronous-External-Abort. */ void arm_cpu_do_interrupt (CPUState *cs) {
target/arm/kvm64.c +2 -2
@@ -960,7 +960,7 @@ static void kvm_inject_arm_sea(CPUState *c) env->exception.syndrome = esr; - cc->do_interrupt (c); +arm_cpu_do_interrupt (c); }#define AARCH64_CORE_REG (x) (KVM_REG_ARM64 | KVM_REG_SIZE_U64 | \
@@ -1545,7 +1545,7 @@ bool kvm_arm_handle_debug(CPUState *cs, struct kvm_debug_exit_arch *debug_exit) env->exception.vaddress = debug_exit->far; env->exception.target_el =1 ;qemu_mutex_lock_iothread (); - cc->do_interrupt (cs); +arm_cpu_do_interrupt (cs);qemu_mutex_unlock_iothread ();return false;
Signature · 1 line
2.26.2
Re: [RFC v9 22/32] target/arm: do not use cc->do_interrupt for KVM directly
Quoted 19 lines · Claudio Fontana
cc->do_interruptis in theory a TCG callback used in accel/tcg only, to prepare the emulated architecture to take an interrupt as defined in the hardware specifications,but in reality the
_do_interruptstyle of functions in targets are also occasionally reused by KVM to prepare the architecture state in a similar way where userspace code has identified that it needs to deliver an exception to the guest.In the case of ARM, that includes:
1) the vcpu thread got a SIGBUS indicating a memory error, and we need to deliver a Synchronous External Abort to the guest to let it know about the error.
2) the kernel told us about a debug exception (breakpoint, watchpoint) but it is not for one of QEMU's own gdbstub breakpoints/watchpoints so it must be a breakpoint the guest itself has set up, therefore we need to deliver it to the guest.
Quoted 6 lines
So in order to reuse code, the same
arm_do_interruptfunction is used. This is all fine, but we need to avoid calling it using the callback registered in CPUClass, since that one is now TCG-only.Fortunately this is easily solved by replacing calls to
CPUClass::do_interrupt()with explicit calls toarm_do_interrupt().
My ultra-modern gcc10 gentoo box is quick to point out:
64.c.o -c ../../target/arm/kvm64.c
../../target/arm/kvm64.c: In function ‘kvm_inject_arm_sea’:
../../target/arm/kvm64.c:947:15: error: unused variable ‘cc’ [-Werror=unused-variable]
947 | CPUClass *cc = CPU_GET_CLASS(c);
| ^~ ../../target/arm/kvm64.c: In function ‘kvm_arm_handle_debug’:
../../target/arm/kvm64.c:1494:15: error: unused variable ‘cc’ [-Werror=unused-variable]
1494 | CPUClass *cc = CPU_GET_CLASS(cs);
| ^~
cc1: all warnings being treated as errors
Quoted 47 lines
Signed-off-by Claudio Fontana <[email protected]>Cc Peter Maydell <[email protected]>Reviewed-by Alex Bennée <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/helper.c | 4 ++++ target/arm/kvm64.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-)target/arm/helper.c +4
-0@@ -9895,6 +9895,10 @@ static void handle_semihosting(CPUState *cs)* Do any appropriate logging, handle PSCI calls, and then hand off * to the AArch64-entry or AArch32-entry function depending on the * target exception level's register width. +* +* Note: this is used for both TCG (as the do_interrupt tcg op), +* and KVM to re-inject guest debug exceptions, and to +* inject a Synchronous-External-Abort. */ void arm_cpu_do_interrupt (CPUState *cs) {target/arm/kvm64.c +2
-2@@ -960,7 +960,7 @@ static void kvm_inject_arm_sea(CPUState *c) env->exception.syndrome = esr; - cc->do_interrupt (c); +arm_cpu_do_interrupt (c); }#define AARCH64_CORE_REG (x) (KVM_REG_ARM64 | KVM_REG_SIZE_U64 | \@@ -1545,7 +1545,7 @@ bool kvm_arm_handle_debug(CPUState *cs, struct kvm_debug_exit_arch *debug_exit) env->exception.vaddress = debug_exit->far; env->exception.target_el =1 ;qemu_mutex_lock_iothread (); - cc->do_interrupt (cs); +arm_cpu_do_interrupt (cs);qemu_mutex_unlock_iothread ();return false;
Signature · 1 line
Alex Bennée
RFC v9 23/32 cpu: move cc->do_interrupt to tcg_ops
In reply to Claudio Fontana--- accel/tcg/cpu-exec.c | 4 ++-- include/hw/core/cpu.h | 2 -- include/hw/core/tcg-cpu-ops.h | 3 +++ target/alpha/cpu.c | 2 +- target/arm/cpu.c | 6 ++++-- target/arm/cpu_tcg.c | 9 ++++----- target/avr/cpu.c | 2 +- target/avr/helper.c | 4 ++-- target/cris/cpu.c | 12 ++++++------ target/cris/helper.c | 4 ++-- target/hppa/cpu.c | 2 +- target/i386/tcg-cpu.c | 2 +- target/lm32/cpu.c | 2 +- target/m68k/cpu.c | 2 +- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 6 ++++-- target/moxie/cpu.c | 2 +- target/nios2/cpu.c | 2 +- target/openrisc/cpu.c | 2 +- target/ppc/translate_init.c.inc | 2 +- target/riscv/cpu.c | 2 +- target/rx/cpu.c | 2 +- target/s390x/cpu.c | 2 +- target/sh4/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/tilegx/cpu.c | 2 +- target/unicore32/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- 28 files changed, 46 insertions(+), 42 deletions(-)
accel/tcg/cpu-exec.c +2 -2
@@ -517,7 +517,7 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret)loop */ #if defined(TARGET_I386 )CPUClass *cc =CPU_GET_CLASS (cpu); - cc->do_interrupt (cpu); + cc->tcg_ops.do_interrupt (cpu);#endif *ret = cpu->exception_index; cpu->exception_index =-1 ;
@@ -526,7 +526,7 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret)if (replay_exception ()) {CPUClass *cc =CPU_GET_CLASS (cpu);qemu_mutex_lock_iothread (); - cc->do_interrupt (cpu); + cc->tcg_ops.do_interrupt (cpu);qemu_mutex_unlock_iothread (); cpu->exception_index =-1 ;
include/hw/core/cpu.h +0 -2
@@ -87,7 +87,6 @@ struct TranslationBlock;* @parse_features: Callback to parse command line arguments. * @reset_dump_flags: #CPUDumpFlags to use for reset logging. * @has_work: Callback for checking if there is work to do. -* @do_interrupt: Callback for interrupt handling. * @do_unaligned_access: Callback for unaligned access handling, if * the target defines #TARGET_ALIGNED_ONLY. * @do_transaction_failed: Callback for handling failed memory transactions
@@ -157,7 +156,6 @@ struct CPUClass {int reset_dump_flags;bool (*has_work)(CPUState *cpu); -void (*do_interrupt)(CPUState *cpu);void (*do_unaligned_access)(CPUState *cpu,vaddr addr,MMUAccessType access_type,int mmu_idx,uintptr_t retaddr);
include/hw/core/tcg-cpu-ops.h +3 -0
@@ -37,6 +37,9 @@ typedef struct TcgCpuOperations {void (*cpu_exec_exit)(CPUState *cpu);/** @cpu_exec_interrupt: Callback for processing interrupts in cpu_exec */ bool (*cpu_exec_interrupt)(CPUState *cpu,int interrupt_request); +/** @do_interrupt: Callback for interrupt handling. */ +void (*do_interrupt)(CPUState *cpu); +/** * @tlb_fill: Handle a softmmu tlb miss or user-only address fault *
target/alpha/cpu.c +1 -1
@@ -217,7 +217,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = alpha_cpu_class_by_name; cc->has_work = alpha_cpu_has_work; - cc->do_interrupt = alpha_cpu_do_interrupt; + cc->tcg_ops.do_interrupt = alpha_cpu_do_interrupt; cc->dump_state = alpha_cpu_dump_state; cc->set_pc = alpha_cpu_set_pc; cc->gdb_read_register = alpha_cpu_gdb_read_register;
target/arm/cpu.c +4 -2
@@ -535,6 +535,7 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,return unmasked || pstate_unmasked; } +#ifdef CONFIG_TCG bool arm_cpu_exec_interrupt (CPUState *cs,int interrupt_request) {CPUClass *cc =CPU_GET_CLASS (cs);
@@ -584,9 +585,10 @@ bool arm_cpu_exec_interrupt(CPUState *cs, int interrupt_request) found: cs->exception_index = excp_idx; env->exception.target_el = target_el; - cc->do_interrupt (cs); + cc->tcg_ops.do_interrupt (cs); return true; } +#endif /* CONFIG_TCG */ void arm_cpu_update_virq (ARMCPU *cpu) {
@@ -2244,7 +2246,6 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_read_register = arm_cpu_gdb_read_register; cc->gdb_write_register = arm_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY - cc->do_interrupt = arm_cpu_do_interrupt; cc->get_phys_page_attrs_debug = arm_cpu_get_phys_page_attrs_debug; cc->asidx_from_attrs = arm_asidx_from_attrs; cc->vmsd = &vmstate_arm_cpu;
@@ -2269,6 +2270,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)#if !defined(CONFIG_USER_ONLY ) cc->do_transaction_failed = arm_cpu_do_transaction_failed; cc->adjust_watchpoint_address = arm_adjust_watchpoint_address; + cc->tcg_ops.do_interrupt = arm_cpu_do_interrupt;#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */ #endif }
target/arm/cpu_tcg.c +4 -5
@@ -33,7 +33,7 @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request)if (interrupt_request &CPU_INTERRUPT_HARD && (armv7m_nvic_can_take_pending_exception (env->nvic))) { cs->exception_index =EXCP_IRQ ; - cc->do_interrupt (cs); + cc->tcg_ops.do_interrupt (cs); ret = true; }return ret;
@@ -624,12 +624,11 @@ static void arm_v7m_class_init(ObjectClass *oc, void *data)CPUClass *cc =CPU_CLASS (oc); acc->info = data; -#ifndef CONFIG_USER_ONLY - cc->do_interrupt = arm_v7m_cpu_do_interrupt; -#endif -#ifdef CONFIG_TCG cc->tcg_ops.cpu_exec_interrupt = arm_v7m_cpu_exec_interrupt; +#ifndef CONFIG_USER_ONLY + cc->tcg_ops.do_interrupt = arm_v7m_cpu_do_interrupt; +#endif #endif /* CONFIG_TCG */ cc->gdb_core_xml_file ="arm-m-profile.xml" ;
target/avr/cpu.c +1 -1
@@ -197,7 +197,7 @@ static void avr_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = avr_cpu_class_by_name; cc->has_work = avr_cpu_has_work; - cc->do_interrupt = avr_cpu_do_interrupt; + cc->tcg_ops.do_interrupt = avr_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt = avr_cpu_exec_interrupt; cc->dump_state = avr_cpu_dump_state; cc->set_pc = avr_cpu_set_pc;
target/avr/helper.c +2 -2
@@ -34,7 +34,7 @@ bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_request)if (interrupt_request &CPU_INTERRUPT_RESET ) {if (cpu_interrupts_enabled (env)) { cs->exception_index =EXCP_RESET ; - cc->do_interrupt (cs); + cc->tcg_ops.do_interrupt (cs); cs->interrupt_request &= ~CPU_INTERRUPT_RESET ;
@@ -45,7 +45,7 @@ bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_request)if (cpu_interrupts_enabled (env) && env->intsrc !=0 ) {int index =ctz32 (env->intsrc); cs->exception_index =EXCP_INT (index); - cc->do_interrupt (cs); + cc->tcg_ops.do_interrupt (cs); env->intsrc &= env->intsrc -1 ;/* clear the interrupt */ cs->interrupt_request &= ~CPU_INTERRUPT_HARD ;
target/cris/cpu.c +6 -6
@@ -199,7 +199,7 @@ static void crisv8_cpu_class_init(ObjectClass *oc, void *data)CRISCPUClass *ccc =CRIS_CPU_CLASS (oc); ccc->vr =8 ; - cc->do_interrupt = crisv10_cpu_do_interrupt; + cc->tcg_ops.do_interrupt = crisv10_cpu_do_interrupt; cc->gdb_read_register = crisv10_cpu_gdb_read_register; cc->tcg_ops.initialize = cris_initialize_crisv10_tcg; }
@@ -210,7 +210,7 @@ static void crisv9_cpu_class_init(ObjectClass *oc, void *data)CRISCPUClass *ccc =CRIS_CPU_CLASS (oc); ccc->vr =9 ; - cc->do_interrupt = crisv10_cpu_do_interrupt; + cc->tcg_ops.do_interrupt = crisv10_cpu_do_interrupt; cc->gdb_read_register = crisv10_cpu_gdb_read_register; cc->tcg_ops.initialize = cris_initialize_crisv10_tcg; }
@@ -221,7 +221,7 @@ static void crisv10_cpu_class_init(ObjectClass *oc, void *data)CRISCPUClass *ccc =CRIS_CPU_CLASS (oc); ccc->vr =10 ; - cc->do_interrupt = crisv10_cpu_do_interrupt; + cc->tcg_ops.do_interrupt = crisv10_cpu_do_interrupt; cc->gdb_read_register = crisv10_cpu_gdb_read_register; cc->tcg_ops.initialize = cris_initialize_crisv10_tcg; }
@@ -232,7 +232,7 @@ static void crisv11_cpu_class_init(ObjectClass *oc, void *data)CRISCPUClass *ccc =CRIS_CPU_CLASS (oc); ccc->vr =11 ; - cc->do_interrupt = crisv10_cpu_do_interrupt; + cc->tcg_ops.do_interrupt = crisv10_cpu_do_interrupt; cc->gdb_read_register = crisv10_cpu_gdb_read_register; cc->tcg_ops.initialize = cris_initialize_crisv10_tcg; }
@@ -243,7 +243,7 @@ static void crisv17_cpu_class_init(ObjectClass *oc, void *data)CRISCPUClass *ccc =CRIS_CPU_CLASS (oc); ccc->vr =17 ; - cc->do_interrupt = crisv10_cpu_do_interrupt; + cc->tcg_ops.do_interrupt = crisv10_cpu_do_interrupt; cc->gdb_read_register = crisv10_cpu_gdb_read_register; cc->tcg_ops.initialize = cris_initialize_crisv10_tcg; }
@@ -268,7 +268,7 @@ static void cris_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = cris_cpu_class_by_name; cc->has_work = cris_cpu_has_work; - cc->do_interrupt = cris_cpu_do_interrupt; + cc->tcg_ops.do_interrupt = cris_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt = cris_cpu_exec_interrupt; cc->dump_state = cris_cpu_dump_state; cc->set_pc = cris_cpu_set_pc;
target/cris/helper.c +2 -2
@@ -299,7 +299,7 @@ bool cris_cpu_exec_interrupt(CPUState *cs, int interrupt_request) && (env->pregs[PR_CCS] & I_FLAG) && !env->locked_irq) { cs->exception_index =EXCP_IRQ ; - cc->do_interrupt (cs); + cc->tcg_ops.do_interrupt (cs); ret = true; }if (interrupt_request &CPU_INTERRUPT_NMI ) {
@@ -311,7 +311,7 @@ bool cris_cpu_exec_interrupt(CPUState *cs, int interrupt_request) }if ((env->pregs[PR_CCS ] & m_flag_archval)) { cs->exception_index =EXCP_NMI ; - cc->do_interrupt (cs); + cc->tcg_ops.do_interrupt (cs); ret = true; } }
target/hppa/cpu.c +1 -1
@@ -139,7 +139,7 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = hppa_cpu_class_by_name; cc->has_work = hppa_cpu_has_work; - cc->do_interrupt = hppa_cpu_do_interrupt; + cc->tcg_ops.do_interrupt = hppa_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt = hppa_cpu_exec_interrupt; cc->dump_state = hppa_cpu_dump_state; cc->set_pc = hppa_cpu_set_pc;
target/i386/tcg-cpu.c +1 -1
@@ -58,7 +58,7 @@ static void x86_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb)void tcg_cpu_common_class_init (CPUClass *cc) { - cc->do_interrupt = x86_cpu_do_interrupt; + cc->tcg_ops.do_interrupt = x86_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt = x86_cpu_exec_interrupt; cc->tcg_ops.synchronize_from_tb = x86_cpu_synchronize_from_tb; cc->tcg_ops.cpu_exec_enter = x86_cpu_exec_enter;
target/lm32/cpu.c +1 -1
@@ -222,7 +222,7 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = lm32_cpu_class_by_name; cc->has_work = lm32_cpu_has_work; - cc->do_interrupt = lm32_cpu_do_interrupt; + cc->tcg_ops.do_interrupt = lm32_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt = lm32_cpu_exec_interrupt; cc->dump_state = lm32_cpu_dump_state; cc->set_pc = lm32_cpu_set_pc;
target/m68k/cpu.c +1 -1
@@ -277,7 +277,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) cc->class_by_name = m68k_cpu_class_by_name; cc->has_work = m68k_cpu_has_work; - cc->do_interrupt = m68k_cpu_do_interrupt; + cc->tcg_ops.do_interrupt = m68k_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt = m68k_cpu_exec_interrupt; cc->dump_state = m68k_cpu_dump_state; cc->set_pc = m68k_cpu_set_pc;
target/microblaze/cpu.c +1 -1
@@ -317,7 +317,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = mb_cpu_class_by_name; cc->has_work = mb_cpu_has_work; - cc->do_interrupt = mb_cpu_do_interrupt; + cc->tcg_ops.do_interrupt = mb_cpu_do_interrupt; cc->do_unaligned_access = mb_cpu_do_unaligned_access; cc->tcg_ops.cpu_exec_interrupt = mb_cpu_exec_interrupt; cc->dump_state = mb_cpu_dump_state;
target/mips/cpu.c +4 -2
@@ -234,7 +234,6 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->class_by_name = mips_cpu_class_by_name; cc->has_work = mips_cpu_has_work; - cc->do_interrupt = mips_cpu_do_interrupt; cc->dump_state = mips_cpu_dump_state; cc->set_pc = mips_cpu_set_pc; cc->gdb_read_register = mips_cpu_gdb_read_register;
@@ -251,7 +250,10 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->tcg_ops.cpu_exec_interrupt = mips_cpu_exec_interrupt; cc->tcg_ops.synchronize_from_tb = mips_cpu_synchronize_from_tb; cc->tcg_ops.tlb_fill = mips_cpu_tlb_fill; -#endif +#ifndef CONFIG_USER_ONLY + cc->tcg_ops.do_interrupt = mips_cpu_do_interrupt; +#endif /* CONFIG_USER_ONLY */ +#endif /* CONFIG_TCG */ cc->gdb_num_core_regs =73 ; cc->gdb_stop_before_watchpoint = true;
target/moxie/cpu.c +1 -1
@@ -107,7 +107,7 @@ static void moxie_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = moxie_cpu_class_by_name; cc->has_work = moxie_cpu_has_work; - cc->do_interrupt = moxie_cpu_do_interrupt; + cc->tcg_ops.do_interrupt = moxie_cpu_do_interrupt; cc->dump_state = moxie_cpu_dump_state; cc->set_pc = moxie_cpu_set_pc; cc->tcg_ops.tlb_fill = moxie_cpu_tlb_fill;
target/nios2/cpu.c +1 -1
@@ -192,7 +192,7 @@ static void nios2_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = nios2_cpu_class_by_name; cc->has_work = nios2_cpu_has_work; - cc->do_interrupt = nios2_cpu_do_interrupt; + cc->tcg_ops.do_interrupt = nios2_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt = nios2_cpu_exec_interrupt; cc->dump_state = nios2_cpu_dump_state; cc->set_pc = nios2_cpu_set_pc;
target/openrisc/cpu.c +1 -1
@@ -154,7 +154,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = openrisc_cpu_class_by_name; cc->has_work = openrisc_cpu_has_work; - cc->do_interrupt = openrisc_cpu_do_interrupt; + cc->tcg_ops.do_interrupt = openrisc_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt = openrisc_cpu_exec_interrupt; cc->dump_state = openrisc_cpu_dump_state; cc->set_pc = openrisc_cpu_set_pc;
target/ppc/translate_init.c.inc +1 -1
@@ -10908,7 +10908,6 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) pcc->parent_parse_features = cc->parse_features; cc->parse_features = ppc_cpu_parse_featurestr; cc->has_work = ppc_cpu_has_work; - cc->do_interrupt = ppc_cpu_do_interrupt; cc->dump_state = ppc_cpu_dump_state; cc->dump_statistics = ppc_cpu_dump_statistics; cc->set_pc = ppc_cpu_set_pc;
@@ -10946,6 +10945,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) #ifdef CONFIG_TCG cc->tcg_ops.initialize = ppc_translate_init; cc->tcg_ops.cpu_exec_interrupt = ppc_cpu_exec_interrupt; + cc->tcg_ops.do_interrupt = ppc_cpu_do_interrupt; cc->tcg_ops.tlb_fill = ppc_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->tcg_ops.cpu_exec_enter = ppc_cpu_exec_enter;
target/riscv/cpu.c +1 -1
@@ -539,7 +539,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data) cc->class_by_name = riscv_cpu_class_by_name; cc->has_work = riscv_cpu_has_work; - cc->do_interrupt = riscv_cpu_do_interrupt; + cc->tcg_ops.do_interrupt = riscv_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt = riscv_cpu_exec_interrupt; cc->dump_state = riscv_cpu_dump_state; cc->set_pc = riscv_cpu_set_pc;
target/rx/cpu.c +1 -1
@@ -185,7 +185,7 @@ static void rx_cpu_class_init(ObjectClass *klass, void *data) cc->class_by_name = rx_cpu_class_by_name; cc->has_work = rx_cpu_has_work; - cc->do_interrupt = rx_cpu_do_interrupt; + cc->tcg_ops.do_interrupt = rx_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt = rx_cpu_exec_interrupt; cc->dump_state = rx_cpu_dump_state; cc->set_pc = rx_cpu_set_pc;
target/s390x/cpu.c +1 -1
@@ -493,7 +493,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = s390_cpu_class_by_name, cc->has_work = s390_cpu_has_work;#ifdef CONFIG_TCG - cc->do_interrupt = s390_cpu_do_interrupt; + cc->tcg_ops.do_interrupt = s390_cpu_do_interrupt;#endif cc->dump_state = s390_cpu_dump_state; cc->set_pc = s390_cpu_set_pc;
target/sh4/cpu.c +1 -1
@@ -218,7 +218,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = superh_cpu_class_by_name; cc->has_work = superh_cpu_has_work; - cc->do_interrupt = superh_cpu_do_interrupt; + cc->tcg_ops.do_interrupt = superh_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt = superh_cpu_exec_interrupt; cc->dump_state = superh_cpu_dump_state; cc->set_pc = superh_cpu_set_pc;
target/sparc/cpu.c +1 -1
@@ -861,7 +861,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = sparc_cpu_class_by_name; cc->parse_features = sparc_cpu_parse_features; cc->has_work = sparc_cpu_has_work; - cc->do_interrupt = sparc_cpu_do_interrupt; + cc->tcg_ops.do_interrupt = sparc_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt = sparc_cpu_exec_interrupt; cc->dump_state = sparc_cpu_dump_state;#if !defined(TARGET_SPARC64 ) && !defined(CONFIG_USER_ONLY )
target/tilegx/cpu.c +1 -1
@@ -147,7 +147,7 @@ static void tilegx_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = tilegx_cpu_class_by_name; cc->has_work = tilegx_cpu_has_work; - cc->do_interrupt = tilegx_cpu_do_interrupt; + cc->tcg_ops.do_interrupt = tilegx_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt = tilegx_cpu_exec_interrupt; cc->dump_state = tilegx_cpu_dump_state; cc->set_pc = tilegx_cpu_set_pc;
target/unicore32/cpu.c +1 -1
@@ -131,7 +131,7 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = uc32_cpu_class_by_name; cc->has_work = uc32_cpu_has_work; - cc->do_interrupt = uc32_cpu_do_interrupt; + cc->tcg_ops.do_interrupt = uc32_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt = uc32_cpu_exec_interrupt; cc->dump_state = uc32_cpu_dump_state; cc->set_pc = uc32_cpu_set_pc;
target/xtensa/cpu.c +1 -1
@@ -194,7 +194,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = xtensa_cpu_class_by_name; cc->has_work = xtensa_cpu_has_work; - cc->do_interrupt = xtensa_cpu_do_interrupt; + cc->tcg_ops.do_interrupt = xtensa_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt = xtensa_cpu_exec_interrupt; cc->dump_state = xtensa_cpu_dump_state; cc->set_pc = xtensa_cpu_set_pc;
Signature · 1 line
2.26.2
Re: [RFC v9 23/32] cpu: move cc->do_interrupt to tcg_ops
Quoted 1 line · Claudio Fontana
Signed-off-by Claudio Fontana <[email protected]>
Signature · 1 line
Alex Bennée
RFC v9 24/32 cpu: move cc->transaction_failed to tcg_ops
In reply to Claudio Fontana--- hw/mips/jazz.c | 4 ++-- include/hw/core/cpu.h | 18 +++++++----------- include/hw/core/tcg-cpu-ops.h | 9 +++++++++ target/alpha/cpu.c | 2 +- target/arm/cpu.c | 4 ++-- target/m68k/cpu.c | 2 +- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 2 +- target/riscv/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- 11 files changed, 27 insertions(+), 22 deletions(-)
hw/mips/jazz.c +2 -2
@@ -204,8 +204,8 @@ static void mips_jazz_init(MachineState *machine,* memory region that catches all memory accesses, as we do on Malta. */ cc =CPU_GET_CLASS (cpu); - real_do_transaction_failed = cc->do_transaction_failed; - cc->do_transaction_failed = mips_jazz_do_transaction_failed; + real_do_transaction_failed = cc->tcg_ops.do_transaction_failed; + cc->tcg_ops.do_transaction_failed = mips_jazz_do_transaction_failed;/* allocate RAM */ memory_region_add_subregion (address_space,0 , machine->ram);
include/hw/core/cpu.h +7 -11
@@ -89,8 +89,6 @@ struct TranslationBlock;* @has_work: Callback for checking if there is work to do. * @do_unaligned_access: Callback for unaligned access handling, if * the target defines #TARGET_ALIGNED_ONLY. -* @do_transaction_failed: Callback for handling failed memory transactions -* (ie bus faults or external aborts; not MMU faults) * @virtio_is_big_endian: Callback to return %true if a CPU which supports * runtime configurable endianness is currently big-endian. Non-configurable * CPUs can use the default implementation of this method. This method should
@@ -159,10 +157,6 @@ struct CPUClass {void (*do_unaligned_access)(CPUState *cpu,vaddr addr,MMUAccessType access_type,int mmu_idx,uintptr_t retaddr); -void (*do_transaction_failed)(CPUState *cpu,hwaddr physaddr,vaddr addr, -unsigned size,MMUAccessType access_type, -int mmu_idx,MemTxAttrs attrs, -MemTxResult response,uintptr_t retaddr);bool (*virtio_is_big_endian)(CPUState *cpu);int (*memory_rw_debug)(CPUState *cpu,vaddr addr,uint8_t *buf,int len,bool is_write);
@@ -848,7 +842,7 @@ static inline void cpu_unaligned_access(CPUState *cpu, vaddr addr, cc->do_unaligned_access (cpu, addr, access_type, mmu_idx, retaddr); } - +#ifdef CONFIG_TCG static inline void cpu_transaction_failed(CPUState *cpu, hwaddr physaddr, vaddr addr, unsigned size, MMUAccessType access_type,
@@ -858,12 +852,14 @@ static inline void cpu_transaction_failed(CPUState *cpu, hwaddr physaddr, {CPUClass *cc =CPU_GET_CLASS (cpu); -if (!cpu->ignore_memory_transaction_failures && cc->do_transaction_failed) { - cc->do_transaction_failed (cpu, physaddr, addr, size, access_type, - mmu_idx, attrs, response, retaddr); +if (!cpu->ignore_memory_transaction_failures && + cc->tcg_ops.do_transaction_failed) { + cc->tcg_ops.do_transaction_failed (cpu, physaddr, addr, size, access_type, + mmu_idx, attrs, response, retaddr); } } -#endif +#endif /* CONFIG_TCG */ +#endif /* CONFIG_SOFTMMU */ #endif /* NEED_CPU_H */
include/hw/core/tcg-cpu-ops.h +9 -0
@@ -40,6 +40,15 @@ typedef struct TcgCpuOperations {/** @do_interrupt: Callback for interrupt handling. */ void (*do_interrupt)(CPUState *cpu); +/** +* @do_transaction_failed: Callback for handling failed memory transactions +* (ie bus faults or external aborts; not MMU faults) +*/ +void (*do_transaction_failed)(CPUState *cpu,hwaddr physaddr,vaddr addr, +unsigned size,MMUAccessType access_type, +int mmu_idx,MemTxAttrs attrs, +MemTxResult response,uintptr_t retaddr); +/** * @tlb_fill: Handle a softmmu tlb miss or user-only address fault *
target/alpha/cpu.c +1 -1
@@ -224,7 +224,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = alpha_cpu_gdb_write_register; cc->tcg_ops.tlb_fill = alpha_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY - cc->do_transaction_failed = alpha_cpu_do_transaction_failed; + cc->tcg_ops.do_transaction_failed = alpha_cpu_do_transaction_failed; cc->do_unaligned_access = alpha_cpu_do_unaligned_access; cc->get_phys_page_debug = alpha_cpu_get_phys_page_debug; dc->vmsd = &vmstate_alpha_cpu;
target/arm/cpu.c +2 -2
@@ -2268,11 +2268,11 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->debug_check_watchpoint = arm_debug_check_watchpoint; cc->do_unaligned_access = arm_cpu_do_unaligned_access;#if !defined(CONFIG_USER_ONLY ) - cc->do_transaction_failed = arm_cpu_do_transaction_failed; + cc->tcg_ops.do_transaction_failed = arm_cpu_do_transaction_failed; cc->adjust_watchpoint_address = arm_adjust_watchpoint_address; cc->tcg_ops.do_interrupt = arm_cpu_do_interrupt;#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */ -#endif +#endif /* CONFIG_TCG */ }#ifdef CONFIG_KVM
target/m68k/cpu.c +1 -1
@@ -285,7 +285,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) cc->gdb_write_register = m68k_cpu_gdb_write_register; cc->tcg_ops.tlb_fill = m68k_cpu_tlb_fill;#if defined(CONFIG_SOFTMMU ) - cc->do_transaction_failed = m68k_cpu_transaction_failed; + cc->tcg_ops.do_transaction_failed = m68k_cpu_transaction_failed; cc->get_phys_page_debug = m68k_cpu_get_phys_page_debug;#endif cc->disas_set_info = m68k_cpu_disas_set_info;
target/microblaze/cpu.c +1 -1
@@ -327,7 +327,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = mb_cpu_gdb_write_register; cc->tcg_ops.tlb_fill = mb_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY - cc->do_transaction_failed = mb_cpu_transaction_failed; + cc->tcg_ops.do_transaction_failed = mb_cpu_transaction_failed; cc->get_phys_page_debug = mb_cpu_get_phys_page_debug; dc->vmsd = &vmstate_mb_cpu;#endif
target/mips/cpu.c +1 -1
@@ -239,7 +239,6 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->gdb_read_register = mips_cpu_gdb_read_register; cc->gdb_write_register = mips_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY - cc->do_transaction_failed = mips_cpu_do_transaction_failed; cc->do_unaligned_access = mips_cpu_do_unaligned_access; cc->get_phys_page_debug = mips_cpu_get_phys_page_debug; cc->vmsd = &vmstate_mips_cpu;
@@ -252,6 +251,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->tcg_ops.tlb_fill = mips_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY cc->tcg_ops.do_interrupt = mips_cpu_do_interrupt; + cc->tcg_ops.do_transaction_failed = mips_cpu_do_transaction_failed;#endif /* CONFIG_USER_ONLY */ #endif /* CONFIG_TCG */
target/riscv/cpu.c +1 -1
@@ -555,7 +555,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data) cc->gdb_stop_before_watchpoint = true; cc->disas_set_info = riscv_cpu_disas_set_info;#ifndef CONFIG_USER_ONLY - cc->do_transaction_failed = riscv_cpu_do_transaction_failed; + cc->tcg_ops.do_transaction_failed = riscv_cpu_do_transaction_failed; cc->do_unaligned_access = riscv_cpu_do_unaligned_access; cc->get_phys_page_debug = riscv_cpu_get_phys_page_debug;/* For now, mark unmigratable: */
target/sparc/cpu.c +1 -1
@@ -873,7 +873,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = sparc_cpu_gdb_write_register; cc->tcg_ops.tlb_fill = sparc_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY - cc->do_transaction_failed = sparc_cpu_do_transaction_failed; + cc->tcg_ops.do_transaction_failed = sparc_cpu_do_transaction_failed; cc->do_unaligned_access = sparc_cpu_do_unaligned_access; cc->get_phys_page_debug = sparc_cpu_get_phys_page_debug; cc->vmsd = &vmstate_sparc_cpu;
target/xtensa/cpu.c +1 -1
@@ -205,7 +205,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data)#ifndef CONFIG_USER_ONLY cc->do_unaligned_access = xtensa_cpu_do_unaligned_access; cc->get_phys_page_debug = xtensa_cpu_get_phys_page_debug; - cc->do_transaction_failed = xtensa_cpu_do_transaction_failed; + cc->tcg_ops.do_transaction_failed = xtensa_cpu_do_transaction_failed;#endif cc->tcg_ops.debug_excp_handler = xtensa_breakpoint_handler; cc->disas_set_info = xtensa_cpu_disas_set_info;
Signature · 1 line
2.26.2
Re: [RFC v9 24/32] cpu: move cc->transaction_failed to tcg_ops
Quoted 2 lines · Claudio Fontana
Signed-off-by Claudio Fontana <[email protected]>---
...
include/hw/core/tcg-cpu-ops.h
Quoted 4 lines
include/hw/core/tcg-cpu-ops.h +0
-0
Missing (for MemTxAttrs/MemTxResult):
#include "exec/memattrs.h"
Quoted 13 lines
include/hw/core/tcg-cpu-ops.h +9
-0@@ -40,6 +40,15 @@ typedef struct TcgCpuOperations {/** @do_interrupt: Callback for interrupt handling. */ void (*do_interrupt)(CPUState *cpu); +/** +* @do_transaction_failed: Callback for handling failed memory transactions +* (ie bus faults or external aborts; not MMU faults) +*/ +void (*do_transaction_failed)(CPUState *cpu,hwaddr physaddr,vaddr addr, +unsigned size,MMUAccessType access_type, +int mmu_idx,MemTxAttrs attrs, +MemTxResult response,uintptr_t retaddr); +
...
Re: [RFC v9 24/32] cpu: move cc->transaction_failed to tcg_ops
Quoted 4 lines · Philippe Mathieu-Daudé
Quoted 2 lines · Claudio Fontana
Signed-off-by Claudio Fontana <[email protected]>---
...
Quoted 8 lines
include/hw/core/tcg-cpu-ops.h
Quoted 4 lines
include/hw/core/tcg-cpu-ops.h +0
-0Missing (for MemTxAttrs/MemTxResult):
#include "exec/memattrs.h"
right, this is included only from cpu.h though, which already does it, should we still repeat the include here?
Thanks,
Claudio
Quoted 17 lines
Quoted 14 lines
include/hw/core/tcg-cpu-ops.h +9
-0@@ -40,6 +40,15 @@ typedef struct TcgCpuOperations {/** @do_interrupt: Callback for interrupt handling. */ void (*do_interrupt)(CPUState *cpu); +/** +* @do_transaction_failed: Callback for handling failed memory transactions +* (ie bus faults or external aborts; not MMU faults) +*/ +void (*do_transaction_failed)(CPUState *cpu,hwaddr physaddr,vaddr addr, +unsigned size,MMUAccessType access_type, +int mmu_idx,MemTxAttrs attrs, +MemTxResult response,uintptr_t retaddr); +...
Re: [RFC v9 24/32] cpu: move cc->transaction_failed to tcg_ops
Quoted 12 lines · Claudio Fontana
Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 2 lines · Claudio Fontana
Signed-off-by Claudio Fontana <[email protected]>---
...
include/hw/core/tcg-cpu-ops.h
Quoted 4 lines
include/hw/core/tcg-cpu-ops.h +0
-0Missing (for MemTxAttrs/MemTxResult):
Quoted 4 lines
Quoted 1 line
#include "exec/memattrs.h"right, this is included only from
cpu.hthough, which already does it, should we still repeat the include here?
It doesn't hurt, and may save some headache in the future. A .c file should be able to include tcg-cpu-ops.h directly if necessary.
Signature · 1 line
Eduardo
Re: [RFC v9 24/32] cpu: move cc->transaction_failed to tcg_ops
In reply to Claudio FontanaQuoted 1 line · Claudio Fontana
Signed-off-by Claudio Fontana <[email protected]>
Signature · 1 line
Alex Bennée
RFC v9 25/32 cpu: move do_unaligned_access to tcg_ops
In reply to Claudio Fontanamake it consistently SOFTMMU-only.
--- include/hw/core/cpu.h | 17 +++-------------- include/hw/core/tcg-cpu-ops.h | 7 +++++++ target/alpha/cpu.c | 2 +- target/arm/cpu.c | 2 +- target/hppa/cpu.c | 4 +++- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 3 ++- target/nios2/cpu.c | 2 +- target/ppc/translate_init.c.inc | 2 +- target/riscv/cpu.c | 2 +- target/s390x/cpu.c | 2 +- target/sh4/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- 14 files changed, 25 insertions(+), 26 deletions(-)
include/hw/core/cpu.h +3 -14
@@ -87,8 +87,6 @@ struct TranslationBlock;* @parse_features: Callback to parse command line arguments. * @reset_dump_flags: #CPUDumpFlags to use for reset logging. * @has_work: Callback for checking if there is work to do. -* @do_unaligned_access: Callback for unaligned access handling, if -* the target defines #TARGET_ALIGNED_ONLY. * @virtio_is_big_endian: Callback to return %true if a CPU which supports * runtime configurable endianness is currently big-endian. Non-configurable * CPUs can use the default implementation of this method. This method should
@@ -154,9 +152,6 @@ struct CPUClass {int reset_dump_flags;bool (*has_work)(CPUState *cpu); -void (*do_unaligned_access)(CPUState *cpu,vaddr addr, -MMUAccessType access_type, -int mmu_idx,uintptr_t retaddr);bool (*virtio_is_big_endian)(CPUState *cpu);int (*memory_rw_debug)(CPUState *cpu,vaddr addr,uint8_t *buf,int len,bool is_write);
@@ -831,18 +826,15 @@ CPUState *cpu_by_arch_id(int64_t id);void cpu_interrupt (CPUState *cpu,int mask); -#ifdef NEED_CPU_H - -#ifdef CONFIG_SOFTMMU +#if !defined(CONFIG_USER_ONLY ) && defined(CONFIG_TCG )static inline void cpu_unaligned_access (CPUState *cpu,vaddr addr,MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) {CPUClass *cc =CPU_GET_CLASS (cpu); - cc->do_unaligned_access (cpu, addr, access_type, mmu_idx, retaddr); + cc->tcg_ops.do_unaligned_access (cpu, addr, access_type, mmu_idx, retaddr); } -#ifdef CONFIG_TCG static inline void cpu_transaction_failed(CPUState *cpu, hwaddr physaddr, vaddr addr, unsigned size, MMUAccessType access_type,
@@ -858,10 +850,7 @@ static inline void cpu_transaction_failed(CPUState *cpu, hwaddr physaddr, mmu_idx, attrs, response, retaddr); } } -#endif /* CONFIG_TCG */ -#endif /* CONFIG_SOFTMMU */ - -#endif /* NEED_CPU_H */ +#endif /* !CONFIG_USER_ONLY && CONFIG_TCG */ /** * cpu_set_pc:
include/hw/core/tcg-cpu-ops.h +7 -0
@@ -48,6 +48,13 @@ typedef struct TcgCpuOperations { unsigned size, MMUAccessType access_type, int mmu_idx, MemTxAttrs attrs, MemTxResult response, uintptr_t retaddr); +/** +* @do_unaligned_access: Callback for unaligned access handling, if +* the target defines #TARGET_ALIGNED_ONLY. +*/ +void (*do_unaligned_access)(CPUState *cpu,vaddr addr, +MMUAccessType access_type, +int mmu_idx,uintptr_t retaddr);/** * @tlb_fill: Handle a softmmu tlb miss or user-only address fault
target/alpha/cpu.c +1 -1
@@ -225,7 +225,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) cc->tcg_ops.tlb_fill = alpha_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY cc->tcg_ops.do_transaction_failed = alpha_cpu_do_transaction_failed; - cc->do_unaligned_access = alpha_cpu_do_unaligned_access; + cc->tcg_ops.do_unaligned_access = alpha_cpu_do_unaligned_access; cc->get_phys_page_debug = alpha_cpu_get_phys_page_debug; dc->vmsd = &vmstate_alpha_cpu;#endif
target/arm/cpu.c +1 -1
@@ -2266,9 +2266,9 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->tcg_ops.tlb_fill = arm_cpu_tlb_fill; cc->tcg_ops.debug_excp_handler = arm_debug_excp_handler; cc->debug_check_watchpoint = arm_debug_check_watchpoint; - cc->do_unaligned_access = arm_cpu_do_unaligned_access;#if !defined(CONFIG_USER_ONLY ) cc->tcg_ops.do_transaction_failed = arm_cpu_do_transaction_failed; + cc->tcg_ops.do_unaligned_access = arm_cpu_do_unaligned_access; cc->adjust_watchpoint_address = arm_adjust_watchpoint_address; cc->tcg_ops.do_interrupt = arm_cpu_do_interrupt;#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
target/hppa/cpu.c +3 -1
@@ -70,6 +70,7 @@ static void hppa_cpu_disas_set_info(CPUState *cs, disassemble_info *info) info->print_insn = print_insn_hppa; } +#ifndef CONFIG_USER_ONLY static void hppa_cpu_do_unaligned_access (CPUState *cs,vaddr addr,MMUAccessType access_type,int mmu_idx,uintptr_t retaddr)
@@ -86,6 +87,7 @@ static void hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr, cpu_loop_exit_restore(cs, retaddr); } +#endif /* CONFIG_USER_ONLY */ static void hppa_cpu_realizefn (DeviceState *dev,Error **errp) {
@@ -149,9 +151,9 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *data) cc->tcg_ops.tlb_fill = hppa_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = hppa_cpu_get_phys_page_debug; + cc->tcg_ops.do_unaligned_access = hppa_cpu_do_unaligned_access; dc->vmsd = &vmstate_hppa_cpu;#endif - cc->do_unaligned_access = hppa_cpu_do_unaligned_access; cc->disas_set_info = hppa_cpu_disas_set_info; cc->tcg_ops.initialize = hppa_translate_init;
target/microblaze/cpu.c +1 -1
@@ -318,7 +318,6 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = mb_cpu_class_by_name; cc->has_work = mb_cpu_has_work; cc->tcg_ops.do_interrupt = mb_cpu_do_interrupt; - cc->do_unaligned_access = mb_cpu_do_unaligned_access; cc->tcg_ops.cpu_exec_interrupt = mb_cpu_exec_interrupt; cc->dump_state = mb_cpu_dump_state; cc->set_pc = mb_cpu_set_pc;
@@ -328,6 +327,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data) cc->tcg_ops.tlb_fill = mb_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY cc->tcg_ops.do_transaction_failed = mb_cpu_transaction_failed; + cc->tcg_ops.do_unaligned_access = mb_cpu_do_unaligned_access; cc->get_phys_page_debug = mb_cpu_get_phys_page_debug; dc->vmsd = &vmstate_mb_cpu;#endif
target/mips/cpu.c +2 -1
@@ -239,7 +239,6 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->gdb_read_register = mips_cpu_gdb_read_register; cc->gdb_write_register = mips_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY - cc->do_unaligned_access = mips_cpu_do_unaligned_access; cc->get_phys_page_debug = mips_cpu_get_phys_page_debug; cc->vmsd = &vmstate_mips_cpu;#endif
@@ -252,6 +251,8 @@ static void mips_cpu_class_init(ObjectClass *c, void *data)#ifndef CONFIG_USER_ONLY cc->tcg_ops.do_interrupt = mips_cpu_do_interrupt; cc->tcg_ops.do_transaction_failed = mips_cpu_do_transaction_failed; + cc->tcg_ops.do_unaligned_access = mips_cpu_do_unaligned_access; +#endif /* CONFIG_USER_ONLY */ #endif /* CONFIG_TCG */
target/nios2/cpu.c +1 -1
@@ -199,7 +199,7 @@ static void nios2_cpu_class_init(ObjectClass *oc, void *data) cc->disas_set_info = nios2_cpu_disas_set_info; cc->tcg_ops.tlb_fill = nios2_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY - cc->do_unaligned_access = nios2_cpu_do_unaligned_access; + cc->tcg_ops.do_unaligned_access = nios2_cpu_do_unaligned_access; cc->get_phys_page_debug = nios2_cpu_get_phys_page_debug;#endif cc->gdb_read_register = nios2_cpu_gdb_read_register;
target/ppc/translate_init.c.inc +1 -1
@@ -10913,7 +10913,6 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = ppc_cpu_set_pc; cc->gdb_read_register = ppc_cpu_gdb_read_register; cc->gdb_write_register = ppc_cpu_gdb_write_register; - cc->do_unaligned_access = ppc_cpu_do_unaligned_access; #ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = ppc_cpu_get_phys_page_debug; cc->vmsd = &vmstate_ppc_cpu;
@@ -10950,6 +10949,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) #ifndef CONFIG_USER_ONLY cc->tcg_ops.cpu_exec_enter = ppc_cpu_exec_enter; cc->tcg_ops.cpu_exec_exit = ppc_cpu_exec_exit; + cc->tcg_ops.do_unaligned_access = ppc_cpu_do_unaligned_access; #endif /* !CONFIG_USER_ONLY */ #endif /* CONFIG_TCG */
target/riscv/cpu.c +1 -1
@@ -556,7 +556,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data) cc->disas_set_info = riscv_cpu_disas_set_info;#ifndef CONFIG_USER_ONLY cc->tcg_ops.do_transaction_failed = riscv_cpu_do_transaction_failed; - cc->do_unaligned_access = riscv_cpu_do_unaligned_access; + cc->tcg_ops.do_unaligned_access = riscv_cpu_do_unaligned_access; cc->get_phys_page_debug = riscv_cpu_get_phys_page_debug;/* For now, mark unmigratable: */ cc->vmsd = &vmstate_riscv_cpu;
target/s390x/cpu.c +1 -1
@@ -507,7 +507,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data)#ifdef CONFIG_TCG cc->tcg_ops.cpu_exec_interrupt = s390_cpu_exec_interrupt; cc->tcg_ops.debug_excp_handler = s390x_cpu_debug_excp_handler; - cc->do_unaligned_access = s390x_cpu_do_unaligned_access; + cc->tcg_ops.do_unaligned_access = s390x_cpu_do_unaligned_access;#endif #endif cc->disas_set_info = s390_cpu_disas_set_info;
target/sh4/cpu.c +1 -1
@@ -227,7 +227,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = superh_cpu_gdb_write_register; cc->tcg_ops.tlb_fill = superh_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY - cc->do_unaligned_access = superh_cpu_do_unaligned_access; + cc->tcg_ops.do_unaligned_access = superh_cpu_do_unaligned_access; cc->get_phys_page_debug = superh_cpu_get_phys_page_debug;#endif cc->disas_set_info = superh_cpu_disas_set_info;
target/sparc/cpu.c +1 -1
@@ -874,7 +874,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data) cc->tcg_ops.tlb_fill = sparc_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY cc->tcg_ops.do_transaction_failed = sparc_cpu_do_transaction_failed; - cc->do_unaligned_access = sparc_cpu_do_unaligned_access; + cc->tcg_ops.do_unaligned_access = sparc_cpu_do_unaligned_access; cc->get_phys_page_debug = sparc_cpu_get_phys_page_debug; cc->vmsd = &vmstate_sparc_cpu;#endif
target/xtensa/cpu.c +1 -1
@@ -203,7 +203,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_stop_before_watchpoint = true; cc->tcg_ops.tlb_fill = xtensa_cpu_tlb_fill;#ifndef CONFIG_USER_ONLY - cc->do_unaligned_access = xtensa_cpu_do_unaligned_access; + cc->tcg_ops.do_unaligned_access = xtensa_cpu_do_unaligned_access; cc->get_phys_page_debug = xtensa_cpu_get_phys_page_debug; cc->tcg_ops.do_transaction_failed = xtensa_cpu_do_transaction_failed;#endif
Signature · 1 line
2.26.2
Re: [RFC v9 25/32] cpu: move do_unaligned_access to tcg_ops
Quoted 3 lines · Claudio Fontana
make it consistently SOFTMMU-only.
Signed-off-by Claudio Fontana <[email protected]>
Signature · 1 line
Alex Bennée
RFC v9 26/32 accel: extend AccelState and AccelClass to user-mode
In reply to Claudio Fontana---
MAINTAINERS | 2 +-
accel/accel-common.c | 50 ++++++++++++++++++++++++++++++
accel/{accel.c => accel-softmmu.c} | 27 ++--------------
accel/accel-user.c | 24 ++++++++++++++
accel/meson.build | 4 ++-
accel/qtest/qtest.c | 2 +-
accel/tcg/meson.build | 2 +-
accel/tcg/tcg-all.c | 13 ++++++--
accel/xen/xen-all.c | 2 +-
bsd-user/main.c | 6 +++-
include/hw/boards.h | 2 +-
include/{sysemu => qemu}/accel.h | 14 +++++----
include/sysemu/hvf.h | 2 +-
include/sysemu/kvm.h | 2 +-
include/sysemu/kvm_int.h | 2 +-
linux-user/main.c | 6 +++-
softmmu/memory.c | 2 +-
softmmu/qtest.c | 2 +-
softmmu/vl.c | 2 +-
target/i386/hax/hax-all.c | 2 +-
target/i386/hvf/hvf-i386.h | 2 +-
target/i386/hvf/hvf.c | 2 +-
target/i386/hvf/x86_task.c | 2 +-
target/i386/whpx/whpx-all.c | 2 +-
24 files changed, 124 insertions(+), 52 deletions(-)
create mode 100644 accel/accel-common.c
rename accel/{accel.c => accel-softmmu.c} (75%)
create mode 100644 accel/accel-user.c
rename include/{sysemu => qemu}/accel.h (95%)MAINTAINERS +1 -1
@@ -434,7 +434,7 @@ Overall M: Richard Henderson <[email protected]> R: Paolo Bonzini <[email protected]> S: Maintained -F: include/sysemu/accel.h +F: include/qemu/accel.h F: accel/accel.c F: accel/Makefile.objs F: accel/stubs/Makefile.objs
accel/accel-common.c new file +50 -0
50 lines not on this page · raw message
accel/accel-softmmu.c renamed from accel/accel.c +2 -25
@@ -1,5 +1,5 @@/* -* QEMU System Emulator, accelerator interfaces +* QEMU accel class, system emulation components * * Copyright (c) 2003-2008 Fabrice Bellard * Copyright (c) 2014 Red Hat Inc.
@@ -24,28 +24,12 @@*/ #include "qemu/osdep.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "hw/boards.h" #include "sysemu/arch_init.h" #include "sysemu/sysemu.h" #include "qom/object.h" -static const TypeInfo accel_type = { - .name =TYPE_ACCEL , - .parent =TYPE_OBJECT , - .class_size =sizeof (AccelClass), - .instance_size =sizeof (AccelState), -}; - -/* Lookup AccelClass from opt_name. Returns NULL if not found */ -AccelClass *accel_find (const char *opt_name) -{ -char *class_name =g_strdup_printf (ACCEL_CLASS_NAME ("%s" ), opt_name); -AccelClass *ac =ACCEL_CLASS (object_class_by_name (class_name)); -g_free (class_name); -return ac; -} -int accel_init_machine (AccelState *accel,MachineState *ms) {AccelClass *acc =ACCEL_GET_CLASS (accel);
@@ -76,10 +60,3 @@ void accel_setup_post(MachineState *ms) acc->setup_post (ms, accel); } } - -static void register_accel_types (void ) -{ -type_register_static (&accel_type); -} - -type_init (register_accel_types);
accel/accel-user.c new file +24 -0
@@ -0,0 +1,24 @@ +/* +* QEMU accel class, user-mode components +* +* Copyright 2020 SUSE LLC +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "qemu/osdep.h" +#include "qemu/accel.h" + +AccelState *current_accel (void ) +{ +static AccelState *accel; + +if (!accel) { +AccelClass *ac =accel_find ("tcg" ); + +g_assert (ac !=NULL ); + accel =ACCEL (object_new_with_class (OBJECT_CLASS (ac))); + } +return accel; +}
accel/meson.build +3 -1
@@ -1,4 +1,6 @@ -softmmu_ss.add(files('accel.c')) +specific_ss.add(files('accel-common.c')) +softmmu_ss.add(files('accel-softmmu.c')) +user_ss.add(files('accel-user.c')) subdir('qtest') subdir('kvm')
accel/qtest/qtest.c +1 -1
@@ -17,7 +17,7 @@#include "qemu/module.h" #include "qemu/option.h" #include "qemu/config-file.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "sysemu/qtest.h" #include "sysemu/cpus.h" #include "sysemu/cpu-timers.h"
accel/tcg/meson.build +1 -1
@@ -1,5 +1,6 @@ tcg_ss = ss.source_set() tcg_ss.add(files( + 'tcg-all.c', 'cpu-exec-common.c', 'cpu-exec.c', 'tcg-runtime-gvec.c',
@@ -13,7 +14,6 @@ tcg_ss.add(when: 'CONFIG_PLUGIN', if_true: [files('plugin-gen.c'), libdl]) specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_ss) specific_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: files( - 'tcg-all.c', 'cputlb.c', 'tcg-cpus.c', 'tcg-cpus-mttcg.c',
accel/tcg/tcg-all.c +11 -2
@@ -30,9 +30,12 @@#include "tcg/tcg.h" #include "qapi/error.h" #include "qemu/error-report.h" -#include "hw/boards.h" +#include "qemu/accel.h" #include "qapi/qapi-builtin-visit.h" + +#ifndef CONFIG_USER_ONLY #include "tcg-cpus.h" +#endif /* CONFIG_USER_ONLY */ struct TCGState {AccelState parent_obj;
@@ -106,8 +109,12 @@ static int tcg_init(MachineState *ms) mttcg_enabled = s->mttcg_enabled;/* -* Initialize TCG regions +* Initialize TCG regions only for softmmu. +* +* This needs to be done later for user mode, because the prologue +* generation needs to be delayed so that GUEST_BASE is already set. */ +#ifndef CONFIG_USER_ONLY tcg_region_init ();if (mttcg_enabled) {
@@ -117,6 +124,8 @@ static int tcg_init(MachineState *ms) } else {cpus_register_accel (&tcg_cpus_rr); } +#endif /* !CONFIG_USER_ONLY */ +return 0 ; }
accel/xen/xen-all.c +1 -1
@@ -15,7 +15,7 @@#include "hw/xen/xen-legacy-backend.h" #include "hw/xen/xen_pt.h" #include "chardev/char.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "sysemu/cpus.h" #include "sysemu/xen.h" #include "sysemu/runstate.h"
bsd-user/main.c +5 -1
@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "qemu-common.h" #include "qemu/units.h" +#include "qemu/accel.h" #include "sysemu/tcg.h" #include "qemu-version.h" #include <machine/trap.h>
@@ -908,8 +909,11 @@ int main(int argc, char **argv) }/* init tcg before creating CPUs and to get qemu_host_page_size */ -tcg_exec_init (0 ); + { +AccelClass *ac =ACCEL_GET_CLASS (current_accel ()); + ac->init_machine (NULL ); + } cpu_type =parse_cpu_option (cpu_model); cpu =cpu_create (cpu_type); env = cpu->env_ptr;
include/hw/boards.h +1 -1
@@ -6,7 +6,7 @@#include "exec/memory.h" #include "sysemu/hostmem.h" #include "sysemu/blockdev.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "qapi/qapi-types-machine.h" #include "qemu/module.h" #include "qom/object.h"
include/qemu/accel.h renamed from include/sysemu/accel.h +8 -6
@@ -20,8 +20,8 @@* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#ifndef HW_ACCEL_H -#define HW_ACCEL_H +#ifndef QEMU_ACCEL_H +#define QEMU_ACCEL_H #include "qom/object.h" #include "exec/hwaddr.h"
@@ -37,8 +37,8 @@ typedef struct AccelClass {/*< public >*/ const char *name; -#ifndef CONFIG_USER_ONLY int (*init_machine)(MachineState *ms); +#ifndef CONFIG_USER_ONLY void (*setup_post)(MachineState *ms,AccelState *accel);bool (*has_memory)(MachineState *ms,AddressSpace *as,hwaddr start_addr,hwaddr size);
@@ -67,11 +67,13 @@ typedef struct AccelClass { OBJECT_GET_CLASS(AccelClass, (obj), TYPE_ACCEL)AccelClass *accel_find (const char *opt_name); +AccelState *current_accel (void ); + +#ifndef CONFIG_USER_ONLY int accel_init_machine (AccelState *accel,MachineState *ms);/* Called just before os_setup_post (ie just before drop OS privs) */ void accel_setup_post (MachineState *ms); +#endif /* !CONFIG_USER_ONLY */ -AccelState *current_accel (void ); - -#endif +#endif /* QEMU_ACCEL_H */
include/sysemu/hvf.h +1 -1
@@ -13,7 +13,7 @@#ifndef HVF_H #define HVF_H -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "qom/object.h" #ifdef CONFIG_HVF
include/sysemu/kvm.h +1 -1
@@ -17,7 +17,7 @@#include "qemu/queue.h" #include "hw/core/cpu.h" #include "exec/memattrs.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "qom/object.h" #ifdef NEED_CPU_H
include/sysemu/kvm_int.h +1 -1
@@ -10,7 +10,7 @@#define QEMU_KVM_INT_H #include "exec/memory.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "sysemu/kvm.h" typedef struct KVMSlot
linux-user/main.c +5 -1
@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "qemu-common.h" #include "qemu/units.h" +#include "qemu/accel.h" #include "sysemu/tcg.h" #include "qemu-version.h" #include <sys/syscall.h>
@@ -703,8 +704,11 @@ int main(int argc, char **argv, char **envp) cpu_type =parse_cpu_option (cpu_model);/* init tcg before creating CPUs and to get qemu_host_page_size */ -tcg_exec_init (0 ); + { +AccelClass *ac =ACCEL_GET_CLASS (current_accel ()); + ac->init_machine (NULL ); + } cpu =cpu_create (cpu_type); env = cpu->env_ptr;cpu_reset (cpu);
softmmu/memory.c +1 -1
@@ -32,7 +32,7 @@#include "sysemu/kvm.h" #include "sysemu/runstate.h" #include "sysemu/tcg.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "hw/boards.h" #include "migration/vmstate.h"
softmmu/qtest.c +1 -1
@@ -20,7 +20,7 @@#include "exec/ioport.h" #include "exec/memory.h" #include "hw/irq.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "sysemu/cpu-timers.h" #include "qemu/config-file.h" #include "qemu/option.h"
softmmu/vl.c +1 -1
@@ -40,7 +40,7 @@#include "qemu/error-report.h" #include "qemu/sockets.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "hw/usb.h" #include "hw/isa/isa.h" #include "hw/scsi/scsi.h"
target/i386/hax/hax-all.c +1 -1
@@ -28,7 +28,7 @@#include "exec/address-spaces.h" #include "qemu-common.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "sysemu/reset.h" #include "sysemu/runstate.h" #include "hw/boards.h"
target/i386/hvf/hvf-i386.h +1 -1
@@ -16,7 +16,7 @@#ifndef HVF_I386_H #define HVF_I386_H -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "sysemu/hvf.h" #include "cpu.h" #include "x86.h"
target/i386/hvf/hvf.c +1 -1
@@ -69,7 +69,7 @@#include "exec/address-spaces.h" #include "hw/i386/apic_internal.h" #include "qemu/main-loop.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "target/i386/cpu.h" #include "hvf-cpus.h"
target/i386/hvf/x86_task.c +1 -1
@@ -28,7 +28,7 @@#include "hw/i386/apic_internal.h" #include "qemu/main-loop.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "target/i386/cpu.h" // TODO: taskswitch handling
target/i386/whpx/whpx-all.c +1 -1
@@ -13,7 +13,7 @@#include "exec/address-spaces.h" #include "exec/ioport.h" #include "qemu-common.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "sysemu/whpx.h" #include "sysemu/cpus.h" #include "sysemu/runstate.h"
Signature · 1 line
2.26.2
Re: [RFC v9 26/32] accel: extend AccelState and AccelClass to user-mode
Quoted 250 lines · Claudio Fontana
Signed-off-by Claudio Fontana <[email protected]>--- MAINTAINERS | 2 +- accel/accel-common.c | 50 ++++++++++++++++++++++++++++++ accel/{accel.c => accel-softmmu.c} | 27 ++-------------- accel/accel-user.c | 24 ++++++++++++++ accel/meson.build | 4 ++- accel/qtest/qtest.c | 2 +- accel/tcg/meson.build | 2 +- accel/tcg/tcg-all.c | 13 ++++++-- accel/xen/xen-all.c | 2 +- bsd-user/main.c | 6 +++- include/hw/boards.h | 2 +- include/{sysemu => qemu}/accel.h | 14 +++++---- include/sysemu/hvf.h | 2 +- include/sysemu/kvm.h | 2 +- include/sysemu/kvm_int.h | 2 +- linux-user/main.c | 6 +++- softmmu/memory.c | 2 +- softmmu/qtest.c | 2 +- softmmu/vl.c | 2 +- target/i386/hax/hax-all.c | 2 +- target/i386/hvf/hvf-i386.h | 2 +- target/i386/hvf/hvf.c | 2 +- target/i386/hvf/x86_task.c | 2 +- target/i386/whpx/whpx-all.c | 2 +- 24 files changed, 124 insertions(+), 52 deletions(-) create mode 100644 accel/accel-common.c rename accel/{accel.c => accel-softmmu.c} (75%) create mode 100644 accel/accel-user.c rename include/{sysemu => qemu}/accel.h (95%)MAINTAINERS +1
-1@@ -434,7 +434,7 @@ Overall M: Richard Henderson <[email protected]> R: Paolo Bonzini <[email protected]> S: Maintained -F: include/sysemu/accel.h +F: include/qemu/accel.h F: accel/accel.c F: accel/Makefile.objs F: accel/stubs/Makefile.objsaccel/accel-common.c new file +50
-0@@ -0,0 +1,50 @@ +/* +* QEMU accel class, components common to system emulation and user mode +* +* Copyright (c) 2003-2008 Fabrice Bellard +* Copyright (c) 2014 Red Hat Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#include "qemu/osdep.h" +#include "qemu/accel.h" + +static const TypeInfo accel_type = { + .name =TYPE_ACCEL , + .parent =TYPE_OBJECT , + .class_size =sizeof (AccelClass), + .instance_size =sizeof (AccelState), +}; + +/* Lookup AccelClass from opt_name. Returns NULL if not found */ +AccelClass *accel_find (const char *opt_name) +{ +char *class_name =g_strdup_printf (ACCEL_CLASS_NAME ("%s" ), opt_name); +AccelClass *ac =ACCEL_CLASS (object_class_by_name (class_name)); +g_free (class_name); +return ac; +} + +static void register_accel_types (void ) +{ +type_register_static (&accel_type); +} + +type_init (register_accel_types);accel/accel-softmmu.c renamed from accel/accel.c +2
-25@@ -1,5 +1,5 @@/* -* QEMU System Emulator, accelerator interfaces +* QEMU accel class, system emulation components * * Copyright (c) 2003-2008 Fabrice Bellard * Copyright (c) 2014 Red Hat Inc. @@ -24,28 +24,12 @@*/ #include "qemu/osdep.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "hw/boards.h" #include "sysemu/arch_init.h" #include "sysemu/sysemu.h" #include "qom/object.h" -static const TypeInfo accel_type = { - .name =TYPE_ACCEL , - .parent =TYPE_OBJECT , - .class_size =sizeof (AccelClass), - .instance_size =sizeof (AccelState), -}; - -/* Lookup AccelClass from opt_name. Returns NULL if not found */ -AccelClass *accel_find (const char *opt_name) -{ -char *class_name =g_strdup_printf (ACCEL_CLASS_NAME ("%s" ), opt_name); -AccelClass *ac =ACCEL_CLASS (object_class_by_name (class_name)); -g_free (class_name); -return ac; -} -int accel_init_machine (AccelState *accel,MachineState *ms) {AccelClass *acc =ACCEL_GET_CLASS (accel);@@ -76,10 +60,3 @@ void accel_setup_post(MachineState *ms) acc->setup_post (ms, accel); } } - -static void register_accel_types (void ) -{ -type_register_static (&accel_type); -} - -type_init (register_accel_types);accel/accel-user.c new file +24
-0@@ -0,0 +1,24 @@ +/* +* QEMU accel class, user-mode components +* +* Copyright 2020 SUSE LLC +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "qemu/osdep.h" +#include "qemu/accel.h" + +AccelState *current_accel (void ) +{ +static AccelState *accel; + +if (!accel) { +AccelClass *ac =accel_find ("tcg" ); + +g_assert (ac !=NULL ); + accel =ACCEL (object_new_with_class (OBJECT_CLASS (ac))); + } +return accel; +}accel/meson.build +3
-1@@ -1,4 +1,6 @@ -softmmu_ss.add(files('accel.c')) +specific_ss.add(files('accel-common.c')) +softmmu_ss.add(files('accel-softmmu.c')) +user_ss.add(files('accel-user.c')) subdir('qtest') subdir('kvm')accel/qtest/qtest.c +1
-1@@ -17,7 +17,7 @@#include "qemu/module.h" #include "qemu/option.h" #include "qemu/config-file.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "sysemu/qtest.h" #include "sysemu/cpus.h" #include "sysemu/cpu-timers.h" accel/tcg/meson.build +1
-1@@ -1,5 +1,6 @@ tcg_ss = ss.source_set() tcg_ss.add(files( + 'tcg-all.c', 'cpu-exec-common.c', 'cpu-exec.c', 'tcg-runtime-gvec.c',@@ -13,7 +14,6 @@ tcg_ss.add(when: 'CONFIG_PLUGIN', if_true: [files('plugin-gen.c'), libdl]) specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_ss) specific_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: files( - 'tcg-all.c', 'cputlb.c', 'tcg-cpus.c', 'tcg-cpus-mttcg.c',accel/tcg/tcg-all.c +4
-1@@ -30,9 +30,12 @@#include "tcg/tcg.h" #include "qapi/error.h" #include "qemu/error-report.h" -#include "hw/boards.h" +#include "qemu/accel.h" #include "qapi/qapi-builtin-visit.h" + +#ifndef CONFIG_USER_ONLY #include "tcg-cpus.h" +#endif /* CONFIG_USER_ONLY */ struct TCGState {AccelState parent_obj;@@ -106,8 +109,12 @@ static int tcg_init(MachineState *ms) mttcg_enabled = s->mttcg_enabled;
accel/tcg/tcg-all.c static int tcg_init(MachineState *ms) · line 118
Quoted 10 lines
accel/tcg/tcg-all.c +5
-1/* -* Initialize TCG regions +* Initialize TCG regions only for softmmu. +* +* This needs to be done later for user mode, because the prologue +* generation needs to be delayed so that GUEST_BASE is already set. */ +#ifndef CONFIG_USER_ONLY tcg_region_init ();
This implies we broke bisectability with:
accel/tcg: split tcg_start_vcpu_thread
<snip>
Otherwise with that fixed:
Signature · 1 line
Alex Bennée
Re: [RFC v9 26/32] accel: extend AccelState and AccelClass to user-mode
Quoted 266 lines · Alex Bennée
Quoted 250 lines · Claudio Fontana
Signed-off-by Claudio Fontana <[email protected]>--- MAINTAINERS | 2 +- accel/accel-common.c | 50 ++++++++++++++++++++++++++++++ accel/{accel.c => accel-softmmu.c} | 27 ++-------------- accel/accel-user.c | 24 ++++++++++++++ accel/meson.build | 4 ++- accel/qtest/qtest.c | 2 +- accel/tcg/meson.build | 2 +- accel/tcg/tcg-all.c | 13 ++++++-- accel/xen/xen-all.c | 2 +- bsd-user/main.c | 6 +++- include/hw/boards.h | 2 +- include/{sysemu => qemu}/accel.h | 14 +++++---- include/sysemu/hvf.h | 2 +- include/sysemu/kvm.h | 2 +- include/sysemu/kvm_int.h | 2 +- linux-user/main.c | 6 +++- softmmu/memory.c | 2 +- softmmu/qtest.c | 2 +- softmmu/vl.c | 2 +- target/i386/hax/hax-all.c | 2 +- target/i386/hvf/hvf-i386.h | 2 +- target/i386/hvf/hvf.c | 2 +- target/i386/hvf/x86_task.c | 2 +- target/i386/whpx/whpx-all.c | 2 +- 24 files changed, 124 insertions(+), 52 deletions(-) create mode 100644 accel/accel-common.c rename accel/{accel.c => accel-softmmu.c} (75%) create mode 100644 accel/accel-user.c rename include/{sysemu => qemu}/accel.h (95%)MAINTAINERS +1
-1@@ -434,7 +434,7 @@ Overall M: Richard Henderson <[email protected]> R: Paolo Bonzini <[email protected]> S: Maintained -F: include/sysemu/accel.h +F: include/qemu/accel.h F: accel/accel.c F: accel/Makefile.objs F: accel/stubs/Makefile.objsaccel/accel-common.c new file +50
-0@@ -0,0 +1,50 @@ +/* +* QEMU accel class, components common to system emulation and user mode +* +* Copyright (c) 2003-2008 Fabrice Bellard +* Copyright (c) 2014 Red Hat Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#include "qemu/osdep.h" +#include "qemu/accel.h" + +static const TypeInfo accel_type = { + .name =TYPE_ACCEL , + .parent =TYPE_OBJECT , + .class_size =sizeof (AccelClass), + .instance_size =sizeof (AccelState), +}; + +/* Lookup AccelClass from opt_name. Returns NULL if not found */ +AccelClass *accel_find (const char *opt_name) +{ +char *class_name =g_strdup_printf (ACCEL_CLASS_NAME ("%s" ), opt_name); +AccelClass *ac =ACCEL_CLASS (object_class_by_name (class_name)); +g_free (class_name); +return ac; +} + +static void register_accel_types (void ) +{ +type_register_static (&accel_type); +} + +type_init (register_accel_types);accel/accel-softmmu.c renamed from accel/accel.c +2
-25@@ -1,5 +1,5 @@/* -* QEMU System Emulator, accelerator interfaces +* QEMU accel class, system emulation components * * Copyright (c) 2003-2008 Fabrice Bellard * Copyright (c) 2014 Red Hat Inc. @@ -24,28 +24,12 @@*/ #include "qemu/osdep.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "hw/boards.h" #include "sysemu/arch_init.h" #include "sysemu/sysemu.h" #include "qom/object.h" -static const TypeInfo accel_type = { - .name =TYPE_ACCEL , - .parent =TYPE_OBJECT , - .class_size =sizeof (AccelClass), - .instance_size =sizeof (AccelState), -}; - -/* Lookup AccelClass from opt_name. Returns NULL if not found */ -AccelClass *accel_find (const char *opt_name) -{ -char *class_name =g_strdup_printf (ACCEL_CLASS_NAME ("%s" ), opt_name); -AccelClass *ac =ACCEL_CLASS (object_class_by_name (class_name)); -g_free (class_name); -return ac; -} -int accel_init_machine (AccelState *accel,MachineState *ms) {AccelClass *acc =ACCEL_GET_CLASS (accel);@@ -76,10 +60,3 @@ void accel_setup_post(MachineState *ms) acc->setup_post (ms, accel); } } - -static void register_accel_types (void ) -{ -type_register_static (&accel_type); -} - -type_init (register_accel_types);accel/accel-user.c new file +24
-0@@ -0,0 +1,24 @@ +/* +* QEMU accel class, user-mode components +* +* Copyright 2020 SUSE LLC +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "qemu/osdep.h" +#include "qemu/accel.h" + +AccelState *current_accel (void ) +{ +static AccelState *accel; + +if (!accel) { +AccelClass *ac =accel_find ("tcg" ); + +g_assert (ac !=NULL ); + accel =ACCEL (object_new_with_class (OBJECT_CLASS (ac))); + } +return accel; +}accel/meson.build +3
-1@@ -1,4 +1,6 @@ -softmmu_ss.add(files('accel.c')) +specific_ss.add(files('accel-common.c')) +softmmu_ss.add(files('accel-softmmu.c')) +user_ss.add(files('accel-user.c')) subdir('qtest') subdir('kvm')accel/qtest/qtest.c +1
-1@@ -17,7 +17,7 @@#include "qemu/module.h" #include "qemu/option.h" #include "qemu/config-file.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "sysemu/qtest.h" #include "sysemu/cpus.h" #include "sysemu/cpu-timers.h" accel/tcg/meson.build +1
-1@@ -1,5 +1,6 @@ tcg_ss = ss.source_set() tcg_ss.add(files( + 'tcg-all.c', 'cpu-exec-common.c', 'cpu-exec.c', 'tcg-runtime-gvec.c',@@ -13,7 +14,6 @@ tcg_ss.add(when: 'CONFIG_PLUGIN', if_true: [files('plugin-gen.c'), libdl]) specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_ss) specific_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: files( - 'tcg-all.c', 'cputlb.c', 'tcg-cpus.c', 'tcg-cpus-mttcg.c',accel/tcg/tcg-all.c +4
-1@@ -30,9 +30,12 @@#include "tcg/tcg.h" #include "qapi/error.h" #include "qemu/error-report.h" -#include "hw/boards.h" +#include "qemu/accel.h" #include "qapi/qapi-builtin-visit.h" + +#ifndef CONFIG_USER_ONLY #include "tcg-cpus.h" +#endif /* CONFIG_USER_ONLY */ struct TCGState {AccelState parent_obj;@@ -106,8 +109,12 @@ static int tcg_init(MachineState *ms) mttcg_enabled = s->mttcg_enabled;accel/tcg/tcg-all.c static int tcg_init(MachineState *ms) · line 118
Quoted 10 lines
accel/tcg/tcg-all.c +5
-1/* -* Initialize TCG regions +* Initialize TCG regions only for softmmu. +* +* This needs to be done later for user mode, because the prologue +* generation needs to be delayed so that GUEST_BASE is already set. */ +#ifndef CONFIG_USER_ONLY tcg_region_init ();This implies we broke bisectability with:
Quoted 1 line
accel/tcg: split
tcg_start_vcpu_thread
Hi Alex,
I don't think so, this is only an issue after applying this patch, because tcg_init is only called by softmmu code up and until this very patch,
bisect should be ok..
Ciao,
Claudio
Quoted 7 lines
<snip>
Otherwise with that fixed:
Reviewed-by Alex Bennée <[email protected]>
RFC v9 27/32 accel: replace struct CpusAccel with AccelOpsClass
In reply to Claudio Fontanacentralize the registration of the cpus.c module
accelerator operations in accel/accel-softmmu.c
--- MAINTAINERS | 3 ++- accel/accel-common.c | 11 +++++++++ accel/accel-softmmu.c | 43 +++++++++++++++++++++++++++++++--- accel/accel-softmmu.h | 15 ++++++++++++ accel/kvm/kvm-all.c | 2 -- accel/kvm/kvm-cpus.c | 26 ++++++++++++++++----- accel/kvm/kvm-cpus.h | 2 -- accel/qtest/qtest.c | 23 +++++++++++++----- accel/tcg/tcg-all.c | 12 ---------- accel/tcg/tcg-cpus-icount.c | 11 +-------- accel/tcg/tcg-cpus-icount.h | 2 ++ accel/tcg/tcg-cpus-mttcg.c | 12 +++------- accel/tcg/tcg-cpus-mttcg.h | 19 +++++++++++++++ accel/tcg/tcg-cpus-rr.c | 7 ------ accel/tcg/tcg-cpus.c | 43 ++++++++++++++++++++++++++++++++++ accel/tcg/tcg-cpus.h | 4 ---- accel/xen/xen-all.c | 22 ++++++++++++------ bsd-user/main.c | 3 ++- include/qemu/accel.h | 2 ++ include/sysemu/accel-ops.h | 45 ++++++++++++++++++++++++++++++++++++ include/sysemu/cpus.h | 26 ++++----------------- linux-user/main.c | 1 + softmmu/cpus.c | 12 +++++----- softmmu/vl.c | 6 +++-- target/i386/hax/hax-all.c | 3 --- target/i386/hax/hax-cpus.c | 29 +++++++++++++++++------ target/i386/hax/hax-cpus.h | 2 -- target/i386/hvf/hvf-cpus.c | 27 +++++++++++++++++----- target/i386/hvf/hvf-cpus.h | 2 -- target/i386/hvf/hvf.c | 1 - target/i386/whpx/whpx-all.c | 2 -- target/i386/whpx/whpx-cpus.c | 29 +++++++++++++++++------ target/i386/whpx/whpx-cpus.h | 2 -- 33 files changed, 318 insertions(+), 131 deletions(-) create mode 100644 accel/accel-softmmu.h create mode 100644 accel/tcg/tcg-cpus-mttcg.h create mode 100644 include/sysemu/accel-ops.h
MAINTAINERS +2 -1
@@ -435,7 +435,8 @@ M: Richard Henderson <[email protected]> R: Paolo Bonzini <[email protected]> S: Maintained F: include/qemu/accel.h -F: accel/accel.c +F: include/sysemu/accel-ops.h +F: accel/accel-*.c F: accel/Makefile.objs F: accel/stubs/Makefile.objs
accel/accel-common.c +11 -0
@@ -26,6 +26,10 @@#include "qemu/osdep.h" #include "qemu/accel.h" +#ifndef CONFIG_USER_ONLY +#include "accel-softmmu.h" +#endif /* !CONFIG_USER_ONLY */ +static const TypeInfo accel_type = { .name =TYPE_ACCEL , .parent =TYPE_OBJECT ,
@@ -42,6 +46,13 @@ AccelClass *accel_find(const char *opt_name)return ac; } +void accel_init_interfaces (AccelClass *ac) +{ +#ifndef CONFIG_USER_ONLY +accel_init_ops_interfaces (ac); +#endif /* !CONFIG_USER_ONLY */ +} +static void register_accel_types (void ) {type_register_static (&accel_type);
accel/accel-softmmu.c +40 -3
52 lines not on this page · raw message
accel/accel-softmmu.h new file +15 -0
@@ -0,0 +1,15 @@ +/* +* QEMU System Emulation accel internal functions +* +* Copyright 2020 SUSE LLC +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef ACCEL_SOFTMMU_H +#define ACCEL_SOFTMMU_H + +void accel_init_ops_interfaces (AccelClass *ac); + +#endif /* ACCEL_SOFTMMU_H */
accel/kvm/kvm-all.c +0 -2
@@ -2253,8 +2253,6 @@ static int kvm_init(MachineState *ms) ret =ram_block_discard_disable (true);assert (!ret); } - -cpus_register_accel (&kvm_cpus);return 0 ; err:
accel/kvm/kvm-cpus.c +20 -6
@@ -74,11 +74,25 @@ static void kvm_start_vcpu_thread(CPUState *cpu) cpu, QEMU_THREAD_JOINABLE); } -const CpusAccel kvm_cpus = { - .create_vcpu_thread = kvm_start_vcpu_thread, +static void kvm_cpus_class_init (ObjectClass *oc,void *data) +{ +AccelOpsClass *ops =ACCEL_OPS_CLASS (oc); - .synchronize_post_reset = kvm_cpu_synchronize_post_reset, - .synchronize_post_init = kvm_cpu_synchronize_post_init, - .synchronize_state = kvm_cpu_synchronize_state, - .synchronize_pre_loadvm = kvm_cpu_synchronize_pre_loadvm, + ops->create_vcpu_thread = kvm_start_vcpu_thread; + ops->synchronize_post_reset = kvm_cpu_synchronize_post_reset; + ops->synchronize_post_init = kvm_cpu_synchronize_post_init; + ops->synchronize_state = kvm_cpu_synchronize_state; + ops->synchronize_pre_loadvm = kvm_cpu_synchronize_pre_loadvm; }; +static const TypeInfo kvm_cpus_type_info = { + .name =ACCEL_OPS_NAME ("kvm" ), + + .parent =TYPE_ACCEL_OPS , + .class_init = kvm_cpus_class_init, + .abstract = true, +}; +static void kvm_cpus_register_types (void ) +{ +type_register_static (&kvm_cpus_type_info); +} +type_init (kvm_cpus_register_types);
accel/kvm/kvm-cpus.h +0 -2
@@ -12,8 +12,6 @@#include "sysemu/cpus.h" -extern const CpusAccel kvm_cpus; -int kvm_init_vcpu (CPUState *cpu,Error **errp);int kvm_cpu_exec (CPUState *cpu);void kvm_destroy_vcpu (CPUState *cpu);
accel/qtest/qtest.c +17 -6
@@ -25,14 +25,8 @@#include "qemu/main-loop.h" #include "hw/core/cpu.h" -const CpusAccel qtest_cpus = { - .create_vcpu_thread = dummy_start_vcpu_thread, - .get_virtual_clock = qtest_get_virtual_clock, -}; -static int qtest_init_accel (MachineState *ms) { -cpus_register_accel (&qtest_cpus);return 0 ; }
@@ -52,9 +46,26 @@ static const TypeInfo qtest_accel_type = { .class_init = qtest_accel_class_init, }; +static void qtest_cpus_class_init (ObjectClass *oc,void *data) +{ +AccelOpsClass *ops =ACCEL_OPS_CLASS (oc); + + ops->create_vcpu_thread = dummy_start_vcpu_thread; + ops->get_virtual_clock = qtest_get_virtual_clock; +}; + +static const TypeInfo qtest_cpus_type_info = { + .name =ACCEL_OPS_NAME ("qtest" ), + + .parent =TYPE_ACCEL_OPS , + .class_init = qtest_cpus_class_init, + .abstract = true, +}; +static void qtest_type_init (void ) {type_register_static (&qtest_accel_type); +type_register_static (&qtest_cpus_type_info); }type_init (qtest_type_init);
accel/tcg/tcg-all.c +0 -12
@@ -33,10 +33,6 @@#include "qemu/accel.h" #include "qapi/qapi-builtin-visit.h" -#ifndef CONFIG_USER_ONLY -#include "tcg-cpus.h" -#endif /* CONFIG_USER_ONLY */ -struct TCGState {AccelState parent_obj;
@@ -116,14 +112,6 @@ static int tcg_init(MachineState *ms)*/ #ifndef CONFIG_USER_ONLY tcg_region_init (); - -if (mttcg_enabled) { -cpus_register_accel (&tcg_cpus_mttcg); - }else if (icount_enabled ()) { -cpus_register_accel (&tcg_cpus_icount); - }else { -cpus_register_accel (&tcg_cpus_rr); - }#endif /* !CONFIG_USER_ONLY */ return 0 ;
accel/tcg/tcg-cpus-icount.c +1 -10
@@ -125,7 +125,7 @@ void icount_process_data(CPUState *cpu)replay_mutex_unlock (); } -static void icount_handle_interrupt (CPUState *cpu,int mask) +void icount_handle_interrupt (CPUState *cpu,int mask) {int old_mask = cpu->interrupt_request;
@@ -136,12 +136,3 @@ static void icount_handle_interrupt(CPUState *cpu, int mask)cpu_abort (cpu,"Raised interrupt while not in I/O function" ); } } - -const CpusAccel tcg_cpus_icount = { - .create_vcpu_thread = rr_start_vcpu_thread, - .kick_vcpu_thread = rr_kick_vcpu_thread, - - .handle_interrupt = icount_handle_interrupt, - .get_virtual_clock = icount_get, - .get_elapsed_ticks = icount_get, -};
accel/tcg/tcg-cpus-icount.h +2 -0
@@ -14,4 +14,6 @@ void icount_handle_deadline(void);void icount_prepare_for_run (CPUState *cpu);void icount_process_data (CPUState *cpu); +void icount_handle_interrupt (CPUState *cpu,int mask); +#endif /* TCG_CPUS_ICOUNT_H */
accel/tcg/tcg-cpus-mttcg.c +3 -9
@@ -33,6 +33,7 @@#include "hw/boards.h" #include "tcg-cpus.h" +#include "tcg-cpus-mttcg.h" /* * In the multi-threaded case each vCPU has its own thread. The TLS
@@ -103,12 +104,12 @@ static void *mttcg_cpu_thread_fn(void *arg)return NULL ; } -static void mttcg_kick_vcpu_thread (CPUState *cpu) +void mttcg_kick_vcpu_thread (CPUState *cpu) {cpu_exit (cpu); } -static void mttcg_start_vcpu_thread (CPUState *cpu) +void mttcg_start_vcpu_thread (CPUState *cpu) {char thread_name[VCPU_THREAD_NAME_SIZE ];
@@ -131,10 +132,3 @@ static void mttcg_start_vcpu_thread(CPUState *cpu) cpu->hThread =qemu_thread_get_handle (cpu->thread);#endif } - -const CpusAccel tcg_cpus_mttcg = { - .create_vcpu_thread = mttcg_start_vcpu_thread, - .kick_vcpu_thread = mttcg_kick_vcpu_thread, - - .handle_interrupt = tcg_cpus_handle_interrupt, -};
accel/tcg/tcg-cpus-mttcg.h new file +19 -0
@@ -0,0 +1,19 @@ +/* +* QEMU TCG Multi Threaded vCPUs implementation +* +* Copyright 2020 SUSE LLC +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef TCG_CPUS_MTTCG_H +#define TCG_CPUS_MTTCG_H + +/* kick MTTCG vCPU thread */ +void mttcg_kick_vcpu_thread (CPUState *cpu); + +/* start an mttcg vCPU thread */ +void mttcg_start_vcpu_thread (CPUState *cpu); + +#endif /* TCG_CPUS_MTTCG_H */
accel/tcg/tcg-cpus-rr.c +0 -7
@@ -296,10 +296,3 @@ void rr_start_vcpu_thread(CPUState *cpu) cpu->created = true; } } - -const CpusAccel tcg_cpus_rr = { - .create_vcpu_thread = rr_start_vcpu_thread, - .kick_vcpu_thread = rr_kick_vcpu_thread, - - .handle_interrupt = tcg_cpus_handle_interrupt, -};
accel/tcg/tcg-cpus.c +43 -0
52 lines not on this page · raw message
accel/tcg/tcg-cpus.h +0 -4
@@ -14,10 +14,6 @@#include "sysemu/cpus.h" -extern const CpusAccel tcg_cpus_mttcg; -extern const CpusAccel tcg_cpus_icount; -extern const CpusAccel tcg_cpus_rr; -void tcg_cpus_destroy (CPUState *cpu);int tcg_cpus_exec (CPUState *cpu);void tcg_cpus_handle_interrupt (CPUState *cpu,int mask);
accel/xen/xen-all.c +15 -7
@@ -154,10 +154,6 @@ static void xen_setup_post(MachineState *ms, AccelState *accel) } } -const CpusAccel xen_cpus = { - .create_vcpu_thread = dummy_start_vcpu_thread, -}; -static int xen_init (MachineState *ms) {MachineClass *mc =MACHINE_GET_CLASS (ms);
@@ -185,9 +181,6 @@ static int xen_init(MachineState *ms)* opt out of system RAM being allocated by generic code */ mc->default_ram_id =NULL ; - -cpus_register_accel (&xen_cpus); -return 0 ; }
@@ -222,9 +215,24 @@ static const TypeInfo xen_accel_type = { .class_init = xen_accel_class_init, }; +static void xen_cpus_class_init (ObjectClass *oc,void *data) +{ +AccelOpsClass *ops =ACCEL_OPS_CLASS (oc); + + ops->create_vcpu_thread = dummy_start_vcpu_thread; +}; +static const TypeInfo xen_cpus_type_info = { + .name =ACCEL_OPS_NAME ("xen" ), + + .parent =TYPE_ACCEL_OPS , + .class_init = xen_cpus_class_init, + .abstract = true, +}; +static void xen_type_init (void ) {type_register_static (&xen_accel_type); +type_register_static (&xen_cpus_type_info); }type_init (xen_type_init);
bsd-user/main.c +2 -1
@@ -908,13 +908,14 @@ int main(int argc, char **argv)#endif } + cpu_type =parse_cpu_option (cpu_model);/* init tcg before creating CPUs and to get qemu_host_page_size */ {AccelClass *ac =ACCEL_GET_CLASS (current_accel ()); ac->init_machine (NULL ); +accel_init_interfaces (ac); } - cpu_type =parse_cpu_option (cpu_model); cpu =cpu_create (cpu_type); env = cpu->env_ptr;#if defined(TARGET_SPARC ) || defined(TARGET_PPC )
include/qemu/accel.h +2 -0
@@ -69,6 +69,8 @@ typedef struct AccelClass {AccelClass *accel_find (const char *opt_name);AccelState *current_accel (void ); +void accel_init_interfaces (AccelClass *ac); +#ifndef CONFIG_USER_ONLY int accel_init_machine (AccelState *accel,MachineState *ms);
include/sysemu/accel-ops.h new file +45 -0
45 lines not on this page · raw message
include/sysemu/cpus.h +5 -21
@@ -2,30 +2,14 @@#define QEMU_CPUS_H #include "qemu/timer.h" +#include "sysemu/accel-ops.h" -/* cpus.c */ +/* register accel-specific operations */ +void cpus_register_accel (const AccelOpsClass *i); -/* CPU execution threads */ +/* accel/dummy-cpus.c */ -typedef struct CpusAccel { -void (*create_vcpu_thread)(CPUState *cpu);/* MANDATORY */ -void (*kick_vcpu_thread)(CPUState *cpu); - -void (*synchronize_post_reset)(CPUState *cpu); -void (*synchronize_post_init)(CPUState *cpu); -void (*synchronize_state)(CPUState *cpu); -void (*synchronize_pre_loadvm)(CPUState *cpu); - -void (*handle_interrupt)(CPUState *cpu,int mask); - -int64_t (*get_virtual_clock)(void ); -int64_t (*get_elapsed_ticks)(void ); -}CpusAccel ; - -/* register accel-specific cpus interface implementation */ -void cpus_register_accel (const CpusAccel *i); - -/* Create a dummy vcpu for CpusAccel->create_vcpu_thread */ +/* Create a dummy vcpu for AccelOpsClass->create_vcpu_thread */ void dummy_start_vcpu_thread (CPUState *);/* interface available for cpus accelerator threads */
linux-user/main.c +1 -0
@@ -708,6 +708,7 @@ int main(int argc, char **argv, char **envp)AccelClass *ac =ACCEL_GET_CLASS (current_accel ()); ac->init_machine (NULL ); +accel_init_interfaces (ac); } cpu =cpu_create (cpu_type); env = cpu->env_ptr;
softmmu/cpus.c +6 -6
@@ -127,7 +127,7 @@ void hw_error(const char *fmt, ...)/* * The chosen accelerator is supposed to register this. */ -static const CpusAccel *cpus_accel; +static const AccelOpsClass *cpus_accel;void cpu_synchronize_all_states (void ) {
@@ -593,11 +593,11 @@ void cpu_remove_sync(CPUState *cpu)qemu_mutex_lock_iothread (); } -void cpus_register_accel (const CpusAccel *ca) +void cpus_register_accel (const AccelOpsClass *ops) { -assert (ca !=NULL ); -assert (ca->create_vcpu_thread !=NULL );/* mandatory */ - cpus_accel = ca; +assert (ops !=NULL ); +assert (ops->create_vcpu_thread !=NULL );/* mandatory */ + cpus_accel = ops; }void qemu_init_vcpu (CPUState *cpu)
@@ -617,7 +617,7 @@ void qemu_init_vcpu(CPUState *cpu)cpu_address_space_init (cpu,0 ,"cpu-memory" , cpu->memory); } -/* accelerators all implement the CpusAccel interface */ +/* accelerators all implement the AccelOpsClass */ g_assert (cpus_accel !=NULL && cpus_accel->create_vcpu_thread !=NULL ); cpus_accel->create_vcpu_thread (cpu);
softmmu/vl.c +4 -2
@@ -2558,7 +2558,7 @@ static bool object_create_initial(const char *type, QemuOpts *opts) }/* Memory allocation by backends needs to be done -* after configure_accelerator() (due to the tcg_enabled() +* after do_configure_accelerator() (due to the tcg_enabled() * checks at memory_region_init_*()). * * Also, allocation of large amounts of memory may delay
@@ -4186,7 +4186,7 @@ void qemu_init(int argc, char **argv, char **envp)* * Machine compat properties: object_set_machine_compat_props(). * Accelerator compat props: object_set_accelerator_compat_props(), -* called from configure_accelerator(). +* called from do_configure_accelerator(). */ if (!qtest_enabled () && machine_class->deprecation_reason) {
@@ -4321,6 +4321,8 @@ void qemu_init(int argc, char **argv, char **envp)if (cpu_option) { current_machine->cpu_type =parse_cpu_option (cpu_option); } +/* NB: for machine none cpu_type could STILL be NULL here! */ +accel_init_interfaces (ACCEL_GET_CLASS (current_machine->accelerator));if (current_machine->ram_memdev_id) {Object *backend;
target/i386/hax/hax-all.c +0 -3
@@ -364,9 +364,6 @@ static int hax_accel_init(MachineState *ms) !ret ?"working" :"not working" , !ret ? "fast virt" : "emulation"); } -if (ret ==0 ) { -cpus_register_accel (&hax_cpus); - }return ret; }
target/i386/hax/hax-cpus.c +22 -7
@@ -74,12 +74,27 @@ static void hax_start_vcpu_thread(CPUState *cpu)#endif } -const CpusAccel hax_cpus = { - .create_vcpu_thread = hax_start_vcpu_thread, - .kick_vcpu_thread = hax_kick_vcpu_thread, +static void hax_cpus_class_init (ObjectClass *oc,void *data) +{ +AccelOpsClass *ops =ACCEL_OPS_CLASS (oc); - .synchronize_post_reset = hax_cpu_synchronize_post_reset, - .synchronize_post_init = hax_cpu_synchronize_post_init, - .synchronize_state = hax_cpu_synchronize_state, - .synchronize_pre_loadvm = hax_cpu_synchronize_pre_loadvm, + ops->create_vcpu_thread = hax_start_vcpu_thread; + ops->kick_vcpu_thread = hax_kick_vcpu_thread; + + ops->synchronize_post_reset = hax_cpu_synchronize_post_reset; + ops->synchronize_post_init = hax_cpu_synchronize_post_init; + ops->synchronize_state = hax_cpu_synchronize_state; + ops->synchronize_pre_loadvm = hax_cpu_synchronize_pre_loadvm; +}; +static const TypeInfo hax_cpus_type_info = { + .name =ACCEL_OPS_NAME ("hax" ), + + .parent =TYPE_ACCEL_OPS , + .class_init = hax_cpus_class_init, + .abstract = true, }; +static void hax_cpus_register_types (void ) +{ +type_register_static (&hax_cpus_type_info); +} +type_init (hax_cpus_register_types);
target/i386/hax/hax-cpus.h +0 -2
@@ -12,8 +12,6 @@#include "sysemu/cpus.h" -extern const CpusAccel hax_cpus; -#include "hax-interface.h" #include "hax-i386.h"
target/i386/hvf/hvf-cpus.c +21 -6
@@ -121,11 +121,26 @@ static void hvf_start_vcpu_thread(CPUState *cpu) cpu, QEMU_THREAD_JOINABLE); } -const CpusAccel hvf_cpus = { - .create_vcpu_thread = hvf_start_vcpu_thread, +static void hvf_cpus_class_init (ObjectClass *oc,void *data) +{ +AccelOpsClass *ops =ACCEL_OPS_CLASS (oc); - .synchronize_post_reset = hvf_cpu_synchronize_post_reset, - .synchronize_post_init = hvf_cpu_synchronize_post_init, - .synchronize_state = hvf_cpu_synchronize_state, - .synchronize_pre_loadvm = hvf_cpu_synchronize_pre_loadvm, + ops->create_vcpu_thread = hvf_start_vcpu_thread; + + ops->synchronize_post_reset = hvf_cpu_synchronize_post_reset; + ops->synchronize_post_init = hvf_cpu_synchronize_post_init; + ops->synchronize_state = hvf_cpu_synchronize_state; + ops->synchronize_pre_loadvm = hvf_cpu_synchronize_pre_loadvm; +}; +static const TypeInfo hvf_cpus_type_info = { + .name =ACCEL_OPS_NAME ("hvf" ), + + .parent =TYPE_ACCEL_OPS , + .class_init = hvf_cpus_class_init, + .abstract = true, }; +static void hvf_cpus_register_types (void ) +{ +type_register_static (&hvf_cpus_type_info); +} +type_init (hvf_cpus_register_types);
target/i386/hvf/hvf-cpus.h +0 -2
@@ -12,8 +12,6 @@#include "sysemu/cpus.h" -extern const CpusAccel hvf_cpus; -int hvf_init_vcpu (CPUState *);int hvf_vcpu_exec (CPUState *);void hvf_cpu_synchronize_state (CPUState *);
target/i386/hvf/hvf.c +0 -1
@@ -887,7 +887,6 @@ static int hvf_accel_init(MachineState *ms) hvf_state = s;memory_listener_register (&hvf_memory_listener, &address_space_memory); -cpus_register_accel (&hvf_cpus);return 0 ; }
target/i386/whpx/whpx-all.c +0 -2
@@ -1642,8 +1642,6 @@ static int whpx_accel_init(MachineState *ms)whpx_memory_init (); -cpus_register_accel (&whpx_cpus); -printf ("Windows Hypervisor Platform accelerator is operational\n" );return 0 ;
target/i386/whpx/whpx-cpus.c +22 -7
@@ -85,12 +85,27 @@ static void whpx_kick_vcpu_thread(CPUState *cpu) } } -const CpusAccel whpx_cpus = { - .create_vcpu_thread = whpx_start_vcpu_thread, - .kick_vcpu_thread = whpx_kick_vcpu_thread, +static void whpx_cpus_class_init (ObjectClass *oc,void *data) +{ +AccelOpsClass *ops =ACCEL_OPS_CLASS (oc); - .synchronize_post_reset = whpx_cpu_synchronize_post_reset, - .synchronize_post_init = whpx_cpu_synchronize_post_init, - .synchronize_state = whpx_cpu_synchronize_state, - .synchronize_pre_loadvm = whpx_cpu_synchronize_pre_loadvm, + ops->create_vcpu_thread = whpx_start_vcpu_thread; + ops->kick_vcpu_thread = whpx_kick_vcpu_thread; + + ops->synchronize_post_reset = whpx_cpu_synchronize_post_reset; + ops->synchronize_post_init = whpx_cpu_synchronize_post_init; + ops->synchronize_state = whpx_cpu_synchronize_state; + ops->synchronize_pre_loadvm = whpx_cpu_synchronize_pre_loadvm; +}; +static const TypeInfo whpx_cpus_type_info = { + .name =ACCEL_OPS_NAME ("whpx" ), + + .parent =TYPE_ACCEL_OPS , + .class_init = whpx_cpus_class_init, + .abstract = true, }; +static void whpx_cpus_register_types (void ) +{ +type_register_static (&whpx_cpus_type_info); +} +type_init (whpx_cpus_register_types);
target/i386/whpx/whpx-cpus.h +0 -2
@@ -12,8 +12,6 @@#include "sysemu/cpus.h" -extern const CpusAccel whpx_cpus; -int whpx_init_vcpu (CPUState *cpu);int whpx_vcpu_exec (CPUState *cpu);void whpx_destroy_vcpu (CPUState *cpu);
Signature · 1 line
2.26.2
Re: [RFC v9 27/32] accel: replace struct CpusAccel with AccelOpsClass
Quoted 4 lines · Claudio Fontana
centralize the registration of the
cpus.cmodule
accelerator operations inaccel/accel-softmmu.cSigned-off-by Claudio Fontana <[email protected]>
<snip>
Quoted 29 lines
accel/tcg/tcg-cpus.c +14
-0@@ -35,6 +35,9 @@#include "hw/boards.h" #include "tcg-cpus.h" +#include "tcg-cpus-mttcg.h" +#include "tcg-cpus-rr.h" +#include "tcg-cpus-icount.h" /* common functionality among all TCG variants */ @@ -80,3 +83,43 @@ void tcg_cpus_handle_interrupt(CPUState *cpu, int mask)qatomic_set (&cpu_neg (cpu)->icount_decr.u16.high,-1 ); } } + +static void tcg_cpus_ops_init (AccelOpsClass *ops) +{ +if (qemu_tcg_mttcg_enabled ()) { + ops->create_vcpu_thread = mttcg_start_vcpu_thread; + ops->kick_vcpu_thread = mttcg_kick_vcpu_thread; + ops->handle_interrupt = tcg_cpus_handle_interrupt; + + }else if (icount_enabled ()) { + ops->create_vcpu_thread = rr_start_vcpu_thread; + ops->kick_vcpu_thread = rr_kick_vcpu_thread;
accel/tcg/tcg-cpus.c void tcg_cpus_handle_interrupt(CPUState *cpu, int mask) · line 106
Quoted 10 lines
accel/tcg/tcg-cpus.c +10
-0+ ops->handle_interrupt = icount_handle_interrupt; + ops->get_virtual_clock = icount_get; + ops->get_elapsed_ticks = icount_get; + + }else { + ops->create_vcpu_thread = rr_start_vcpu_thread; + ops->kick_vcpu_thread = rr_kick_vcpu_thread; + ops->handle_interrupt = tcg_cpus_handle_interrupt; + } +}
Aren't we going backwards here by having a global function aware of the different accelerator types rather than encapsulating this is the particular accelerator machinery?
<snip>
Signature · 1 line
Alex Bennée
Re: [RFC v9 27/32] accel: replace struct CpusAccel with AccelOpsClass
Quoted 52 lines · Alex Bennée
Quoted 4 lines · Claudio Fontana
centralize the registration of the
cpus.cmodule
accelerator operations inaccel/accel-softmmu.cSigned-off-by Claudio Fontana <[email protected]><snip>
Quoted 29 lines
accel/tcg/tcg-cpus.c +14
-0@@ -35,6 +35,9 @@#include "hw/boards.h" #include "tcg-cpus.h" +#include "tcg-cpus-mttcg.h" +#include "tcg-cpus-rr.h" +#include "tcg-cpus-icount.h" /* common functionality among all TCG variants */ @@ -80,3 +83,43 @@ void tcg_cpus_handle_interrupt(CPUState *cpu, int mask)qatomic_set (&cpu_neg (cpu)->icount_decr.u16.high,-1 ); } } + +static void tcg_cpus_ops_init (AccelOpsClass *ops) +{ +if (qemu_tcg_mttcg_enabled ()) { + ops->create_vcpu_thread = mttcg_start_vcpu_thread; + ops->kick_vcpu_thread = mttcg_kick_vcpu_thread; + ops->handle_interrupt = tcg_cpus_handle_interrupt; + + }else if (icount_enabled ()) { + ops->create_vcpu_thread = rr_start_vcpu_thread; + ops->kick_vcpu_thread = rr_kick_vcpu_thread;accel/tcg/tcg-cpus.c void tcg_cpus_handle_interrupt(CPUState *cpu, int mask) · line 106
Quoted 10 lines
accel/tcg/tcg-cpus.c +10
-0+ ops->handle_interrupt = icount_handle_interrupt; + ops->get_virtual_clock = icount_get; + ops->get_elapsed_ticks = icount_get; + + }else { + ops->create_vcpu_thread = rr_start_vcpu_thread; + ops->kick_vcpu_thread = rr_kick_vcpu_thread; + ops->handle_interrupt = tcg_cpus_handle_interrupt; + } +}Aren't we going backwards here by having a global function aware of the different accelerator types rather than encapsulating this is the particular accelerator machinery?
Quoted 2 lines
<snip>
I don't fully understand what you mean here, which is the global function, what is the particular accelerator machinery?
Could you suggest an alternative for my understanding?
Thanks a lot,
Claudio
Re: [RFC v9 27/32] accel: replace struct CpusAccel with AccelOpsClass
In reply to Alex BennéeQuoted 52 lines · Alex Bennée
Quoted 4 lines · Claudio Fontana
centralize the registration of the
cpus.cmodule
accelerator operations inaccel/accel-softmmu.cSigned-off-by Claudio Fontana <[email protected]><snip>
Quoted 29 lines
accel/tcg/tcg-cpus.c +14
-0@@ -35,6 +35,9 @@#include "hw/boards.h" #include "tcg-cpus.h" +#include "tcg-cpus-mttcg.h" +#include "tcg-cpus-rr.h" +#include "tcg-cpus-icount.h" /* common functionality among all TCG variants */ @@ -80,3 +83,43 @@ void tcg_cpus_handle_interrupt(CPUState *cpu, int mask)qatomic_set (&cpu_neg (cpu)->icount_decr.u16.high,-1 ); } } + +static void tcg_cpus_ops_init (AccelOpsClass *ops) +{ +if (qemu_tcg_mttcg_enabled ()) { + ops->create_vcpu_thread = mttcg_start_vcpu_thread; + ops->kick_vcpu_thread = mttcg_kick_vcpu_thread; + ops->handle_interrupt = tcg_cpus_handle_interrupt; + + }else if (icount_enabled ()) { + ops->create_vcpu_thread = rr_start_vcpu_thread; + ops->kick_vcpu_thread = rr_kick_vcpu_thread;accel/tcg/tcg-cpus.c void tcg_cpus_handle_interrupt(CPUState *cpu, int mask) · line 106
Quoted 10 lines
accel/tcg/tcg-cpus.c +10
-0+ ops->handle_interrupt = icount_handle_interrupt; + ops->get_virtual_clock = icount_get; + ops->get_elapsed_ticks = icount_get; + + }else { + ops->create_vcpu_thread = rr_start_vcpu_thread; + ops->kick_vcpu_thread = rr_kick_vcpu_thread; + ops->handle_interrupt = tcg_cpus_handle_interrupt; + } +}Aren't we going backwards here by having a global function aware of the different accelerator types rather than encapsulating this is the particular accelerator machinery?
Quoted 2 lines
<snip>
Now I got your point.
The ideal would be to have three classes. One called tcg-mttcg, one tcg-icount, one tcg-rr. The problem: backward compatibility I think, since currently we have only one accel, "tcg".
But, hmm maybe fixable, I'll take a look.
Thanks!
Claudio
Re: [RFC v9 27/32] accel: replace struct CpusAccel with AccelOpsClass
Quoted 56 lines · Claudio Fontana
Quoted 52 lines · Alex Bennée
Quoted 4 lines · Claudio Fontana
centralize the registration of the
cpus.cmodule
accelerator operations inaccel/accel-softmmu.cSigned-off-by Claudio Fontana <[email protected]><snip>
Quoted 29 lines
accel/tcg/tcg-cpus.c +14
-0@@ -35,6 +35,9 @@#include "hw/boards.h" #include "tcg-cpus.h" +#include "tcg-cpus-mttcg.h" +#include "tcg-cpus-rr.h" +#include "tcg-cpus-icount.h" /* common functionality among all TCG variants */ @@ -80,3 +83,43 @@ void tcg_cpus_handle_interrupt(CPUState *cpu, int mask)qatomic_set (&cpu_neg (cpu)->icount_decr.u16.high,-1 ); } } + +static void tcg_cpus_ops_init (AccelOpsClass *ops) +{ +if (qemu_tcg_mttcg_enabled ()) { + ops->create_vcpu_thread = mttcg_start_vcpu_thread; + ops->kick_vcpu_thread = mttcg_kick_vcpu_thread; + ops->handle_interrupt = tcg_cpus_handle_interrupt; + + }else if (icount_enabled ()) { + ops->create_vcpu_thread = rr_start_vcpu_thread; + ops->kick_vcpu_thread = rr_kick_vcpu_thread;accel/tcg/tcg-cpus.c void tcg_cpus_handle_interrupt(CPUState *cpu, int mask) · line 106
Quoted 10 lines
accel/tcg/tcg-cpus.c +10
-0+ ops->handle_interrupt = icount_handle_interrupt; + ops->get_virtual_clock = icount_get; + ops->get_elapsed_ticks = icount_get; + + }else { + ops->create_vcpu_thread = rr_start_vcpu_thread; + ops->kick_vcpu_thread = rr_kick_vcpu_thread; + ops->handle_interrupt = tcg_cpus_handle_interrupt; + } +}Aren't we going backwards here by having a global function aware of the different accelerator types rather than encapsulating this is the particular accelerator machinery?
Quoted 2 lines
<snip>
Quoted 6 lines
Now I got your point.
The ideal would be to have three classes. One called tcg-mttcg, one tcg-icount, one tcg-rr. The problem: backward compatibility I think, since currently we have only one accel, "tcg".
But, hmm maybe fixable, I'll take a look.
Yeah I was wondering if we were going to have subclasses for each "type" of TCG. But now I'm wondering if that even makes sense. Will we ever want to built a TCG enabled binary that say doesn't do icount? Maybe not - having a single AccelOpsClass which runs in 3 modes will probably do for now.
Quoted 4 lines
Thanks!
Claudio
Signature · 1 line
Alex Bennée
Re: [RFC v9 27/32] accel: replace struct CpusAccel with AccelOpsClass
Quoted 64 lines · Alex Bennée
Quoted 61 lines · Claudio Fontana
Quoted 52 lines · Alex Bennée
Quoted 4 lines · Claudio Fontana
centralize the registration of the
cpus.cmodule
accelerator operations inaccel/accel-softmmu.cSigned-off-by Claudio Fontana <[email protected]><snip>
Quoted 29 lines
accel/tcg/tcg-cpus.c +14
-0@@ -35,6 +35,9 @@#include "hw/boards.h" #include "tcg-cpus.h" +#include "tcg-cpus-mttcg.h" +#include "tcg-cpus-rr.h" +#include "tcg-cpus-icount.h" /* common functionality among all TCG variants */ @@ -80,3 +83,43 @@ void tcg_cpus_handle_interrupt(CPUState *cpu, int mask)qatomic_set (&cpu_neg (cpu)->icount_decr.u16.high,-1 ); } } + +static void tcg_cpus_ops_init (AccelOpsClass *ops) +{ +if (qemu_tcg_mttcg_enabled ()) { + ops->create_vcpu_thread = mttcg_start_vcpu_thread; + ops->kick_vcpu_thread = mttcg_kick_vcpu_thread; + ops->handle_interrupt = tcg_cpus_handle_interrupt; + + }else if (icount_enabled ()) { + ops->create_vcpu_thread = rr_start_vcpu_thread; + ops->kick_vcpu_thread = rr_kick_vcpu_thread;accel/tcg/tcg-cpus.c void tcg_cpus_handle_interrupt(CPUState *cpu, int mask) · line 106
Quoted 10 lines
accel/tcg/tcg-cpus.c +10
-0+ ops->handle_interrupt = icount_handle_interrupt; + ops->get_virtual_clock = icount_get; + ops->get_elapsed_ticks = icount_get; + + }else { + ops->create_vcpu_thread = rr_start_vcpu_thread; + ops->kick_vcpu_thread = rr_kick_vcpu_thread; + ops->handle_interrupt = tcg_cpus_handle_interrupt; + } +}Aren't we going backwards here by having a global function aware of the different accelerator types rather than encapsulating this is the particular accelerator machinery?
Quoted 2 lines
<snip>
Now I got your point.
The ideal would be to have three classes. One called tcg-mttcg, one tcg-icount, one tcg-rr. The problem: backward compatibility I think, since currently we have only one accel, "tcg".
Quoted 7 lines
Quoted 1 line
But, hmm maybe fixable, I'll take a look.
Yeah I was wondering if we were going to have subclasses for each "type" of TCG. But now I'm wondering if that even makes sense. Will we ever want to built a TCG enabled binary that say doesn't do icount? Maybe not - having a single AccelOpsClass which runs in 3 modes will probably do for now.
Ok, I think you have a point there, so if you find a way we could subclass and not break backward compatibility in a non-super-convoluted way, I am all ears, thanks a lot!
Ciao,
Claudio
RFC v9 28/32 accel: introduce AccelCPUClass extending CPUClass
In reply to Claudio Fontanaadd a new optional interface to CPUClass, which allows accelerators to extend the CPUClass with additional accelerator-specific initializations.
--- MAINTAINERS | 1 + accel/accel-common.c | 44 +++++++++++++++++++++++++++++++++++++ include/hw/core/accel-cpu.h | 25 +++++++++++++++++++++ include/hw/core/cpu.h | 13 +++++++++++ 4 files changed, 83 insertions(+) create mode 100644 include/hw/core/accel-cpu.h
MAINTAINERS +1 -0
@@ -436,6 +436,7 @@ R: Paolo Bonzini <[email protected]> S: Maintained F: include/qemu/accel.h F: include/sysemu/accel-ops.h +F: include/hw/core/accel-cpu.h F: accel/accel-*.c F: accel/Makefile.objs F: accel/stubs/Makefile.objs
accel/accel-common.c +44 -0
66 lines not on this page · raw message
include/hw/core/accel-cpu.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* Accelerator interface, specializes CPUClass +* +* Copyright 2020 SUSE LLC +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef ACCEL_CPU_H +#define ACCEL_CPU_H + +/* +* these defines cannot be in cpu.h, because we are using +* CPU_RESOLVING_TYPE here. +* Use this header to define your accelerator-specific +* cpu-specific accelerator interfaces. +*/ + +#define TYPE_ACCEL_CPU "accel-" CPU_RESOLVING_TYPE +#define ACCEL_CPU_NAME (name) (name "-" TYPE_ACCEL_CPU) +typedef struct AccelCPUClass AccelCPUClass ; +DECLARE_CLASS_CHECKERS(AccelCPUClass, ACCEL_CPU, TYPE_ACCEL_CPU) + +#endif /* ACCEL_CPU_H */
include/hw/core/cpu.h +13 -0
@@ -76,6 +76,17 @@ typedef struct CPUWatchpoint CPUWatchpoint;struct TranslationBlock ; +/* see also accel-cpu.h */ +typedef struct AccelCPUClass { +/*< private >*/ +ObjectClass parent_class; +/*< public >*/ + +void (*cpu_class_init)(CPUClass *cc); +void (*cpu_instance_init)(CPUState *cpu); +void (*cpu_realizefn)(CPUState *cpu,Error **errp); +}AccelCPUClass ; +#ifdef CONFIG_TCG #include "tcg-cpu-ops.h" #endif /* CONFIG_TCG */
@@ -196,6 +207,8 @@ struct CPUClass {#ifdef CONFIG_TCG TcgCpuOperations tcg_ops;#endif /* CONFIG_TCG */ + +AccelCPUClass *accel_cpu_interface; };/*
Signature · 1 line
2.26.2
RFC v9 29/32 i386: split cpu accelerators from cpu.c, using AccelCPUClass
In reply to Claudio Fontanai386 is the first user of AccelCPUClass, allowing to split cpu.c into:
cpu.c cpuid and common x86 cpu functionality host-cpu.c host x86 cpu functions and "host" cpu type kvm/cpu.c KVM x86 AccelCPUClass hvf/cpu.c HVF x86 AccelCPUClass tcg/cpu.c TCG x86 AccelCPUClass
--- MAINTAINERS | 2 +- hw/i386/pc_piix.c | 1 + target/i386/cpu.c | 386 ++++-------------------------------- target/i386/cpu.h | 20 +- target/i386/host-cpu.c | 198 ++++++++++++++++++ target/i386/host-cpu.h | 19 ++ target/i386/hvf/cpu.c | 65 ++++++ target/i386/hvf/meson.build | 1 + target/i386/kvm/cpu.c | 148 ++++++++++++++ target/i386/kvm/kvm-cpu.h | 41 ++++ target/i386/kvm/kvm.c | 3 +- target/i386/kvm/meson.build | 7 +- target/i386/meson.build | 8 +- target/i386/tcg-cpu.c | 71 ------- target/i386/tcg-cpu.h | 15 -- target/i386/tcg/cpu.c | 173 ++++++++++++++++ target/i386/tcg/meson.build | 3 +- 17 files changed, 711 insertions(+), 450 deletions(-) create mode 100644 target/i386/host-cpu.c create mode 100644 target/i386/host-cpu.h create mode 100644 target/i386/hvf/cpu.c create mode 100644 target/i386/kvm/cpu.c create mode 100644 target/i386/kvm/kvm-cpu.h delete mode 100644 target/i386/tcg-cpu.c delete mode 100644 target/i386/tcg-cpu.h create mode 100644 target/i386/tcg/cpu.c
MAINTAINERS +1 -1
@@ -337,7 +337,7 @@ M: Paolo Bonzini <[email protected]> M: Richard Henderson <[email protected]> M: Eduardo Habkost <[email protected]> S: Maintained -F: target/i386/ +F: target/i386/tcg/ F: tests/tcg/i386/ F: tests/tcg/x86_64/ F: hw/i386/
hw/i386/pc_piix.c +1 -0
@@ -64,6 +64,7 @@#include "hw/hyperv/vmbus-bridge.h" #include "hw/mem/nvdimm.h" #include "hw/i386/acpi-build.h" +#include "kvm/kvm-cpu.h" #define MAX_IDE_BUS 2
target/i386/cpu.c +40 -346
550 lines not on this page · raw message
target/i386/cpu.h +8 -12
@@ -1905,13 +1905,20 @@ int cpu_x86_signal_handler(int host_signum, void *pinfo, void *puc);/* cpu.c */ +void x86_cpu_vendor_words2str (char *dst,uint32_t vendor1, +uint32_t vendor2,uint32_t vendor3); +typedef struct PropValue { +const char *prop, *value; +}PropValue ; +void x86_cpu_apply_props (X86CPU *cpu,PropValue *props); + +/* cpu.c other functions (cpuid) */ void cpu_x86_cpuid (CPUX86State *env,uint32_t index,uint32_t count,uint32_t *eax,uint32_t *ebx,uint32_t *ecx,uint32_t *edx);void cpu_clear_apic_feature (CPUX86State *env);void host_cpuid (uint32_t function,uint32_t count,uint32_t *eax,uint32_t *ebx,uint32_t *ecx,uint32_t *edx); -void host_vendor_fms (char *vendor,int *family,int *model,int *stepping);/* helper.c */ void x86_cpu_set_a20 (X86CPU *cpu,int a20_state);
@@ -2111,17 +2118,6 @@ void cpu_report_tpr_access(CPUX86State *env, TPRAccess access);void apic_handle_tpr_access_report (DeviceState *d,target_ulong ip,TPRAccess access); - -/* Change the value of a KVM-specific default -* -* If value is NULL, no default will be set and the original -* value from the CPU model table will be kept. -* -* It is valid to call this function only for properties that -* are already present in the kvm_default_props table. -*/ -void x86_cpu_change_kvm_default (const char *prop,const char *value); -/* Special values for X86CPUVersion: */ /* Resolve to latest CPU version */
target/i386/host-cpu.c new file +198 -0
198 lines not on this page · raw message
target/i386/host-cpu.h new file +19 -0
@@ -0,0 +1,19 @@ +/* +* x86 host CPU type initialization and host CPU functions +* +* Copyright 2020 SUSE LLC +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef HOST_CPU_H +#define HOST_CPU_H + +void host_cpu_instance_init (X86CPU *cpu); +void host_cpu_max_instance_init (X86CPU *cpu); +void host_cpu_realizefn (CPUState *cs,Error **errp); + +void host_cpu_vendor_fms (char *vendor,int *family,int *model,int *stepping); + +#endif /* HOST_CPU_H */
target/i386/hvf/cpu.c new file +65 -0
65 lines not on this page · raw message
target/i386/hvf/meson.build +1 -0
@@ -10,4 +10,5 @@ i386_softmmu_ss.add(when: [hvf, 'CONFIG_HVF'], if_true: files( 'x86_mmu.c', 'x86_task.c', 'x86hvf.c', + 'cpu.c', ))
target/i386/kvm/cpu.c new file +148 -0
148 lines not on this page · raw message
target/i386/kvm/kvm-cpu.h new file +41 -0
41 lines not on this page · raw message
target/i386/kvm/kvm.c +2 -1
@@ -22,6 +22,7 @@#include "standard-headers/asm-x86/kvm_para.h" #include "cpu.h" +#include "host-cpu.h" #include "sysemu/sysemu.h" #include "sysemu/hw_accel.h" #include "sysemu/kvm_int.h"
@@ -285,7 +286,7 @@ static bool host_tsx_broken(void)int family, model, stepping;\char vendor[CPUID_VENDOR_SZ +1 ]; -host_vendor_fms (vendor, &family, &model, &stepping); +host_cpu_vendor_fms (vendor, &family, &model, &stepping);/* Check if we are running on a Haswell host known to have broken TSX */ return !strcmp(vendor, CPUID_VENDOR_INTEL) &&
target/i386/kvm/meson.build +6 -1
@@ -1,3 +1,8 @@ i386_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c')) -i386_softmmu_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c')) + +i386_softmmu_ss.add(when: 'CONFIG_KVM', if_true: files( + 'kvm.c', + 'cpu.c', +)) + i386_softmmu_ss.add(when: 'CONFIG_HYPERV', if_true: files('hyperv.c'), if_false: files('hyperv-stub.c'))
target/i386/meson.build +6 -2
@@ -6,8 +6,12 @@ i386_ss.add(files( 'xsave_helper.c', 'cpu-dump.c', )) -i386_ss.add(when: 'CONFIG_TCG', if_true: files('tcg-cpu.c')) -i386_ss.add(when: 'CONFIG_SEV', if_true: files('sev.c'), if_false: files('sev-stub.c')) + +i386_ss.add(when: 'CONFIG_SEV', if_true: files('host-cpu.c', 'sev.c'), if_false: files('sev-stub.c')) + +# x86 cpu type +i386_ss.add(when: 'CONFIG_KVM', if_true: files('host-cpu.c')) +i386_ss.add(when: 'CONFIG_HVF', if_true: files('host-cpu.c')) i386_softmmu_ss = ss.source_set() i386_softmmu_ss.add(files(
target/i386/tcg-cpu.c deleted +0 -71
71 lines not on this page · raw message
target/i386/tcg-cpu.h deleted +0 -15
@@ -1,15 +0,0 @@ -/* -* i386 TCG CPU class initialization -* -* Copyright 2020 SUSE LLC -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -*/ - -#ifndef TCG_CPU_H -#define TCG_CPU_H - -void tcg_cpu_common_class_init (CPUClass *cc); - -#endif /* TCG_CPU_H */
target/i386/tcg/cpu.c new file +173 -0
173 lines not on this page · raw message
target/i386/tcg/meson.build +2 -1
@@ -10,4 +10,5 @@ i386_ss.add(when: 'CONFIG_TCG', if_true: files( 'seg_helper.c', 'smm_helper.c', 'svm_helper.c', - 'translate.c'), if_false: files('tcg-stub.c')) + 'translate.c', + 'cpu.c'), if_false: files('tcg-stub.c'))
Signature · 1 line
2.26.2
RFC v9 30/32 cpu: call AccelCPUClass::cpu_realizefn in cpu_exec_realizefn
In reply to Claudio Fontanamove the call to the accel_cpu_interface method to the general cpu_exec_realizefn from target/i386, so it does not need to be called for every target explicitly as we enable more targets.
--- cpu.c | 5 +++++ target/i386/cpu.c | 15 ++++----------- 2 files changed, 9 insertions(+), 11 deletions(-)
cpu.c +5 -0
@@ -130,6 +130,11 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp)cpu_list_add (cpu); +if (cc->accel_cpu_interface) { +/* NB: errp parameter is unused currently */ + cc->accel_cpu_interface->cpu_realizefn (cpu, errp); + } +#ifdef CONFIG_TCG /* NB: errp parameter is unused currently */ if (tcg_enabled ()) {
target/i386/cpu.c +4 -11
@@ -6280,16 +6280,16 @@ static void x86_cpu_filter_features(X86CPU *cpu, bool verbose)static void x86_cpu_realizefn (DeviceState *dev,Error **errp) {CPUState *cs =CPU (dev); -CPUClass *cc =CPU_GET_CLASS (cs);X86CPU *cpu =X86_CPU (dev);X86CPUClass *xcc =X86_CPU_GET_CLASS (dev);CPUX86State *env = &cpu->env;Error *local_err =NULL ;static bool ht_warned; -/* The accelerator realizefn needs to be called first. */ -if (cc->accel_cpu_interface) { - cc->accel_cpu_interface->cpu_realizefn (cs, errp); +cpu_exec_realizefn (cs, &local_err); +if (local_err !=NULL ) { +error_propagate (errp, local_err); +return ; }if (xcc->host_cpuid_required && !accel_uses_host_cpuid ()) {
@@ -6405,13 +6405,6 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) env->cache_info_amd.l3_cache = &legacy_l3_cache; } - -cpu_exec_realizefn (cs, &local_err); -if (local_err !=NULL ) { -error_propagate (errp, local_err); -return ; - } -#ifndef CONFIG_USER_ONLY MachineState *ms =MACHINE (qdev_get_machine ());qemu_register_reset (x86_cpu_machine_reset_cb, cpu);
Signature · 1 line
2.26.2
Quoted 9 lines · Claudio Fontana
v8 -> v9: move additional methods to
CPUClass->tcg_ops
do_unaligned_access,transaction_failedanddo_interrupt.
do_interruptis a bit tricky, as the same code is reused (albeit not usually directly) for KVM under certain odd conditions.Change arm, as the only user of
do_interruptcallback for KVM, to instead call the target function directlyarm_do_interrupt.
Please use scripts/git.orderfile for such refactors please ;)
...
Quoted 142 lines
MAINTAINERS | 19 +-
accel/accel-common.c | 105 +++++
accel/{accel.c => accel-softmmu.c} | 60 +--
accel/accel-softmmu.h | 15 +
accel/accel-user.c | 24 ++
accel/kvm/kvm-all.c | 2 -
accel/kvm/kvm-cpus.c | 26 +-
accel/kvm/kvm-cpus.h | 2 -
accel/meson.build | 4 +-
accel/qtest/qtest.c | 25 +-
accel/tcg/cpu-exec.c | 70 +++-
accel/tcg/cputlb.c | 6 +-
accel/tcg/meson.build | 9 +-
accel/tcg/tcg-all.c | 14 +-
accel/tcg/tcg-cpus-icount.c | 138 +++++++
accel/tcg/tcg-cpus-icount.h | 19 +
accel/tcg/tcg-cpus-mttcg.c | 134 +++++++
accel/tcg/tcg-cpus-mttcg.h | 19 +
accel/tcg/tcg-cpus-rr.c | 298 ++++++++++++++
accel/tcg/tcg-cpus-rr.h | 21 +
accel/tcg/tcg-cpus.c | 539 +++-----------------------
accel/tcg/tcg-cpus.h | 8 +-
accel/tcg/user-exec.c | 6 +-
accel/xen/xen-all.c | 24 +-
bsd-user/main.c | 11 +-
cpu.c | 71 ++--
hw/core/cpu.c | 30 +-
hw/i386/fw_cfg.c | 2 +-
hw/i386/intel_iommu.c | 2 +-
hw/i386/kvm/apic.c | 2 +-
hw/i386/kvm/clock.c | 2 +-
hw/i386/microvm.c | 2 +-
hw/i386/pc.c | 2 +-
hw/i386/pc_piix.c | 1 +
hw/i386/x86.c | 2 +-
hw/mips/jazz.c | 4 +-
include/hw/boards.h | 2 +-
include/hw/core/accel-cpu.h | 25 ++
include/hw/core/cpu.h | 92 ++---
include/hw/core/tcg-cpu-ops.h | 75 ++++
include/{sysemu => qemu}/accel.h | 16 +-
include/sysemu/accel-ops.h | 45 +++
include/sysemu/cpus.h | 26 +-
include/sysemu/hvf.h | 2 +-
include/sysemu/kvm.h | 2 +-
include/sysemu/kvm_int.h | 2 +-
linux-user/main.c | 7 +-
meson.build | 1 +
softmmu/cpus.c | 12 +-
softmmu/icount.c | 2 +-
softmmu/memory.c | 2 +-
softmmu/qtest.c | 2 +-
softmmu/vl.c | 8 +-
target/alpha/cpu.c | 18 +-
target/arm/cpu.c | 26 +-
target/arm/cpu64.c | 5 +-
target/arm/cpu_tcg.c | 8 +-
target/arm/helper.c | 4 +
target/arm/kvm64.c | 4 +-
target/avr/cpu.c | 13 +-
target/avr/helper.c | 4 +-
target/cris/cpu.c | 30 +-
target/cris/helper.c | 4 +-
target/hppa/cpu.c | 15 +-
target/i386/cpu-dump.c | 537 +++++++++++++++++++++++++
target/i386/cpu.c | 418 ++------------------
target/i386/cpu.h | 120 +-----
target/i386/{ => hax}/hax-all.c | 5 +-
target/i386/{ => hax}/hax-cpus.c | 29 +-
target/i386/{ => hax}/hax-cpus.h | 2 -
target/i386/{ => hax}/hax-i386.h | 6 +-
target/i386/{ => hax}/hax-interface.h | 0
target/i386/{ => hax}/hax-mem.c | 0
target/i386/{ => hax}/hax-posix.c | 0
target/i386/{ => hax}/hax-posix.h | 0
target/i386/{ => hax}/hax-windows.c | 0
target/i386/{ => hax}/hax-windows.h | 0
target/i386/hax/meson.build | 7 +
target/i386/helper-tcg.h | 112 ++++++
target/i386/helper.c | 539 +-------------------------
target/i386/host-cpu.c | 198 ++++++++++
target/i386/host-cpu.h | 19 +
target/i386/hvf/cpu.c | 65 ++++
target/i386/hvf/hvf-cpus.c | 27 +-
target/i386/hvf/hvf-cpus.h | 2 -
target/i386/hvf/hvf-i386.h | 2 +-
target/i386/hvf/hvf.c | 3 +-
target/i386/hvf/meson.build | 1 +
target/i386/hvf/x86_task.c | 2 +-
target/i386/kvm/cpu.c | 148 +++++++
target/i386/{ => kvm}/hyperv-proto.h | 0
target/i386/{ => kvm}/hyperv-stub.c | 0
target/i386/{ => kvm}/hyperv.c | 0
target/i386/{ => kvm}/hyperv.h | 0
target/i386/kvm/kvm-cpu.h | 41 ++
target/i386/{ => kvm}/kvm-stub.c | 0
target/i386/{ => kvm}/kvm.c | 3 +-
target/i386/{ => kvm}/kvm_i386.h | 0
target/i386/kvm/meson.build | 8 +
target/i386/kvm/trace-events | 7 +
target/i386/kvm/trace.h | 1 +
target/i386/machine.c | 4 +-
target/i386/meson.build | 39 +-
target/i386/{ => tcg}/bpt_helper.c | 1 +
target/i386/{ => tcg}/cc_helper.c | 1 +
target/i386/tcg/cpu.c | 173 +++++++++
target/i386/{ => tcg}/excp_helper.c | 1 +
target/i386/{ => tcg}/fpu_helper.c | 33 +-
target/i386/{ => tcg}/int_helper.c | 1 +
target/i386/{ => tcg}/mem_helper.c | 1 +
target/i386/tcg/meson.build | 14 +
target/i386/{ => tcg}/misc_helper.c | 1 +
target/i386/{ => tcg}/mpx_helper.c | 1 +
target/i386/{ => tcg}/seg_helper.c | 1 +
target/i386/{ => tcg}/smm_helper.c | 2 +
target/i386/{ => tcg}/svm_helper.c | 1 +
target/i386/{ => tcg}/tcg-stub.c | 0
target/i386/{ => tcg}/translate.c | 1 +
target/i386/trace-events | 6 -
target/i386/whpx/meson.build | 4 +
target/i386/{ => whpx}/whp-dispatch.h | 0
target/i386/{ => whpx}/whpx-all.c | 4 +-
target/i386/{ => whpx}/whpx-cpus.c | 29 +-
target/i386/{ => whpx}/whpx-cpus.h | 2 -
target/lm32/cpu.c | 13 +-
target/m68k/cpu.c | 12 +-
target/microblaze/cpu.c | 23 +-
target/mips/cpu.c | 21 +-
target/moxie/cpu.c | 10 +-
target/nios2/cpu.c | 14 +-
target/openrisc/cpu.c | 12 +-
target/ppc/translate_init.c.inc | 23 +-
target/riscv/cpu.c | 25 +-
target/rx/cpu.c | 18 +-
target/s390x/cpu.c | 15 +-
target/sh4/cpu.c | 14 +-
target/sparc/cpu.c | 18 +-
target/tilegx/cpu.c | 10 +-
target/tricore/cpu.c | 8 +-
target/unicore32/cpu.c | 14 +-
target/xtensa/cpu.c | 16 +-
141 files changed, 3007 insertions(+), 2051 deletions(-)...
Quoted 5 lines · Philippe Mathieu-Daudé
Quoted 4 lines · Claudio Fontana
v8 -> v9: move additional methods to
CPUClass->tcg_ops
do_unaligned_access,transaction_failedanddo_interrupt.
Quoted 7 lines
Quoted 5 lines
do_interruptis a bit tricky, as the same code is reused (albeit not usually directly) for KVM under certain odd conditions.Change arm, as the only user of
do_interruptcallback for KVM, to instead call the target function directlyarm_do_interrupt.Please use
scripts/git.orderfilefor such refactors please ;)
Aye aye!
If you'd like me to respin now, just let me know.
Ciao,
Claudio
Quoted 148 lines
...
Quoted 142 lines
MAINTAINERS | 19 +- accel/accel-common.c | 105 +++++ accel/{accel.c => accel-softmmu.c} | 60 +-- accel/accel-softmmu.h | 15 + accel/accel-user.c | 24 ++ accel/kvm/kvm-all.c | 2 - accel/kvm/kvm-cpus.c | 26 +- accel/kvm/kvm-cpus.h | 2 - accel/meson.build | 4 +- accel/qtest/qtest.c | 25 +- accel/tcg/cpu-exec.c | 70 +++- accel/tcg/cputlb.c | 6 +- accel/tcg/meson.build | 9 +- accel/tcg/tcg-all.c | 14 +- accel/tcg/tcg-cpus-icount.c | 138 +++++++ accel/tcg/tcg-cpus-icount.h | 19 + accel/tcg/tcg-cpus-mttcg.c | 134 +++++++ accel/tcg/tcg-cpus-mttcg.h | 19 + accel/tcg/tcg-cpus-rr.c | 298 ++++++++++++++ accel/tcg/tcg-cpus-rr.h | 21 + accel/tcg/tcg-cpus.c | 539 +++----------------------- accel/tcg/tcg-cpus.h | 8 +- accel/tcg/user-exec.c | 6 +- accel/xen/xen-all.c | 24 +- bsd-user/main.c | 11 +- cpu.c | 71 ++-- hw/core/cpu.c | 30 +- hw/i386/fw_cfg.c | 2 +- hw/i386/intel_iommu.c | 2 +- hw/i386/kvm/apic.c | 2 +- hw/i386/kvm/clock.c | 2 +- hw/i386/microvm.c | 2 +- hw/i386/pc.c | 2 +- hw/i386/pc_piix.c | 1 + hw/i386/x86.c | 2 +- hw/mips/jazz.c | 4 +- include/hw/boards.h | 2 +- include/hw/core/accel-cpu.h | 25 ++ include/hw/core/cpu.h | 92 ++--- include/hw/core/tcg-cpu-ops.h | 75 ++++ include/{sysemu => qemu}/accel.h | 16 +- include/sysemu/accel-ops.h | 45 +++ include/sysemu/cpus.h | 26 +- include/sysemu/hvf.h | 2 +- include/sysemu/kvm.h | 2 +- include/sysemu/kvm_int.h | 2 +- linux-user/main.c | 7 +- meson.build | 1 + softmmu/cpus.c | 12 +- softmmu/icount.c | 2 +- softmmu/memory.c | 2 +- softmmu/qtest.c | 2 +- softmmu/vl.c | 8 +- target/alpha/cpu.c | 18 +- target/arm/cpu.c | 26 +- target/arm/cpu64.c | 5 +- target/arm/cpu_tcg.c | 8 +- target/arm/helper.c | 4 + target/arm/kvm64.c | 4 +- target/avr/cpu.c | 13 +- target/avr/helper.c | 4 +- target/cris/cpu.c | 30 +- target/cris/helper.c | 4 +- target/hppa/cpu.c | 15 +- target/i386/cpu-dump.c | 537 +++++++++++++++++++++++++ target/i386/cpu.c | 418 ++------------------ target/i386/cpu.h | 120 +----- target/i386/{ => hax}/hax-all.c | 5 +- target/i386/{ => hax}/hax-cpus.c | 29 +- target/i386/{ => hax}/hax-cpus.h | 2 - target/i386/{ => hax}/hax-i386.h | 6 +- target/i386/{ => hax}/hax-interface.h | 0 target/i386/{ => hax}/hax-mem.c | 0 target/i386/{ => hax}/hax-posix.c | 0 target/i386/{ => hax}/hax-posix.h | 0 target/i386/{ => hax}/hax-windows.c | 0 target/i386/{ => hax}/hax-windows.h | 0 target/i386/hax/meson.build | 7 + target/i386/helper-tcg.h | 112 ++++++ target/i386/helper.c | 539 +------------------------- target/i386/host-cpu.c | 198 ++++++++++ target/i386/host-cpu.h | 19 + target/i386/hvf/cpu.c | 65 ++++ target/i386/hvf/hvf-cpus.c | 27 +- target/i386/hvf/hvf-cpus.h | 2 - target/i386/hvf/hvf-i386.h | 2 +- target/i386/hvf/hvf.c | 3 +- target/i386/hvf/meson.build | 1 + target/i386/hvf/x86_task.c | 2 +- target/i386/kvm/cpu.c | 148 +++++++ target/i386/{ => kvm}/hyperv-proto.h | 0 target/i386/{ => kvm}/hyperv-stub.c | 0 target/i386/{ => kvm}/hyperv.c | 0 target/i386/{ => kvm}/hyperv.h | 0 target/i386/kvm/kvm-cpu.h | 41 ++ target/i386/{ => kvm}/kvm-stub.c | 0 target/i386/{ => kvm}/kvm.c | 3 +- target/i386/{ => kvm}/kvm_i386.h | 0 target/i386/kvm/meson.build | 8 + target/i386/kvm/trace-events | 7 + target/i386/kvm/trace.h | 1 + target/i386/machine.c | 4 +- target/i386/meson.build | 39 +- target/i386/{ => tcg}/bpt_helper.c | 1 + target/i386/{ => tcg}/cc_helper.c | 1 + target/i386/tcg/cpu.c | 173 +++++++++ target/i386/{ => tcg}/excp_helper.c | 1 + target/i386/{ => tcg}/fpu_helper.c | 33 +- target/i386/{ => tcg}/int_helper.c | 1 + target/i386/{ => tcg}/mem_helper.c | 1 + target/i386/tcg/meson.build | 14 + target/i386/{ => tcg}/misc_helper.c | 1 + target/i386/{ => tcg}/mpx_helper.c | 1 + target/i386/{ => tcg}/seg_helper.c | 1 + target/i386/{ => tcg}/smm_helper.c | 2 + target/i386/{ => tcg}/svm_helper.c | 1 + target/i386/{ => tcg}/tcg-stub.c | 0 target/i386/{ => tcg}/translate.c | 1 + target/i386/trace-events | 6 - target/i386/whpx/meson.build | 4 + target/i386/{ => whpx}/whp-dispatch.h | 0 target/i386/{ => whpx}/whpx-all.c | 4 +- target/i386/{ => whpx}/whpx-cpus.c | 29 +- target/i386/{ => whpx}/whpx-cpus.h | 2 - target/lm32/cpu.c | 13 +- target/m68k/cpu.c | 12 +- target/microblaze/cpu.c | 23 +- target/mips/cpu.c | 21 +- target/moxie/cpu.c | 10 +- target/nios2/cpu.c | 14 +- target/openrisc/cpu.c | 12 +- target/ppc/translate_init.c.inc | 23 +- target/riscv/cpu.c | 25 +- target/rx/cpu.c | 18 +- target/s390x/cpu.c | 15 +- target/sh4/cpu.c | 14 +- target/sparc/cpu.c | 18 +- target/tilegx/cpu.c | 10 +- target/tricore/cpu.c | 8 +- target/unicore32/cpu.c | 14 +- target/xtensa/cpu.c | 16 +- 141 files changed, 3007 insertions(+), 2051 deletions(-)...
Quoted 9 lines · Claudio Fontana
Quoted 8 lines · Philippe Mathieu-Daudé
Quoted 7 lines · Claudio Fontana
v8 -> v9: move additional methods to
CPUClass->tcg_ops
do_unaligned_access,transaction_failedanddo_interrupt.
do_interruptis a bit tricky, as the same code is reused (albeit not usually directly) for KVM under certain odd conditions.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Change arm, as the only user of
do_interruptcallback for KVM, to instead call the target function directlyarm_do_interrupt.Please use
scripts/git.orderfilefor such refactors please ;)Aye aye!
If you'd like me to respin now, just let me know.
No, not needed thanks!
Paolo
RFC v9 31/32 hw/core/cpu: call qemu_init_vcpu in cpu_common_realizefn
In reply to Claudio Fontanamove the call to qemu_init_vcpu inside cpu_common_realizefn, so it does not need to be done explicitly in each target cpu.
This makes it a little bit better, but still the way realize is done continues to be bad; ideally the cpu_list_add would be done in common_cpu, and in this case we could avoid even more additional calls in target/xxx/cpu.c,
but this cannot happen because target cpu code, plugins, etc now all rely on cpu->index, since no particular order was defined previously, so we are stuck with the freak call order for the target cpu realizefn.
After this patch the target/xxx/cpu.c realizefn body is now:
void mycpu_realizefn(DeviceState *dev, Error **errp)
{
/* ... */
cpu_exec_realizefn(CPU_STATE(dev), errp);
/* ... anything that needs done pre-qemu_vcpu_init */
xcc->parent_realize(dev, errp); /* does qemu_vcpu_init */
/* ... anything that needs to be done after qemu_vcpu_init */
}Note: better do some testing for all targets for this.
--- hw/core/cpu.c | 2 ++ target/alpha/cpu.c | 5 +---- target/arm/cpu.c | 4 +--- target/avr/cpu.c | 3 +-- target/cris/cpu.c | 2 -- target/hppa/cpu.c | 1 - target/i386/cpu.c | 5 +---- target/lm32/cpu.c | 3 --- target/m68k/cpu.c | 2 -- target/microblaze/cpu.c | 9 +++------ target/mips/cpu.c | 2 -- target/moxie/cpu.c | 4 +--- target/nios2/cpu.c | 4 +--- target/openrisc/cpu.c | 4 +--- target/ppc/translate_init.c.inc | 5 ++--- target/riscv/cpu.c | 8 +++----- target/rx/cpu.c | 8 +++----- target/s390x/cpu.c | 3 +-- target/sh4/cpu.c | 2 -- target/sparc/cpu.c | 4 +--- target/tilegx/cpu.c | 2 -- target/tricore/cpu.c | 2 -- target/unicore32/cpu.c | 6 +----- target/xtensa/cpu.c | 2 -- 24 files changed, 23 insertions(+), 69 deletions(-)
hw/core/cpu.c +2 -0
@@ -318,6 +318,8 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp)CPUState *cpu =CPU (dev);Object *machine =qdev_get_machine (); +qemu_init_vcpu (cpu); +/* qdev_get_machine() can return something that's not TYPE_MACHINE * if this is one of the user-only emulators; in that case there's * no need to check the ignore_memory_transaction_failures board flag.
target/alpha/cpu.c +1 -4
@@ -56,18 +56,15 @@ static void alpha_cpu_disas_set_info(CPUState *cpu, disassemble_info *info)static void alpha_cpu_realizefn (DeviceState *dev,Error **errp) { -CPUState *cs =CPU (dev);AlphaCPUClass *acc =ALPHA_CPU_GET_CLASS (dev);Error *local_err =NULL ; -cpu_exec_realizefn (cs, &local_err); +cpu_exec_realizefn (CPU (dev), &local_err);if (local_err !=NULL ) {error_propagate (errp, local_err);return ; } -qemu_init_vcpu (cs); - acc->parent_realize (dev, errp); }
target/arm/cpu.c +1 -3
@@ -1859,10 +1859,8 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) } } -qemu_init_vcpu (cs); -cpu_reset (cs); - acc->parent_realize (dev, errp); +cpu_reset (cs); }static ObjectClass *arm_cpu_class_by_name (const char *cpu_model)
target/avr/cpu.c +1 -2
@@ -97,10 +97,9 @@ static void avr_cpu_realizefn(DeviceState *dev, Error **errp)error_propagate (errp, local_err);return ; } -qemu_init_vcpu (cs); -cpu_reset (cs); mcc->parent_realize (dev, errp); +cpu_reset (cs); }static void avr_cpu_set_int (void *opaque,int irq,int level)
target/cris/cpu.c +0 -2
@@ -135,8 +135,6 @@ static void cris_cpu_realizefn(DeviceState *dev, Error **errp) }cpu_reset (cs); -qemu_init_vcpu (cs); - ccc->parent_realize (dev, errp); }
target/hppa/cpu.c +0 -1
@@ -101,7 +101,6 @@ static void hppa_cpu_realizefn(DeviceState *dev, Error **errp)return ; } -qemu_init_vcpu (cs); acc->parent_realize (dev, errp);#ifndef CONFIG_USER_ONLY
target/i386/cpu.c +1 -4
@@ -6419,8 +6419,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)mce_init (cpu); -qemu_init_vcpu (cs); - + xcc->parent_realize (dev, &local_err);/* * Most Intel and certain AMD CPUs support hyperthreading. Even though QEMU * fixes this issue by adjusting CPUID_0000_0001_EBX and CPUID_8000_0008_ECX
@@ -6447,8 +6446,6 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) }cpu_reset (cs); - xcc->parent_realize (dev, &local_err); - out:if (local_err !=NULL ) {error_propagate (errp, local_err);
target/lm32/cpu.c +0 -3
@@ -133,9 +133,6 @@ static void lm32_cpu_realizefn(DeviceState *dev, Error **errp) }cpu_reset (cs); - -qemu_init_vcpu (cs); - lcc->parent_realize (dev, errp); }
target/m68k/cpu.c +0 -2
@@ -248,8 +248,6 @@ static void m68k_cpu_realizefn(DeviceState *dev, Error **errp)m68k_cpu_init_gdb (cpu);cpu_reset (cs); -qemu_init_vcpu (cs); - mcc->parent_realize (dev, errp); }
target/microblaze/cpu.c +3 -6
@@ -145,15 +145,14 @@ static void mb_disas_set_info(CPUState *cpu, disassemble_info *info)static void mb_cpu_realizefn (DeviceState *dev,Error **errp) { -CPUState *cs =CPU (dev);MicroBlazeCPUClass *mcc =MICROBLAZE_CPU_GET_CLASS (dev); -MicroBlazeCPU *cpu =MICROBLAZE_CPU (cs); +MicroBlazeCPU *cpu =MICROBLAZE_CPU (dev);uint8_t version_code =0 ;const char *version;int i =0 ;Error *local_err =NULL ; -cpu_exec_realizefn (cs, &local_err); +cpu_exec_realizefn (CPU (dev), &local_err);if (local_err !=NULL ) {error_propagate (errp, local_err);return ;
@@ -165,7 +164,7 @@ static void mb_cpu_realizefn(DeviceState *dev, Error **errp)return ; } -qemu_init_vcpu (cs); + mcc->parent_realize (dev, errp); version = cpu->cfg.version ? cpu->cfg.version :DEFAULT_CPU_VERSION ;for (i =0 ; mb_cpu_lookup[i].name && version; i++) {
@@ -231,8 +230,6 @@ static void mb_cpu_realizefn(DeviceState *dev, Error **errp) cpu->cfg.mmu_tlb_access =3 ; cpu->cfg.mmu_zones =16 ; cpu->cfg.addr_mask =MAKE_64BIT_MASK (0 , cpu->cfg.addr_size); - - mcc->parent_realize (dev, errp); }static void mb_cpu_initfn (Object *obj)
target/mips/cpu.c +0 -2
@@ -182,8 +182,6 @@ static void mips_cpu_realizefn(DeviceState *dev, Error **errp)cpu_mips_realize_env (&cpu->env);cpu_reset (cs); -qemu_init_vcpu (cs); - mcc->parent_realize (dev, errp); }
target/moxie/cpu.c +1 -3
@@ -66,10 +66,8 @@ static void moxie_cpu_realizefn(DeviceState *dev, Error **errp)return ; } -qemu_init_vcpu (cs); -cpu_reset (cs); - mcc->parent_realize (dev, errp); +cpu_reset (cs); }static void moxie_cpu_initfn (Object *obj)
target/nios2/cpu.c +1 -3
@@ -92,10 +92,8 @@ static void nios2_cpu_realizefn(DeviceState *dev, Error **errp)return ; } -qemu_init_vcpu (cs); -cpu_reset (cs); - ncc->parent_realize (dev, errp); +cpu_reset (cs); }static bool nios2_cpu_exec_interrupt (CPUState *cs,int interrupt_request)
target/openrisc/cpu.c +1 -3
@@ -77,10 +77,8 @@ static void openrisc_cpu_realizefn(DeviceState *dev, Error **errp)return ; } -qemu_init_vcpu (cs); -cpu_reset (cs); - occ->parent_realize (dev, errp); +cpu_reset (cs); }static void openrisc_cpu_initfn (Object *obj)
target/ppc/translate_init.c.inc +2 -3
@@ -10093,7 +10093,7 @@ static int ppc_fixup_cpu(PowerPCCPU *cpu) return 0; } -static void ppc_cpu_realize(DeviceState *dev, Error **errp) +static void ppc_cpu_realizefn(DeviceState *dev, Error **errp) { CPUState *cs = CPU(dev); PowerPCCPU *cpu = POWERPC_CPU(dev);
@@ -10143,7 +10143,6 @@ static void ppc_cpu_realize(DeviceState *dev, Error **errp) gdb_register_coprocessor(cs, gdb_get_spr_reg, gdb_set_spr_reg, pcc->gdb_num_sprs, "power-spr.xml", 0); #endif - qemu_init_vcpu(cs); pcc->parent_realize(dev, errp);
@@ -10894,7 +10893,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) CPUClass *cc = CPU_CLASS(oc); DeviceClass *dc = DEVICE_CLASS(oc); - device_class_set_parent_realize(dc, ppc_cpu_realize, + device_class_set_parent_realize(dc, ppc_cpu_realizefn, &pcc->parent_realize); device_class_set_parent_unrealize(dc, ppc_cpu_unrealize, &pcc->parent_unrealize);
target/riscv/cpu.c +3 -5
@@ -341,7 +341,7 @@ static void riscv_cpu_disas_set_info(CPUState *s, disassemble_info *info)#endif } -static void riscv_cpu_realize (DeviceState *dev,Error **errp) +static void riscv_cpu_realizefn (DeviceState *dev,Error **errp) {CPUState *cs =CPU (dev);RISCVCPU *cpu =RISCV_CPU (dev);
@@ -486,10 +486,8 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)riscv_cpu_register_gdb_regs_for_features (cs); -qemu_init_vcpu (cs); -cpu_reset (cs); - mcc->parent_realize (dev, errp); +cpu_reset (cs); }static void riscv_cpu_init (Object *obj)
@@ -532,7 +530,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data)CPUClass *cc =CPU_CLASS (c);DeviceClass *dc =DEVICE_CLASS (c); -device_class_set_parent_realize (dc, riscv_cpu_realize, +device_class_set_parent_realize (dc, riscv_cpu_realizefn, &mcc->parent_realize);device_class_set_parent_reset (dc, riscv_cpu_reset, &mcc->parent_reset);
target/rx/cpu.c +3 -5
@@ -105,7 +105,7 @@ static ObjectClass *rx_cpu_class_by_name(const char *cpu_model)return oc; } -static void rx_cpu_realize (DeviceState *dev,Error **errp) +static void rx_cpu_realizefn (DeviceState *dev,Error **errp) {CPUState *cs =CPU (dev);RXCPUClass *rcc =RX_CPU_GET_CLASS (dev);
@@ -117,10 +117,8 @@ static void rx_cpu_realize(DeviceState *dev, Error **errp)return ; } -qemu_init_vcpu (cs); -cpu_reset (cs); - rcc->parent_realize (dev, errp); +cpu_reset (cs); }static void rx_cpu_set_irq (void *opaque,int no,int request)
@@ -178,7 +176,7 @@ static void rx_cpu_class_init(ObjectClass *klass, void *data)CPUClass *cc =CPU_CLASS (klass);RXCPUClass *rcc =RX_CPU_CLASS (klass); -device_class_set_parent_realize (dc, rx_cpu_realize, +device_class_set_parent_realize (dc, rx_cpu_realizefn, &rcc->parent_realize);device_class_set_parent_reset (dc, rx_cpu_reset, &rcc->parent_reset);
target/s390x/cpu.c +1 -2
@@ -232,8 +232,8 @@ static void s390_cpu_realizefn(DeviceState *dev, Error **errp)qemu_register_reset (s390_cpu_machine_reset_cb, cpu);#endif s390_cpu_gdb_init (cs); -qemu_init_vcpu (cs); + scc->parent_realize (dev, &err);/* * KVM requires the initial CPU reset ioctl to be executed on the target * CPU thread. CPU hotplug under single-threaded TCG will not work with
@@ -246,7 +246,6 @@ static void s390_cpu_realizefn(DeviceState *dev, Error **errp)cpu_reset (cs); } - scc->parent_realize (dev, &err); out:error_propagate (errp, err); }
target/sh4/cpu.c +0 -2
@@ -185,8 +185,6 @@ static void superh_cpu_realizefn(DeviceState *dev, Error **errp) }cpu_reset (cs); -qemu_init_vcpu (cs); - scc->parent_realize (dev, errp); }
target/sparc/cpu.c +1 -3
@@ -738,9 +738,9 @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp) {CPUState *cs =CPU (dev);SPARCCPUClass *scc =SPARC_CPU_GET_CLASS (dev); -Error *local_err =NULL ;SPARCCPU *cpu =SPARC_CPU (dev);CPUSPARCState *env = &cpu->env; +Error *local_err =NULL ;#if defined(CONFIG_USER_ONLY )if ((env->def.features &CPU_FEATURE_FLOAT )) {
@@ -768,8 +768,6 @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp)return ; } -qemu_init_vcpu (cs); - scc->parent_realize (dev, errp); }
target/tilegx/cpu.c +0 -2
@@ -93,8 +93,6 @@ static void tilegx_cpu_realizefn(DeviceState *dev, Error **errp) }cpu_reset (cs); -qemu_init_vcpu (cs); - tcc->parent_realize (dev, errp); }
target/tricore/cpu.c +0 -2
@@ -93,8 +93,6 @@ static void tricore_cpu_realizefn(DeviceState *dev, Error **errp)set_feature (env,TRICORE_FEATURE_13 ); }cpu_reset (cs); -qemu_init_vcpu (cs); - tcc->parent_realize (dev, errp); }
target/unicore32/cpu.c +1 -5
@@ -84,18 +84,14 @@ static void uc32_any_cpu_initfn(Object *obj)static void uc32_cpu_realizefn (DeviceState *dev,Error **errp) { -CPUState *cs =CPU (dev);UniCore32CPUClass *ucc =UNICORE32_CPU_GET_CLASS (dev);Error *local_err =NULL ; -cpu_exec_realizefn (cs, &local_err); +cpu_exec_realizefn (CPU (dev), &local_err);if (local_err !=NULL ) {error_propagate (errp, local_err);return ; } - -qemu_init_vcpu (cs); - ucc->parent_realize (dev, errp); }
target/xtensa/cpu.c +0 -2
@@ -153,8 +153,6 @@ static void xtensa_cpu_realizefn(DeviceState *dev, Error **errp) cs->gdb_num_regs = xcc->config->gdb_regmap.num_regs; -qemu_init_vcpu (cs); - xcc->parent_realize (dev, errp); }
Signature · 1 line
2.26.2
RFC v9 32/32 cpu: introduce cpu_accel_instance_init
In reply to Claudio Fontanacentralize the calls to cpu->accel_cpu_interface
--- hw/core/cpu.c | 9 +++++++++ include/hw/core/cpu.h | 6 ++++++ target/i386/cpu.c | 9 ++------- 3 files changed, 17 insertions(+), 7 deletions(-)
hw/core/cpu.c +9 -0
@@ -242,6 +242,15 @@ void cpu_reset(CPUState *cpu)trace_guest_cpu_reset (cpu); } +void cpu_accel_instance_init (CPUState *cpu) +{ +CPUClass *cc =CPU_GET_CLASS (cpu); + +if (cc->accel_cpu_interface) { + cc->accel_cpu_interface->cpu_instance_init (cpu); + } +} +static void cpu_common_reset (DeviceState *dev) {CPUState *cpu =CPU (dev);
include/hw/core/cpu.h +6 -0
@@ -664,6 +664,12 @@ void cpu_list_remove(CPUState *cpu);*/ void cpu_reset (CPUState *cpu); +/** +* cpu_accel_instance_init: +* @cpu: The CPU that needs to do accel-specific object initializations. +*/ +void cpu_accel_instance_init (CPUState *cpu); +/** * cpu_class_by_name: * @typename: The CPU base type.
target/i386/cpu.c +2 -7
@@ -28,7 +28,6 @@#include "sysemu/kvm.h" #include "sysemu/reset.h" #include "sysemu/hvf.h" -#include "hw/core/accel-cpu.h" #include "sysemu/xen.h" #include "kvm/kvm_i386.h" #include "sev_i386.h"
@@ -6621,8 +6620,6 @@ static void x86_cpu_initfn(Object *obj) {X86CPU *cpu =X86_CPU (obj);X86CPUClass *xcc =X86_CPU_GET_CLASS (obj); -CPUClass *cc =CPU_CLASS (xcc); -CPUX86State *env = &cpu->env;FeatureWord w;
@@ -6680,10 +6677,8 @@ static void x86_cpu_initfn(Object *obj)x86_cpu_load_model (cpu, xcc->model); } -/* if required, do the accelerator-specific cpu initialization */ -if (cc->accel_cpu_interface) { - cc->accel_cpu_interface->cpu_instance_init (CPU (obj)); - } +/* if required, do accelerator-specific cpu initializations */ +cpu_accel_instance_init (CPU (obj)); }static int64_t x86_cpu_get_arch_id (CPUState *cs)
Signature · 1 line
2.26.2
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
Subject: [RFC v9 00/22] i386 cleanup
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
1df468e cpu: introduce cpu_accel_instance_init
273e6bc hw/core/cpu: call qemu_init_vcpu in cpu_common_realizefn 6c8c6a4 cpu: call AccelCPUClass::cpu_realizefn in cpu_exec_realizefn c7ecc11 i386: split cpu accelerators from cpu.c, using AccelCPUClass 739ef2b accel: introduce AccelCPUClass extending CPUClass 706469e accel: replace struct CpusAccel with AccelOpsClass c3aa222 accel: extend AccelState and AccelClass to user-mode c45684a cpu: move do_unaligned_access to tcg_ops
bca539a cpu: move cc->transaction_failed to tcg_ops 74feabd cpu: move cc->do_interrupt to tcg_ops
f22d896 target/arm: do not use cc->do_interrupt for KVM directly 9a74429 cpu: Move debug_excp_handler to tcg_ops
bf5b24b cpu: Move tlb_fill to tcg_ops
481a06e cpu: Move cpu_exec_* to tcg_ops
af72917 cpu: Move synchronize_from_tb() to tcg_ops f9b393d accel/tcg: split TCG-only code from cpu_exec_realizefn 2019e4f target/riscv: remove CONFIG_TCG, as it is always TCG 53b3f4e cpu: Introduce TCGCpuOperations struct
8a0c2e9 cpu: Remove unnecessary noop methods
043b89c tcg: Make CPUClass.debug_excp_handler optional b271ab4 tcg: make CPUClass.cpu_exec_* optional
ac15b62 tcg: cpu_exec_{enter,exit} helpers
0560b09 i386: move TCG cpu class initialization out of helper.c 36ae5f1 i386: move cpu dump out of helper.c into cpu-dump.c ef2d207 i386: move TCG accel files into tcg/
9d7a737 i386: hvf: remove stale MAINTAINERS entry for old hvf stubs 42deca7 i386: move hax accel files into hax/
7dfc2be i386: move whpx accel files into whpx/
4d4c885 i386: move kvm accel files into kvm/
d9966d5 accel/tcg: rename tcg-cpus functions to match module name a8f0cbf accel/tcg: split tcg_start_vcpu_thread
5e46bf0 accel/tcg: split CpusAccel into three TCG variants
=== OUTPUT BEGIN ===
1/32 Checking commit 5e46bf019fb7 (accel/tcg: split CpusAccel into three TCG variants)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #57:
new file mode 100644
total: 0 errors, 1 warnings, 1156 lines checked
Patch 1/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
2/32 Checking commit a8f0cbf6b610 (accel/tcg: split tcg_start_vcpu_thread)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #103:
deleted file mode 100644
total: 0 errors, 1 warnings, 201 lines checked
Patch 2/32 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
3/32 Checking commit d9966d571c7e (accel/tcg: rename tcg-cpus functions to match module name) 4/32 Checking commit 4d4c885ff790 (i386: move kvm accel files into kvm/)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #167:
rename from target/i386/hyperv-proto.h
total: 0 errors, 1 warnings, 150 lines checked
Patch 4/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
5/32 Checking commit 7dfc2bea3c57 (i386: move whpx accel files into whpx/)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #50:
new file mode 100644
total: 0 errors, 1 warnings, 32 lines checked
Patch 5/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
6/32 Checking commit 42deca72cda4 (i386: move hax accel files into hax/)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #25:
rename from target/i386/hax-all.c
total: 0 errors, 1 warnings, 47 lines checked
Patch 6/32 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
7/32 Checking commit 9d7a7374d252 (i386: hvf: remove stale MAINTAINERS entry for old hvf stubs) 8/32 Checking commit ef2d207c5f81 (i386: move TCG accel files into tcg/)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#44:
rename from target/i386/bpt_helper.c
total: 0 errors, 1 warnings, 39 lines checked
Patch 8/32 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
9/32 Checking commit 36ae5f191d8c (i386: move cpu dump out of helper.c into cpu-dump.c)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #11:
new file mode 100644
ERROR: braces {} are necessary for all arms of this statement #128: FILE: target/i386/cpu-dump.c:113:
+ if (!(env->hflags & HF_PE_MASK) || !(sc->flags & DESC_P_MASK))
[...]
WARNING: Block comments use a leading /* on a separate line #172: FILE: target/i386/cpu-dump.c:157:
+/* ARRAY_SIZE check is not required because
WARNING: Block comments use a leading /* on a separate line #211: FILE: target/i386/cpu-dump.c:196:
+/* ARRAY_SIZE check is not required because
ERROR: line over 90 characters
#373: FILE: target/i386/cpu-dump.c:358:
+ qemu_fprintf(f, "RAX=%016" PRIx64 " RBX=%016" PRIx64 " RCX=%016" PRIx64 " RDX=%016" PRIx64 "\n"
ERROR: line over 90 characters
#374: FILE: target/i386/cpu-dump.c:359:
+ "RSI=%016" PRIx64 " RDI=%016" PRIx64 " RBP=%016" PRIx64 " RSP=%016" PRIx64 "\n"
ERROR: line over 90 characters
#375: FILE: target/i386/cpu-dump.c:360:
+ "R8 =%016" PRIx64 " R9 =%016" PRIx64 " R10=%016" PRIx64 " R11=%016" PRIx64 "\n"
ERROR: line over 90 characters
#376: FILE: target/i386/cpu-dump.c:361:
+ "R12=%016" PRIx64 " R13=%016" PRIx64 " R14=%016" PRIx64 " R15=%016" PRIx64 "\n"
ERROR: line over 90 characters
#377: FILE: target/i386/cpu-dump.c:362:
+ "RIP=%016" PRIx64 " RFL=%08x [%c%c%c%c%c%c%c] CPL=%d II=%d A20=%d SMM=%d HLT=%d\n",
ERROR: space required before the open parenthesis '(' #436: FILE: target/i386/cpu-dump.c:421:
+ for(i = 0; i < 6; i++) {
WARNING: line over 80 characters
#448: FILE: target/i386/cpu-dump.c:433:
+ qemu_fprintf(f, "CR0=%08x CR2=%016" PRIx64 " CR3=%016" PRIx64 " CR4=%08x\n",
ERROR: space required before the open parenthesis '(' #453: FILE: target/i386/cpu-dump.c:438:
+ for(i = 0; i < 4; i++)
ERROR: braces {} are necessary for all arms of this statement #453: FILE: target/i386/cpu-dump.c:438:
+ for(i = 0; i < 4; i++)
[...]
ERROR: space required before the open parenthesis '(' #469: FILE: target/i386/cpu-dump.c:454:
+ for(i = 0; i < 4; i++) {
ERROR: braces {} are necessary for all arms of this statement #476: FILE: target/i386/cpu-dump.c:461:
+ if ((unsigned)env->cc_op < CC_OP_NB)
[...]
+ else
[...]
WARNING: line over 80 characters
#477: FILE: target/i386/cpu-dump.c:462:
+ snprintf(cc_op_name, sizeof(cc_op_name), "%s", cc_op_str[env->cc_op]);
ERROR: space required before the open parenthesis '(' #497: FILE: target/i386/cpu-dump.c:482:
+ for(i = 0; i < 8; i++) {
ERROR: spaces required around that '=' (ctx:VxV)
#507: FILE: target/i386/cpu-dump.c:492:
+ for(i=0;i<8;i++) {
^ERROR: space required after that ';' (ctx:VxV)
#507: FILE: target/i386/cpu-dump.c:492:
+ for(i=0;i<8;i++) {
^ERROR: spaces required around that '<' (ctx:VxV)
#507: FILE: target/i386/cpu-dump.c:492:
+ for(i=0;i<8;i++) {
^ERROR: space required after that ';' (ctx:VxV)
#507: FILE: target/i386/cpu-dump.c:492:
+ for(i=0;i<8;i++) {
^ERROR: space required before the open parenthesis '(' #507: FILE: target/i386/cpu-dump.c:492:
+ for(i=0;i<8;i++) {
ERROR: braces {} are necessary for all arms of this statement #512: FILE: target/i386/cpu-dump.c:497:
+ if ((i & 1) == 1)
[...]
+ else
[...]
ERROR: braces {} are necessary for all arms of this statement #517: FILE: target/i386/cpu-dump.c:502:
+ if (env->hflags & HF_CS64_MASK)
[...]
+ else
[...]
ERROR: spaces required around that '=' (ctx:VxV)
#521: FILE: target/i386/cpu-dump.c:506:
+ for(i=0;i<nb;i++) {
^ERROR: space required after that ';' (ctx:VxV)
#521: FILE: target/i386/cpu-dump.c:506:
+ for(i=0;i<nb;i++) {
^ERROR: spaces required around that '<' (ctx:VxV)
#521: FILE: target/i386/cpu-dump.c:506:
+ for(i=0;i<nb;i++) {
^ERROR: space required after that ';' (ctx:VxV)
#521: FILE: target/i386/cpu-dump.c:506:
+ for(i=0;i<nb;i++) {
^ERROR: space required before the open parenthesis '(' #521: FILE: target/i386/cpu-dump.c:506:
+ for(i=0;i<nb;i++) {
ERROR: braces {} are necessary for all arms of this statement #528: FILE: target/i386/cpu-dump.c:513:
+ if ((i & 1) == 1)
[...]
+ else
[...]
total: 25 errors, 5 warnings, 1077 lines checked
Patch 9/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
10/32 Checking commit 0560b09d8481 (i386: move TCG cpu class initialization out of helper.c)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #282:
new file mode 100644
total: 0 errors, 1 warnings, 610 lines checked
Patch 10/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
11/32 Checking commit ac15b624a91f (tcg: cpu_exec_{enter,exit} helpers) 12/32 Checking commit b271ab48c45b (tcg: make CPUClass.cpu_exec_* optional) 13/32 Checking commit 043b89c9c315 (tcg: Make CPUClass.debug_excp_handler optional) 14/32 Checking commit 8a0c2e9a0e2c (cpu: Remove unnecessary noop methods) 15/32 Checking commit 53b3f4e5b390 (cpu: Introduce TCGCpuOperations struct)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #92:
new file mode 100644
total: 0 errors, 1 warnings, 301 lines checked
Patch 15/32 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
16/32 Checking commit 2019e4f802bb (target/riscv: remove CONFIG_TCG, as it is always TCG) 17/32 Checking commit f9b393d26c70 (accel/tcg: split TCG-only code from cpu_exec_realizefn) 18/32 Checking commit af729170f4b8 (cpu: Move synchronize_from_tb() to tcg_ops) 19/32 Checking commit 481a06e3b020 (cpu: Move cpu_exec_* to tcg_ops)
20/32 Checking commit bf5b24bcd22f (cpu: Move tlb_fill to tcg_ops)
WARNING: line over 80 characters
#22: FILE: accel/tcg/cputlb.c:1289:
+ ok = cc->tcg_ops.tlb_fill(cpu, addr, size, access_type, mmu_idx, false, retaddr);
total: 0 errors, 1 warnings, 259 lines checked
Patch 20/32 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
21/32 Checking commit 9a74429f2029 (cpu: Move debug_excp_handler to tcg_ops) 22/32 Checking commit f22d896967f8 (target/arm: do not use cc->do_interrupt for KVM directly) 23/32 Checking commit 74feabd5bae5 (cpu: move cc->do_interrupt to tcg_ops) 24/32 Checking commit bca539a6251e (cpu: move cc->transaction_failed to tcg_ops)
WARNING: line over 80 characters
#67: FILE: include/hw/core/cpu.h:857:
+ cc->tcg_ops.do_transaction_failed(cpu, physaddr, addr, size, access_type,
total: 0 errors, 1 warnings, 144 lines checked
Patch 24/32 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
25/32 Checking commit c45684ac5ad9 (cpu: move do_unaligned_access to tcg_ops) 26/32 Checking commit c3aa2224bd71 (accel: extend AccelState and AccelClass to user-mode)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #24:
new file mode 100644
total: 0 errors, 1 warnings, 359 lines checked
Patch 26/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
27/32 Checking commit 706469ebcc15 (accel: replace struct CpusAccel with AccelOpsClass)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #115:
new file mode 100644
total: 0 errors, 1 warnings, 691 lines checked
Patch 27/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
28/32 Checking commit 739ef2bd13aa (accel: introduce AccelCPUClass extending CPUClass)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #99:
new file mode 100644
total: 0 errors, 1 warnings, 123 lines checked
Patch 28/32 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
29/32 Checking commit c7ecc117664f (i386: split cpu accelerators from cpu.c, using AccelCPUClass)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#664:
new file mode 100644
WARNING: line over 80 characters
#1435: FILE: target/i386/tcg/cpu.c:104:
+ memory_region_add_subregion_overlap(cpu->cpu_as_root, 0, cpu->cpu_as_mem, 0);
total: 0 errors, 2 warnings, 1296 lines checked
Patch 29/32 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
30/32 Checking commit 6c8c6a4d84dd (cpu: call AccelCPUClass::cpu_realizefn in cpu_exec_realizefn) 31/32 Checking commit 273e6bca6404 (hw/core/cpu: call qemu_init_vcpu in cpu_common_realizefn) 32/32 Checking commit 1df468eafd63 (cpu: introduce cpu_accel_instance_init)
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Quoted 8 lines · [email protected] writes:
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Also replicated in:
https://gitlab.com/stsquad/qemu/-/jobs/899057106
Quoted 372 lines
Type: series
Message-id: [email protected]
Subject: [RFC v9 00/22] i386 cleanup=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base >/dev/null|| exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl--mailback base..
=== TEST SCRIPT END ===Updating
3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
1df468e cpu: introducecpu_accel_instance_init
273e6bc hw/core/cpu: callqemu_init_vcpuincpu_common_realizefn6c8c6a4 cpu: callAccelCPUClass::cpu_realizefnincpu_exec_realizefnc7ecc11 i386: split cpu accelerators fromcpu.c, using AccelCPUClass 739ef2b accel: introduce AccelCPUClass extending CPUClass 706469e accel: replace struct CpusAccel with AccelOpsClass c3aa222 accel: extend AccelState and AccelClass to user-mode c45684a cpu: movedo_unaligned_accesstotcg_ops
bca539a cpu: movecc->transaction_failedtotcg_ops74feabd cpu: movecc->do_interrupttotcg_ops
f22d896 target/arm: do not usecc->do_interruptfor KVM directly 9a74429 cpu: Movedebug_excp_handlertotcg_ops
bf5b24b cpu: Movetlb_filltotcg_ops
481a06e cpu: Move cpu_exec_* totcg_ops
af72917 cpu: Movesynchronize_from_tb()totcg_opsf9b393d accel/tcg: split TCG-only code fromcpu_exec_realizefn2019e4f target/riscv: removeCONFIG_TCG, as it is always TCG 53b3f4e cpu: Introduce TCGCpuOperations struct
8a0c2e9 cpu: Remove unnecessary noop methods
043b89c tcg: Make CPUClass.debug_excp_handler optional b271ab4 tcg: make CPUClass.cpu_exec_* optional
ac15b62 tcg: cpu_exec_{enter,exit} helpers
0560b09 i386: move TCG cpu class initialization out ofhelper.c36ae5f1 i386: move cpu dump out ofhelper.cintocpu-dump.cef2d207 i386: move TCG accel files into tcg/
9d7a737 i386: hvf: remove staleMAINTAINERSentry for old hvf stubs 42deca7 i386: move hax accel files into hax/
7dfc2be i386: move whpx accel files into whpx/
4d4c885 i386: move kvm accel files into kvm/
d9966d5 accel/tcg: rename tcg-cpus functions to match module name a8f0cbf accel/tcg: splittcg_start_vcpu_thread
5e46bf0 accel/tcg: split CpusAccel into three TCG variants=== OUTPUT BEGIN ===
1/32 Checking commit5e46bf019fb7(accel/tcg: split CpusAccel into three TCG variants)
WARNING: added, moved or deleted file(s), doesMAINTAINERSneed updating? #57:
new file mode 100644total: 0 errors, 1 warnings, 1156 lines checked
Patch 1/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in
MAINTAINERS.
2/32 Checking commita8f0cbf6b610(accel/tcg: splittcg_start_vcpu_thread)
WARNING: added, moved or deleted file(s), doesMAINTAINERSneed updating? #103:
deleted file mode 100644total: 0 errors, 1 warnings, 201 lines checked
Patch 2/32 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH inMAINTAINERS.
3/32 Checking commitd9966d571c7e(accel/tcg: rename tcg-cpus functions to match module name) 4/32 Checking commit4d4c885ff790(i386: move kvm accel files into kvm/)
WARNING: added, moved or deleted file(s), doesMAINTAINERSneed updating? #167:
rename fromtarget/i386/hyperv-proto.htotal: 0 errors, 1 warnings, 150 lines checked
Patch 4/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in
MAINTAINERS.
5/32 Checking commit7dfc2bea3c57(i386: move whpx accel files into whpx/)
WARNING: added, moved or deleted file(s), doesMAINTAINERSneed updating? #50:
new file mode 100644total: 0 errors, 1 warnings, 32 lines checked
Patch 5/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in
MAINTAINERS.
6/32 Checking commit42deca72cda4(i386: move hax accel files into hax/)
WARNING: added, moved or deleted file(s), doesMAINTAINERSneed updating? #25:
rename fromtarget/i386/hax-all.ctotal: 0 errors, 1 warnings, 47 lines checked
Patch 6/32 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH inMAINTAINERS.
7/32 Checking commit9d7a7374d252(i386: hvf: remove staleMAINTAINERSentry for old hvf stubs) 8/32 Checking commitef2d207c5f81(i386: move TCG accel files into tcg/)
WARNING: added, moved or deleted file(s), doesMAINTAINERSneed updating?
#44:
rename fromtarget/i386/bpt_helper.ctotal: 0 errors, 1 warnings, 39 lines checked
Patch 8/32 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH inMAINTAINERS.
9/32 Checking commit36ae5f191d8c(i386: move cpu dump out ofhelper.cintocpu-dump.c)
WARNING: added, moved or deleted file(s), doesMAINTAINERSneed updating? #11:
new file mode 100644ERROR: braces {} are necessary for all arms of this statement #128: FILE:
target/i386/cpu-dump.c:113:
+ if (!(env->hflags &HF_PE_MASK) || !(sc->flags &DESC_P_MASK))
[...]WARNING: Block comments use a leading /* on a separate line #172: FILE:
target/i386/cpu-dump.c:157:
+/*ARRAY_SIZEcheck is not required becauseWARNING: Block comments use a leading /* on a separate line #211: FILE:
target/i386/cpu-dump.c:196:
+/*ARRAY_SIZEcheck is not required becauseERROR: line over 90 characters
#373: FILE:target/i386/cpu-dump.c:358:
+ qemu_fprintf(f, "RAX=%016" PRIx64 " RBX=%016" PRIx64 " RCX=%016" PRIx64 " RDX=%016" PRIx64 "\n"ERROR: line over 90 characters
#374: FILE:target/i386/cpu-dump.c:359:
+ "RSI=%016" PRIx64 " RDI=%016" PRIx64 " RBP=%016" PRIx64 " RSP=%016" PRIx64 "\n"ERROR: line over 90 characters
#375: FILE:target/i386/cpu-dump.c:360:
+ "R8 =%016" PRIx64 " R9 =%016" PRIx64 " R10=%016" PRIx64 " R11=%016" PRIx64 "\n"ERROR: line over 90 characters
#376: FILE:target/i386/cpu-dump.c:361:
+ "R12=%016" PRIx64 " R13=%016" PRIx64 " R14=%016" PRIx64 " R15=%016" PRIx64 "\n"ERROR: line over 90 characters
#377: FILE:target/i386/cpu-dump.c:362:
+ "RIP=%016" PRIx64 " RFL=%08x [%c%c%c%c%c%c%c] CPL=%d II=%d A20=%d SMM=%d HLT=%d\n",ERROR: space required before the open parenthesis '(' #436: FILE:
target/i386/cpu-dump.c:421:
+ for(i = 0; i < 6; i++) {WARNING: line over 80 characters
#448: FILE:target/i386/cpu-dump.c:433:
+ qemu_fprintf(f, "CR0=%08x CR2=%016" PRIx64 " CR3=%016" PRIx64 " CR4=%08x\n",ERROR: space required before the open parenthesis '(' #453: FILE:
target/i386/cpu-dump.c:438:
+ for(i = 0; i < 4; i++)ERROR: braces {} are necessary for all arms of this statement #453: FILE:
target/i386/cpu-dump.c:438:
+ for(i = 0; i < 4; i++)
[...]ERROR: space required before the open parenthesis '(' #469: FILE:
target/i386/cpu-dump.c:454:
+ for(i = 0; i < 4; i++) {ERROR: braces {} are necessary for all arms of this statement #476: FILE:
target/i386/cpu-dump.c:461:(quoted diff) +2
-0+ if ((unsigned)env->cc_op < CC_OP_NB) + elseWARNING: line over 80 characters
#477: FILE:target/i386/cpu-dump.c:462:
+snprintf(cc_op_name, sizeof(cc_op_name), "%s", cc_op_str[env->cc_op]);ERROR: space required before the open parenthesis '(' #497: FILE:
target/i386/cpu-dump.c:482:
+ for(i = 0; i < 8; i++) {ERROR: spaces required around that '=' (ctx:VxV)
#507: FILE:target/i386/cpu-dump.c:492:+ for(i=0;i<8;i++) { ^ERROR: space required after that ';' (ctx:VxV)
#507: FILE:target/i386/cpu-dump.c:492:+ for(i=0;i<8;i++) { ^ERROR: spaces required around that '<' (ctx:VxV)
#507: FILE:target/i386/cpu-dump.c:492:+ for(i=0;i<8;i++) { ^ERROR: space required after that ';' (ctx:VxV)
#507: FILE:target/i386/cpu-dump.c:492:+ for(i=0;i<8;i++) { ^ERROR: space required before the open parenthesis '(' #507: FILE:
target/i386/cpu-dump.c:492:
+ for(i=0;i<8;i++) {ERROR: braces {} are necessary for all arms of this statement #512: FILE:
target/i386/cpu-dump.c:497:(quoted diff) +2
-0+ if ((i & 1) == 1) + elseERROR: braces {} are necessary for all arms of this statement #517: FILE:
target/i386/cpu-dump.c:502:(quoted diff) +2
-0+ if (env->hflags & HF_CS64_MASK) + elseERROR: spaces required around that '=' (ctx:VxV)
#521: FILE:target/i386/cpu-dump.c:506:+ for(i=0;i<nb;i++) { ^ERROR: space required after that ';' (ctx:VxV)
#521: FILE:target/i386/cpu-dump.c:506:+ for(i=0;i<nb;i++) { ^ERROR: spaces required around that '<' (ctx:VxV)
#521: FILE:target/i386/cpu-dump.c:506:+ for(i=0;i<nb;i++) { ^ERROR: space required after that ';' (ctx:VxV)
#521: FILE:target/i386/cpu-dump.c:506:+ for(i=0;i<nb;i++) { ^ERROR: space required before the open parenthesis '(' #521: FILE:
target/i386/cpu-dump.c:506:
+ for(i=0;i<nb;i++) {ERROR: braces {} are necessary for all arms of this statement #528: FILE:
target/i386/cpu-dump.c:513:(quoted diff) +2
-0+ if ((i & 1) == 1) + elsetotal: 25 errors, 5 warnings, 1077 lines checked
Patch 9/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in
MAINTAINERS.10/32 Checking commit
0560b09d8481(i386: move TCG cpu class initialization out ofhelper.c)
WARNING: added, moved or deleted file(s), doesMAINTAINERSneed updating? #282:
new file mode 100644total: 0 errors, 1 warnings, 610 lines checked
Patch 10/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH inMAINTAINERS.
11/32 Checking commitac15b624a91f(tcg: cpu_exec_{enter,exit} helpers) 12/32 Checking commitb271ab48c45b(tcg: make CPUClass.cpu_exec_* optional) 13/32 Checking commit043b89c9c315(tcg: Make CPUClass.debug_excp_handler optional) 14/32 Checking commit8a0c2e9a0e2c(cpu: Remove unnecessary noop methods) 15/32 Checking commit53b3f4e5b390(cpu: Introduce TCGCpuOperations struct)
WARNING: added, moved or deleted file(s), doesMAINTAINERSneed updating? #92:
new file mode 100644total: 0 errors, 1 warnings, 301 lines checked
Patch 15/32 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH inMAINTAINERS.
16/32 Checking commit2019e4f802bb(target/riscv: removeCONFIG_TCG, as it is always TCG) 17/32 Checking commitf9b393d26c70(accel/tcg: split TCG-only code fromcpu_exec_realizefn) 18/32 Checking commitaf729170f4b8(cpu: Movesynchronize_from_tb()totcg_ops) 19/32 Checking commit481a06e3b020(cpu: Move cpu_exec_* totcg_ops)
20/32 Checking commitbf5b24bcd22f(cpu: Movetlb_filltotcg_ops)
WARNING: line over 80 characters
#22: FILE:accel/tcg/cputlb.c:1289:
+ ok =cc->tcg_ops.tlb_fill(cpu, addr, size, access_type, mmu_idx, false, retaddr);total: 0 errors, 1 warnings, 259 lines checked
Patch 20/32 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH inMAINTAINERS.
21/32 Checking commit9a74429f2029(cpu: Movedebug_excp_handlertotcg_ops) 22/32 Checking commitf22d896967f8(target/arm: do not usecc->do_interruptfor KVM directly) 23/32 Checking commit74feabd5bae5(cpu: movecc->do_interrupttotcg_ops) 24/32 Checking commitbca539a6251e(cpu: movecc->transaction_failedtotcg_ops)
WARNING: line over 80 characters
#67: FILE:include/hw/core/cpu.h:857:
+ cc->tcg_ops.do_transaction_failed(cpu, physaddr, addr, size,access_type,total: 0 errors, 1 warnings, 144 lines checked
Patch 24/32 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH inMAINTAINERS.
25/32 Checking commitc45684ac5ad9(cpu: movedo_unaligned_accesstotcg_ops) 26/32 Checking commitc3aa2224bd71(accel: extend AccelState and AccelClass to user-mode)
WARNING: added, moved or deleted file(s), doesMAINTAINERSneed updating? #24:
new file mode 100644total: 0 errors, 1 warnings, 359 lines checked
Patch 26/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH inMAINTAINERS.
27/32 Checking commit706469ebcc15(accel: replace struct CpusAccel with AccelOpsClass)
WARNING: added, moved or deleted file(s), doesMAINTAINERSneed updating? #115:
new file mode 100644total: 0 errors, 1 warnings, 691 lines checked
Patch 27/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH inMAINTAINERS.
28/32 Checking commit739ef2bd13aa(accel: introduce AccelCPUClass extending CPUClass)
WARNING: added, moved or deleted file(s), doesMAINTAINERSneed updating? #99:
new file mode 100644total: 0 errors, 1 warnings, 123 lines checked
Patch 28/32 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH inMAINTAINERS.
29/32 Checking commitc7ecc117664f(i386: split cpu accelerators fromcpu.c, using AccelCPUClass)
WARNING: added, moved or deleted file(s), doesMAINTAINERSneed updating?
#664:
new file mode 100644WARNING: line over 80 characters
#1435: FILE:target/i386/tcg/cpu.c:104:
+memory_region_add_subregion_overlap(cpu->cpu_as_root, 0, cpu->cpu_as_mem, 0);total: 0 errors, 2 warnings, 1296 lines checked
Patch 29/32 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH inMAINTAINERS.
30/32 Checking commit6c8c6a4d84dd(cpu: callAccelCPUClass::cpu_realizefnincpu_exec_realizefn) 31/32 Checking commit273e6bca6404(hw/core/cpu: callqemu_init_vcpuincpu_common_realizefn) 32/32 Checking commit1df468eafd63(cpu: introducecpu_accel_instance_init)
=== OUTPUT END ===Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Signature · 1 line
Alex Bennée
Claudio Fontana <[email protected]> writes:
<snip>
Quoted 2 lines
Looking forward to your comments on this proposal,
OK I've completed my pass although I petered out a little just before the changes that affect the explicit ordering which was a bit too much for my brain to process after lunch. Some general thoughts...
I like the way this is going and having the much more modular concept for both accelerators and target accelerator support. However to protect the new build combinations I think we need to cover some TCG and HW accelerator builds in the gitlab build matrix.
Signature · 1 line
Alex Bennée
Quoted 7 lines · Alex Bennée
Claudio Fontana <[email protected]> writes:
<snip>
Quoted 2 lines
Looking forward to your comments on this proposal,
Quoted 9 lines
OK I've completed my pass although I petered out a little just before the changes that affect the explicit ordering which was a bit too much for my brain to process after lunch. Some general thoughts...
I like the way this is going and having the much more modular concept for both accelerators and target accelerator support. However to protect the new build combinations I think we need to cover some TCG and HW accelerator builds in the gitlab build matrix.
Hi Alex,
thanks a lot for your review pass,
will start addressing your comments in the next spin,
Ciao!
Claudio