Abstract ArchCPU
From: Philippe Mathieu-Daudé <[email protected]>
The following changes since commit 9d662a6b22a0838a85c5432385f35db2488a33a5:
Merge remote-tracking branch 'remotes/legoater/tags/pull-ppc-20220305' into staging (2022-03-05 18:03:15 +0000)
are available in the Git repository at:
https://github.com/philmd/qemu.git tags/abstract-arch-cpu-20220307
for you to fetch changes up to 61deada4bf54fddf1bc36e15c16269c33462aa90:
accel/tcg: Remove pointless CPUArchState casts (2022-03-06 22:47:52 +0100)
Since v1: Fixed Darwin/x86_64 (HVF)
----------------------------------------------------------------
- Re-org accel/ and softmmu/ to have more target-agnostic objects.
- Use CPUArchState as an abstract type, defined by each target (CPUState is our interface with generic code, CPUArchState is our interface with target-specific code).
----------------------------------------------------------------
Philippe Mathieu-Daudé (32):
accel: Restrict sysemu stubs to system emulation accel/meson: Only build hw virtualization with system emulation
exec: Declare vaddr as a generic target-agnostic type
exec: Make cpu_memory_rw_debug() target agnostic sysemu/memory_mapping: Become target-agnostic
sysemu/kvm: Make kvm_on_sigbus() / kvm_on_sigbus_vcpu() target
agnostic
accel/kvm: Simplify user-mode #ifdef'ry
accel/hax: Introduce CONFIG_HAX_IS_POSSIBLE
softmmu/cpus: Code movement
accel: Introduce AccelOpsClass::cpu_thread_is_idle()
accel: Introduce AccelOpsClass::cpus_are_resettable() softmmu/globals: Remove unused 'hw/i386/*' headers softmmu/physmem: Remove unnecessary include softmmu/cpu-timers: Remove unused 'exec/exec-all.h' header
misc: Remove unnecessary "sysemu/cpu-timers.h" include
misc: Add missing "sysemu/cpu-timers.h" include exec/gdbstub: Make gdb_exit() / gdb_set_stop_cpu() target agnostic exec/cpu: Make address_space_init/reloading_memory_map target agnostic
softmmu: Add qemu_init_arch_modules()
softmmu: Build target-agnostic objects once
meson: Display libfdt as disabled when system emulation is disabled exec/cpu_ldst: Include 'cpu.h' to get target_ulong definition
cpu: Add missing 'exec/exec-all.h' and 'qemu/accel.h' headers target/i386/tcg/sysemu: Include missing 'exec/exec-all.h' header
target: Include missing 'cpu.h'
target/hexagon: Add missing 'hw/core/cpu.h' include
target: Use forward declared type instead of structure type
target: Use CPUArchState as interface to target-specific CPU state
target: Introduce and use OBJECT_DECLARE_CPU_TYPE() macro
target: Use ArchCPU as interface to target CPU target/i386: Remove pointless CPUArchState casts accel/tcg: Remove pointless CPUArchState casts
Taylor Simpson (1):
Hexagon (target/hexagon) convert to OBJECT_DECLARE_TYPE
meson.build | 4 +- include/exec/cpu-all.h | 4 - include/exec/cpu-common.h | 39 ++++++++++ include/exec/cpu_ldst.h | 1 + include/exec/exec-all.h | 26 ------- include/exec/gdbstub.h | 25 +++--- include/exec/poison.h | 2 - include/hw/core/cpu.h | 33 ++++---- include/qemu/typedefs.h | 2 + include/sysemu/accel-ops.h | 3 + include/sysemu/arch_init.h | 2 + include/sysemu/hax.h | 18 +++-- include/sysemu/hw_accel.h | 5 -- include/sysemu/kvm.h | 6 +- include/sysemu/memory_mapping.h | 5 +- target/alpha/cpu-qom.h | 3 +- target/alpha/cpu.h | 11 +-- target/arm/cpu-qom.h | 3 +- target/arm/cpu.h | 7 +- target/arm/hvf_arm.h | 2 +- target/avr/cpu-qom.h | 3 +- target/avr/cpu.h | 13 +--- target/cris/cpu-qom.h | 3 +- target/cris/cpu.h | 7 +- target/hexagon/cpu.h | 23 ++---- target/hppa/cpu-qom.h | 3 +- target/hppa/cpu.h | 12 +-- target/i386/cpu-qom.h | 3 +- target/i386/cpu.h | 7 +- target/i386/hvf/x86_emu.h | 22 +++--- target/m68k/cpu-qom.h | 3 +- target/m68k/cpu.h | 7 +- target/microblaze/cpu-qom.h | 3 +- target/microblaze/cpu.h | 9 +-- target/microblaze/mmu.h | 2 + target/mips/cpu-qom.h | 3 +- target/mips/cpu.h | 10 +-- target/mips/internal.h | 15 ++-- target/nios2/cpu.h | 9 +-- target/nios2/mmu.h | 2 + target/openrisc/cpu.h | 17 ++--- target/ppc/cpu-qom.h | 5 +- target/ppc/cpu.h | 7 +- target/riscv/cpu.h | 11 +-- target/riscv/pmp.h | 2 + target/rx/cpu-qom.h | 5 +- target/rx/cpu.h | 6 +- target/s390x/cpu-qom.h | 7 +- target/s390x/cpu.h | 7 +- target/sh4/cpu-qom.h | 3 +- target/sh4/cpu.h | 7 +- target/sparc/cpu-qom.h | 3 +- target/sparc/cpu.h | 9 +-- target/tricore/cpu-qom.h | 3 +- target/tricore/cpu.h | 10 +-- target/xtensa/cpu-qom.h | 3 +- target/xtensa/cpu.h | 13 ++-- accel/kvm/kvm-accel-ops.c | 12 +++ accel/qtest/qtest.c | 1 - accel/stubs/hax-stub.c | 2 + accel/stubs/kvm-stub.c | 5 -- accel/tcg/cpu-exec.c | 4 +- accel/tcg/tcg-accel-ops-icount.c | 1 + accel/tcg/tcg-accel-ops-mttcg.c | 1 + accel/tcg/tcg-accel-ops-rr.c | 1 + accel/tcg/tcg-accel-ops.c | 1 + cpu.c | 8 +- softmmu/arch_init.c | 9 +++ softmmu/cpu-timers.c | 1 - softmmu/cpus.c | 23 +++--- softmmu/globals.c | 2 - softmmu/memory_mapping.c | 1 + softmmu/physmem.c | 7 +- softmmu/vl.c | 5 +- target/alpha/translate.c | 1 - target/i386/hax/hax-all.c | 11 +-- target/i386/hvf/x86_emu.c | 110 +++++++++++++-------------- target/i386/nvmm/nvmm-all.c | 14 ++-- target/i386/tcg/sysemu/excp_helper.c | 1 + target/i386/tcg/sysemu/misc_helper.c | 1 + target/i386/whpx/whpx-accel-ops.c | 6 ++ target/i386/whpx/whpx-all.c | 18 ++--- target/riscv/csr.c | 1 + tests/unit/ptimer-test-stubs.c | 1 - accel/meson.build | 12 +-- accel/stubs/meson.build | 11 ++- softmmu/meson.build | 24 +++--- 87 files changed, 371 insertions(+), 402 deletions(-)
Signature · 1 line
2.35.1
[PULL v2 28/33] target: Use forward declared type instead of structure type
From: Philippe Mathieu-Daudé <[email protected]>
The CPU / CPU state are forward declared.
$ git grep -E 'struct [A-Za-z]+CPU\ \*' target/arm/hvf_arm.h:16:void hvf_arm_set_cpu_features_from_host(struct ARMCPU *cpu); target/openrisc/cpu.h:234: int (*cpu_openrisc_map_address_code)(struct OpenRISCCPU *cpu, target/openrisc/cpu.h:238: int (*cpu_openrisc_map_address_data)(struct OpenRISCCPU *cpu,
$ git grep -E 'struct CPU[A-Za-z0-9]+State\ \*' target/mips/internal.h:137: int (*map_address)(struct CPUMIPSState *env, hwaddr *physical, int *prot, target/mips/internal.h:139: void (*helper_tlbwi)(struct CPUMIPSState *env); target/mips/internal.h:140: void (*helper_tlbwr)(struct CPUMIPSState *env); target/mips/internal.h:141: void (*helper_tlbp)(struct CPUMIPSState *env); target/mips/internal.h:142: void (*helper_tlbr)(struct CPUMIPSState *env); target/mips/internal.h:143: void (*helper_tlbinv)(struct CPUMIPSState *env); target/mips/internal.h:144: void (*helper_tlbinvf)(struct CPUMIPSState *env); target/xtensa/cpu.h:347: struct CPUXtensaState *env; ...
Message-Id: <[email protected]>
--- target/arm/hvf_arm.h | 2 +- target/i386/hvf/x86_emu.h | 22 ++++---- target/mips/internal.h | 14 ++--- target/openrisc/cpu.h | 4 +- target/xtensa/cpu.h | 2 +- target/i386/hvf/x86_emu.c | 110 ++++++++++++++++++------------------ target/i386/nvmm/nvmm-all.c | 14 ++--- target/i386/whpx/whpx-all.c | 18 +++--- 8 files changed, 93 insertions(+), 93 deletions(-)
target/arm/hvf_arm.h +1 -1
@@ -13,6 +13,6 @@#include "cpu.h" -void hvf_arm_set_cpu_features_from_host (struct ARMCPU *cpu); +void hvf_arm_set_cpu_features_from_host (ARMCPU *cpu);#endif
target/i386/hvf/x86_emu.h +11 -11
@@ -24,7 +24,7 @@#include "cpu.h" void init_emu (void ); -bool exec_instruction (struct CPUX86State *env,struct x86_decode *ins); +bool exec_instruction (CPUX86State *env,struct x86_decode *ins);void load_regs (struct CPUState *cpu);void store_regs (struct CPUState *cpu);
@@ -36,15 +36,15 @@ target_ulong read_reg(CPUX86State *env, int reg, int size);void write_reg (CPUX86State *env,int reg,target_ulong val,int size);target_ulong read_val_from_reg (target_ulong reg_ptr,int size);void write_val_to_reg (target_ulong reg_ptr,target_ulong val,int size); -void write_val_ext (struct CPUX86State *env,target_ulong ptr,target_ulong val,int size); -uint8_t *read_mmio (struct CPUX86State *env,target_ulong ptr,int bytes); -target_ulong read_val_ext (struct CPUX86State *env,target_ulong ptr,int size); +void write_val_ext (CPUX86State *env,target_ulong ptr,target_ulong val,int size); +uint8_t *read_mmio (CPUX86State *env,target_ulong ptr,int bytes); +target_ulong read_val_ext (CPUX86State *env,target_ulong ptr,int size); -void exec_movzx (struct CPUX86State *env,struct x86_decode *decode); -void exec_shl (struct CPUX86State *env,struct x86_decode *decode); -void exec_movsx (struct CPUX86State *env,struct x86_decode *decode); -void exec_ror (struct CPUX86State *env,struct x86_decode *decode); -void exec_rol (struct CPUX86State *env,struct x86_decode *decode); -void exec_rcl (struct CPUX86State *env,struct x86_decode *decode); -void exec_rcr (struct CPUX86State *env,struct x86_decode *decode); +void exec_movzx (CPUX86State *env,struct x86_decode *decode); +void exec_shl (CPUX86State *env,struct x86_decode *decode); +void exec_movsx (CPUX86State *env,struct x86_decode *decode); +void exec_ror (CPUX86State *env,struct x86_decode *decode); +void exec_rol (CPUX86State *env,struct x86_decode *decode); +void exec_rcl (CPUX86State *env,struct x86_decode *decode); +void exec_rcr (CPUX86State *env,struct x86_decode *decode);#endif
target/mips/internal.h +7 -7
@@ -134,14 +134,14 @@ struct r4k_tlb_t { struct CPUMIPSTLBContext { uint32_t nb_tlb; uint32_t tlb_in_use; - int (*map_address)(struct CPUMIPSState *env, hwaddr *physical, int *prot, + int (*map_address)(CPUMIPSState *env, hwaddr *physical, int *prot, target_ulong address, MMUAccessType access_type); - void (*helper_tlbwi)(struct CPUMIPSState *env); - void (*helper_tlbwr)(struct CPUMIPSState *env); - void (*helper_tlbp)(struct CPUMIPSState *env); - void (*helper_tlbr)(struct CPUMIPSState *env); - void (*helper_tlbinv)(struct CPUMIPSState *env); - void (*helper_tlbinvf)(struct CPUMIPSState *env); + void (*helper_tlbwi)(CPUMIPSState *env); + void (*helper_tlbwr)(CPUMIPSState *env); + void (*helper_tlbp)(CPUMIPSState *env); + void (*helper_tlbr)(CPUMIPSState *env); + void (*helper_tlbinv)(CPUMIPSState *env); + void (*helper_tlbinvf)(CPUMIPSState *env); union { struct { r4k_tlb_t tlb[MIPS_TLB_MAX];
target/openrisc/cpu.h +2 -2
@@ -231,11 +231,11 @@ typedef struct CPUOpenRISCTLBContext {OpenRISCTLBEntry itlb[TLB_SIZE ];OpenRISCTLBEntry dtlb[TLB_SIZE ]; -int (*cpu_openrisc_map_address_code)(struct OpenRISCCPU *cpu, +int (*cpu_openrisc_map_address_code)(OpenRISCCPU *cpu,hwaddr *physical,int *prot,target_ulong address,int rw); -int (*cpu_openrisc_map_address_data)(struct OpenRISCCPU *cpu, +int (*cpu_openrisc_map_address_data)(OpenRISCCPU *cpu,hwaddr *physical,int *prot,target_ulong address,int rw);
target/xtensa/cpu.h +1 -1
@@ -344,7 +344,7 @@ typedef struct XtensaGdbRegmap { } XtensaGdbRegmap;typedef struct XtensaCcompareTimer { -struct CPUXtensaState *env; +CPUXtensaState *env;QEMUTimer *timer; }XtensaCcompareTimer ;
target/i386/hvf/x86_emu.c +55 -55
419 lines not on this page · raw message
target/i386/nvmm/nvmm-all.c +7 -7
@@ -85,7 +85,7 @@ nvmm_set_segment(struct nvmm_x64_state_seg *nseg, const SegmentCache *qseg)static void nvmm_set_registers (CPUState *cpu) { -struct CPUX86State *env = (CPUArchState *)cpu->env_ptr; +CPUX86State *env = (CPUArchState *)cpu->env_ptr;struct nvmm_machine *mach =get_nvmm_mach ();struct qemu_vcpu *qcpu =get_qemu_vcpu (cpu);struct nvmm_vcpu *vcpu = &qcpu->vcpu;
@@ -222,7 +222,7 @@ nvmm_get_segment(SegmentCache *qseg, const struct nvmm_x64_state_seg *nseg)static void nvmm_get_registers (CPUState *cpu) { -struct CPUX86State *env = (CPUArchState *)cpu->env_ptr; +CPUX86State *env = (CPUArchState *)cpu->env_ptr;struct nvmm_machine *mach =get_nvmm_mach ();struct qemu_vcpu *qcpu =get_qemu_vcpu (cpu);struct nvmm_vcpu *vcpu = &qcpu->vcpu;
@@ -347,7 +347,7 @@ nvmm_get_registers(CPUState *cpu)static bool nvmm_can_take_int (CPUState *cpu) { -struct CPUX86State *env = (CPUArchState *)cpu->env_ptr; +CPUX86State *env = (CPUArchState *)cpu->env_ptr;struct qemu_vcpu *qcpu =get_qemu_vcpu (cpu);struct nvmm_vcpu *vcpu = &qcpu->vcpu;struct nvmm_machine *mach =get_nvmm_mach ();
@@ -394,7 +394,7 @@ nvmm_can_take_nmi(CPUState *cpu)static void nvmm_vcpu_pre_run (CPUState *cpu) { -struct CPUX86State *env = (CPUArchState *)cpu->env_ptr; +CPUX86State *env = (CPUArchState *)cpu->env_ptr;struct nvmm_machine *mach =get_nvmm_mach ();struct qemu_vcpu *qcpu =get_qemu_vcpu (cpu);struct nvmm_vcpu *vcpu = &qcpu->vcpu;
@@ -480,7 +480,7 @@ static void nvmm_vcpu_post_run(CPUState *cpu, struct nvmm_vcpu_exit *exit) {struct qemu_vcpu *qcpu =get_qemu_vcpu (cpu); -struct CPUX86State *env = (CPUArchState *)cpu->env_ptr; +CPUX86State *env = (CPUArchState *)cpu->env_ptr;X86CPU *x86_cpu =X86_CPU (cpu);uint64_t tpr;
@@ -652,7 +652,7 @@ static int nvmm_handle_halted(struct nvmm_machine *mach, CPUState *cpu, struct nvmm_vcpu_exit *exit) { - struct CPUX86State *env = (CPUArchState *)cpu->env_ptr; + CPUX86State *env = (CPUArchState *)cpu->env_ptr;int ret =0 ;qemu_mutex_lock_iothread ();
@@ -685,7 +685,7 @@ nvmm_inject_ud(struct nvmm_machine *mach, struct nvmm_vcpu *vcpu)static int nvmm_vcpu_loop (CPUState *cpu) { -struct CPUX86State *env = (CPUArchState *)cpu->env_ptr; +CPUX86State *env = (CPUArchState *)cpu->env_ptr;struct nvmm_machine *mach =get_nvmm_mach ();struct qemu_vcpu *qcpu =get_qemu_vcpu (cpu);struct nvmm_vcpu *vcpu = &qcpu->vcpu;
target/i386/whpx/whpx-all.c +9 -9
@@ -221,7 +221,7 @@ static SegmentCache whpx_seg_h2q(const WHV_X64_SEGMENT_REGISTER *hs)static int whpx_set_tsc (CPUState *cpu) { -struct CPUX86State *env = (CPUArchState *)(cpu->env_ptr); +CPUX86State *env = (CPUArchState *)(cpu->env_ptr);WHV_REGISTER_NAME tsc_reg = WHvX64RegisterTsc;WHV_REGISTER_VALUE tsc_val;HRESULT hr;
@@ -260,7 +260,7 @@ static void whpx_set_registers(CPUState *cpu, int level) {struct whpx_state *whpx = &whpx_global;struct whpx_vcpu *vcpu =get_whpx_vcpu (cpu); -struct CPUX86State *env = (CPUArchState *)(cpu->env_ptr); +CPUX86State *env = (CPUArchState *)(cpu->env_ptr);X86CPU *x86_cpu =X86_CPU (cpu);struct whpx_register_set vcxt;HRESULT hr;
@@ -428,7 +428,7 @@ static void whpx_set_registers(CPUState *cpu, int level)static int whpx_get_tsc (CPUState *cpu) { -struct CPUX86State *env = (CPUArchState *)(cpu->env_ptr); +CPUX86State *env = (CPUArchState *)(cpu->env_ptr);WHV_REGISTER_NAME tsc_reg = WHvX64RegisterTsc;WHV_REGISTER_VALUE tsc_val;HRESULT hr;
@@ -449,7 +449,7 @@ static void whpx_get_registers(CPUState *cpu) {struct whpx_state *whpx = &whpx_global;struct whpx_vcpu *vcpu =get_whpx_vcpu (cpu); -struct CPUX86State *env = (CPUArchState *)(cpu->env_ptr); +CPUX86State *env = (CPUArchState *)(cpu->env_ptr);X86CPU *x86_cpu =X86_CPU (cpu);struct whpx_register_set vcxt;uint64_t tpr, apic_base;
@@ -760,7 +760,7 @@ static int whpx_handle_portio(CPUState *cpu,static int whpx_handle_halt (CPUState *cpu) { -struct CPUX86State *env = (CPUArchState *)(cpu->env_ptr); +CPUX86State *env = (CPUArchState *)(cpu->env_ptr);int ret =0 ;qemu_mutex_lock_iothread ();
@@ -781,7 +781,7 @@ static void whpx_vcpu_pre_run(CPUState *cpu)HRESULT hr;struct whpx_state *whpx = &whpx_global;struct whpx_vcpu *vcpu =get_whpx_vcpu (cpu); -struct CPUX86State *env = (CPUArchState *)(cpu->env_ptr); +CPUX86State *env = (CPUArchState *)(cpu->env_ptr);X86CPU *x86_cpu =X86_CPU (cpu);int irq;uint8_t tpr;
@@ -903,7 +903,7 @@ static void whpx_vcpu_pre_run(CPUState *cpu)static void whpx_vcpu_post_run (CPUState *cpu) {struct whpx_vcpu *vcpu =get_whpx_vcpu (cpu); -struct CPUX86State *env = (CPUArchState *)(cpu->env_ptr); +CPUX86State *env = (CPUArchState *)(cpu->env_ptr);X86CPU *x86_cpu =X86_CPU (cpu); env->eflags = vcpu->exit_ctx.VpContext.Rflags;
@@ -927,7 +927,7 @@ static void whpx_vcpu_post_run(CPUState *cpu)static void whpx_vcpu_process_async_events (CPUState *cpu) { -struct CPUX86State *env = (CPUArchState *)(cpu->env_ptr); +CPUX86State *env = (CPUArchState *)(cpu->env_ptr);X86CPU *x86_cpu =X86_CPU (cpu);struct whpx_vcpu *vcpu =get_whpx_vcpu (cpu);
@@ -1333,7 +1333,7 @@ int whpx_init_vcpu(CPUState *cpu)struct whpx_state *whpx = &whpx_global;struct whpx_vcpu *vcpu =NULL ;Error *local_error =NULL ; -struct CPUX86State *env = (CPUArchState *)(cpu->env_ptr); +CPUX86State *env = (CPUArchState *)(cpu->env_ptr);X86CPU *x86_cpu =X86_CPU (cpu);UINT64 freq =0 ;int ret;
Signature · 1 line
2.35.1
Peter Maydell
AppliedQuoted 17 lines · Philippe Mathieu-Daudé
From: Philippe Mathieu-Daudé <[email protected]>
The following changes since commit
9d662a6b22a0838a85c5432385f35db2488a33a5:Merge remote-tracking branch 'remotes/legoater/tags/pull-ppc-20220305' into staging (2022-03-05 18:03:15 +0000)
are available in the Git repository at:
https://github.com/philmd/qemu.git tags/abstract-arch-cpu-20220307
for you to fetch changes up to
61deada4bf54fddf1bc36e15c16269c33462aa90:accel/tcg: Remove pointless CPUArchState casts (2022-03-06 22:47:52 +0100)
Since v1: Fixed Darwin/x86_64 (HVF)
Quoted 9 lines
----------------------------------------------------------------
- Re-org accel/ and softmmu/ to have more target-agnostic objects.- Use CPUArchState as an abstract type, defined by each target (CPUState is our interface with generic code, CPUArchState is our interface with target-specific code).
----------------------------------------------------------------
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/7.0
for any user-visible changes.
-- PMM