QOM CPUState, part 13: Emptying CPU_COMMON
cover QOM CPUState, part 13: Emptying CPU_COMMON
Hello,
This series aggressively decimizes CPU_COMMON fields and then begins with some follow-up cleanups in core CPU code. It is not complete in terms of cleanups, surrounding Coding Style fixes or explanatory commit messages - sending it out early as a gentle reminder not to use unnecessary CPUFooState but FooCPU in target APIs please, since there is progress in getting rid of CPUArchState. Not yet extensively tested.
After this series, only two CPU_COMMON fields remain: tlb_table and iotlb. Problem with those is that they not only use target_ulong but depend on NB_MMU_MODES (CPU-specific) and CPU_TLB_SIZE (host- and CPU-specific). iotlb might be allocated in the CPU realizefn if we copy NB_MMU_MODES to a CPUClass field. tlb_table by comparison is used as offset in host-specific TCG-generated machine code, we would need to load a pointer in arch-specific ways (and test them) if we were to move it out from CPU[Arch]State as once discussed.
On part 11, rth said for alpha that using CPUAlphaState in DisasContext was bad and that the relevant fields should be copied into DisasContext instead; a few targets still have an env field though and use it for register access and cpu_abort(), so I have just changed the type for now and call upon maintainers to review whether they want to do different changes.
Available for testing at:git://github.com/afaerber/qemu-cpu.git qom-cpu-13.v1
https://github.com/afaerber/qemu-cpu/commits/qom-cpu-13.v1
Regards,
Andreas
Quoted 1 line
From qom-cpu-copy preview:
* Instead of moving cpu_copy() to a new linux-user/cpu.c, moved it to main.c, allowing to drop cpu_model_str field completely
Andreas Färber (41):
cpu: Turn cpu_has_work() into a CPUClass hook
cpu: Turn cpu_mmu_index() into a CPUClass hook
cpu: Turn cpu_get_tb_cpu_state() into a CPUClass hook
cpu: Turn cpu_handle_mmu_fault() into a CPUClass hook
cpu: Move mem_io_{pc,vaddr} fields from CPU_COMMON to CPUState
cpu: Move can_do_io field from CPU_COMMON to CPUState
cpu: Move icount_extra field from CPU_COMMON to CPUState
cpu: Move icount_decr field from CPU_COMMON to CPUState
cpu: Move tb_jmp_cache field from CPU_COMMON to CPUState
cpu: Move jmp_env field from CPU_COMMON to CPUState
cpu: Move exception_index field from CPU_COMMON to CPUState
cpu: Move cpu_copy() into linux-user
cpu: Drop cpu_model_str from CPU_COMMON
cpu: Move opaque field from CPU_COMMON to CPUState
cpu: Move watchpoint fields from CPU_COMMON to CPUState
cpu: Move breakpoints field from CPU_COMMON to CPUState
cpu: Move tlb_flush_{addr,mask} fields from CPU_COMMON_TLB to CPUState
exec: Change tlb_fill() argument to CPUState
cpu-exec: Change cpu_loop_exit() argument to CPUState
translate-all: Change cpu_restore_state() argument to CPUState
translate-all: Change cpu_restore_state_from_tb() argument to CPUState
translate-all: Change tb_check_watchpoint() argument to CPUState
translate-all: Change cpu_io_recompile() argument to CPUState
translate-all: Change tb_gen_code() argument to CPUState
translate-all: Change tb_flush_jmp_cache() argument to CPUState
target-ppc: Use PowerPCCPU in PowerPCCPUClass::handle_mmu_fault hook
exec: Change cpu_watchpoint_{insert,remove{,_by_ref,_all}} argument
exec: Change cpu_breakpoint_{insert,remove{,_by_ref,_all}} argument
cpu-exec: Change cpu_resume_from_signal() argument to CPUState
cputlb: Change tlb_update_dirty() argument to CPUState
exec: Change memory_region_section_get_iotlb() argument to CPUState
cputlb: Change tlb_set_page() argument to CPUState
cputlb: Change tlb_set_page() argument to CPUState
exec: Change cpu_abort() argument to CPUState
target-cris: Replace DisasContext::env field with CRISCPU
target-lm32: Replace DisasContext::env field with LM32CPU
target-microblaze: Replace DisasContext::env field with MicroBlazeCPU
target-lm32: Move features field from CPULM32State to LM32CPU
cputlb: Change tlb_flush_page() argument to CPUState
cputlb: Change tlb_flush() argument to CPUState
user-exec: Change exception_action() argument to CPUState
bsd-user/main.c | 2 +- cpu-exec.c | 111 ++++++++++---------- cpus.c | 25 +++-- cputlb.c | 60 +++++------ exec.c | 154 +++++++++++---------------- gdbstub.c | 48 ++++----- hw/i386/kvmvapic.c | 15 +-- hw/ppc/e500.c | 3 +- hw/ppc/ppce500_spin.c | 2 +- hw/ppc/spapr_hcall.c | 2 +- hw/s390x/s390-virtio.c | 8 +- hw/sh4/sh7750.c | 2 +- include/exec/cpu-all.h | 24 ----- include/exec/cpu-defs.h | 65 ------------ include/exec/cputlb.h | 6 +- include/exec/exec-all.h | 43 ++++---- include/exec/gen-icount.h | 10 +- include/exec/softmmu_header.h | 4 +- include/exec/softmmu_template.h | 22 ++-- include/qom/cpu.h | 122 +++++++++++++++++++++- linux-user/elfload.c | 10 +- linux-user/linuxload.c | 3 +- linux-user/m68k-sim.c | 3 +- linux-user/m68k/target_cpu.h | 4 +- linux-user/main.c | 121 +++++++++++++-------- linux-user/signal.c | 24 +++-- linux-user/syscall.c | 30 +++--- linux-user/vm86.c | 27 +++-- qom/cpu.c | 18 ++++ target-alpha/cpu.c | 64 ++++++++++-- target-alpha/cpu.h | 52 +--------- target-alpha/helper.c | 38 ++++--- target-alpha/mem_helper.c | 16 +-- target-alpha/sys_helper.c | 4 +- target-alpha/translate.c | 6 +- target-arm/arm-semi.c | 9 +- target-arm/cpu.c | 51 ++++++++- target-arm/cpu.h | 39 +------ target-arm/helper.c | 110 +++++++++++++------- target-arm/op_helper.c | 33 +++--- target-arm/translate.c | 6 +- target-cris/cpu.c | 36 ++++++- target-cris/cpu.h | 26 +---- target-cris/helper.c | 46 ++++---- target-cris/mmu.c | 3 +- target-cris/op_helper.c | 28 +++-- target-cris/translate.c | 21 ++-- target-cris/translate_v10.c | 16 +-- target-i386/cpu.c | 54 ++++++++-- target-i386/cpu.h | 37 +------ target-i386/excp_helper.c | 6 +- target-i386/helper.c | 78 +++++++++----- target-i386/kvm.c | 8 +- target-i386/machine.c | 7 +- target-i386/mem_helper.c | 16 +-- target-i386/misc_helper.c | 14 ++- target-i386/seg_helper.c | 18 ++-- target-i386/svm_helper.c | 26 ++--- target-i386/translate.c | 6 +- target-lm32/cpu-qom.h | 3 + target-lm32/cpu.c | 25 ++++- target-lm32/cpu.h | 24 +---- target-lm32/helper.c | 26 ++--- target-lm32/op_helper.c | 23 ++-- target-lm32/translate.c | 67 ++++++------ target-m68k/cpu.c | 36 ++++++- target-m68k/cpu.h | 24 +---- target-m68k/helper.c | 24 +++-- target-m68k/m68k-semi.c | 5 +- target-m68k/op_helper.c | 34 +++--- target-m68k/qregs.def | 1 - target-m68k/translate.c | 13 ++- target-microblaze/cpu.c | 42 +++++++- target-microblaze/cpu.h | 28 +---- target-microblaze/helper.c | 34 +++--- target-microblaze/mmu.c | 8 +- target-microblaze/op_helper.c | 19 ++-- target-microblaze/translate.c | 110 +++++++++++--------- target-mips/cpu.c | 58 ++++++++++- target-mips/cpu.h | 46 +------- target-mips/helper.c | 56 ++++++---- target-mips/machine.c | 3 +- target-mips/op_helper.c | 34 ++++-- target-mips/translate.c | 9 +- target-mips/translate_init.c | 4 +- target-moxie/cpu.c | 26 ++++- target-moxie/cpu.h | 20 +--- target-moxie/helper.c | 51 +++++---- target-moxie/translate.c | 4 +- target-openrisc/cpu.c | 45 +++++++- target-openrisc/cpu.h | 28 +---- target-openrisc/exception.c | 6 +- target-openrisc/interrupt.c | 29 +++--- target-openrisc/interrupt_helper.c | 2 +- target-openrisc/mmu.c | 17 +-- target-openrisc/mmu_helper.c | 8 +- target-openrisc/sys_helper.c | 6 +- target-openrisc/translate.c | 7 +- target-ppc/cpu-qom.h | 8 +- target-ppc/cpu.h | 26 +---- target-ppc/excp_helper.c | 73 ++++++------- target-ppc/fpu_helper.c | 26 +++-- target-ppc/helper_regs.h | 2 +- target-ppc/misc_helper.c | 4 +- target-ppc/mmu-hash32.c | 35 ++++--- target-ppc/mmu-hash32.h | 2 +- target-ppc/mmu-hash64.c | 28 ++--- target-ppc/mmu-hash64.h | 2 +- target-ppc/mmu_helper.c | 208 +++++++++++++++++++++---------------- target-ppc/translate.c | 4 +- target-ppc/translate_init.c | 44 ++++++-- target-ppc/user_only_helper.c | 8 +- target-s390x/cc_helper.c | 5 +- target-s390x/cpu.c | 48 +++++++-- target-s390x/cpu.h | 32 +----- target-s390x/fpu_helper.c | 4 +- target-s390x/helper.c | 85 ++++++++------- target-s390x/mem_helper.c | 52 ++++++---- target-s390x/misc_helper.c | 33 +++--- target-s390x/translate.c | 4 +- target-sh4/cpu.c | 42 ++++++-- target-sh4/cpu.h | 28 +---- target-sh4/helper.c | 108 ++++++++++--------- target-sh4/op_helper.c | 20 ++-- target-sh4/translate.c | 4 +- target-sparc/cpu.c | 75 ++++++++++++- target-sparc/cpu.h | 59 +---------- target-sparc/helper.c | 28 ++--- target-sparc/int32_helper.c | 10 +- target-sparc/int64_helper.c | 8 +- target-sparc/ldst_helper.c | 36 ++++--- target-sparc/machine.c | 3 +- target-sparc/mmu_helper.c | 40 ++++--- target-sparc/translate.c | 6 +- target-unicore32/cpu.c | 35 ++++++- target-unicore32/cpu.h | 26 +---- target-unicore32/helper.c | 18 ++-- target-unicore32/op_helper.c | 14 +-- target-unicore32/softmmu.c | 27 +++-- target-unicore32/translate.c | 32 +++++- target-unicore32/ucf64_helper.c | 3 +- target-xtensa/cpu.c | 50 +++++++++ target-xtensa/cpu.h | 44 +------- target-xtensa/helper.c | 30 +++--- target-xtensa/op_helper.c | 50 +++++---- target-xtensa/translate.c | 5 +- translate-all.c | 118 +++++++++++---------- translate-all.h | 2 +- user-exec.c | 28 +++-- 149 files changed, 2536 insertions(+), 1993 deletions(-)
Signature · 1 line
1.8.1.4
RFC 1/41 cpu: Turn cpu_has_work() into a CPUClass hook
Default to false.
Tidy variable naming and inline cast uses while at it.
--- cpu-exec.c | 5 ----- cpus.c | 2 +- include/qom/cpu.h | 12 ++++++++++-- qom/cpu.c | 6 ++++++ target-alpha/cpu.c | 16 ++++++++++++++++ target-alpha/cpu.h | 15 --------------- target-arm/cpu.c | 7 +++++++ target-arm/cpu.h | 6 ------ target-cris/cpu.c | 6 ++++++ target-cris/cpu.h | 5 ----- target-i386/cpu.c | 15 +++++++++++++++ target-i386/cpu.h | 14 -------------- target-lm32/cpu.c | 6 ++++++ target-lm32/cpu.h | 5 ----- target-m68k/cpu.c | 6 ++++++ target-m68k/cpu.h | 5 ----- target-microblaze/cpu.c | 6 ++++++ target-microblaze/cpu.h | 5 ----- target-mips/cpu.c | 30 ++++++++++++++++++++++++++++++ target-mips/cpu.h | 28 ---------------------------- target-moxie/cpu.c | 6 ++++++ target-moxie/cpu.h | 5 ----- target-openrisc/cpu.c | 7 +++++++ target-openrisc/cpu.h | 5 ----- target-ppc/cpu.h | 8 -------- target-ppc/translate_init.c | 9 +++++++++ target-s390x/cpu.c | 10 ++++++++++ target-s390x/cpu.h | 9 --------- target-sh4/cpu.c | 6 ++++++ target-sh4/cpu.h | 5 ----- target-sparc/cpu.c | 10 ++++++++++ target-sparc/cpu.h | 9 --------- target-unicore32/cpu.c | 7 +++++++ target-unicore32/cpu.h | 6 ------ target-xtensa/cpu.c | 8 ++++++++ target-xtensa/cpu.h | 7 ------- 36 files changed, 172 insertions(+), 145 deletions(-)
cpu-exec.c +0 -5
@@ -23,11 +23,6 @@#include "qemu/atomic.h" #include "sysemu/qtest.h" -bool qemu_cpu_has_work (CPUState *cpu) -{ -return cpu_has_work (cpu); -} -void cpu_loop_exit (CPUArchState *env) {CPUState *cpu =ENV_GET_CPU (env);
cpus.c +1 -1
@@ -75,7 +75,7 @@ static bool cpu_thread_is_idle(CPUState *cpu)if (cpu_is_stopped (cpu)) {return true; } -if (!cpu->halted ||qemu_cpu_has_work (cpu) || +if (!cpu->halted ||cpu_has_work (cpu) ||kvm_halt_in_kernel ()) {return false; }
include/qom/cpu.h +10 -2
@@ -69,6 +69,7 @@ struct TranslationBlock;* instantiatable CPU type. * @reset: Callback to reset the #CPUState to its initial state. * @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_unassigned_access: Callback for unassigned access handling. * @memory_rw_debug: Callback for GDB memory access.
@@ -98,6 +99,7 @@ typedef struct CPUClass {void (*reset)(CPUState *cpu);int reset_dump_flags; +bool (*has_work)(CPUState *cpu);void (*do_interrupt)(CPUState *cpu);CPUUnassignedAccess do_unassigned_access; int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
@@ -344,14 +346,20 @@ void cpu_reset(CPUState *cpu);ObjectClass *cpu_class_by_name (const char *typename,const char *cpu_model);/** -* qemu_cpu_has_work: +* cpu_has_work: * @cpu: The vCPU to check. * * Checks whether the CPU has work to do. * * Returns: %true if the CPU has work, %false otherwise. */ -bool qemu_cpu_has_work (CPUState *cpu); +static inline bool cpu_has_work (CPUState *cpu) +{ +CPUClass *cc =CPU_GET_CLASS (cpu); + +g_assert (cc->has_work); +return cc->has_work (cpu); +}/** * qemu_cpu_is_self:
qom/cpu.c +6 -0
@@ -200,6 +200,11 @@ static void cpu_common_reset(CPUState *cpu) cpu->halted =0 ; } +static bool cpu_common_has_work (CPUState *cs) +{ +return false; +} +ObjectClass *cpu_class_by_name (const char *typename,const char *cpu_model) {CPUClass *cc =CPU_CLASS (object_class_by_name (typename));
@@ -244,6 +249,7 @@ static void cpu_class_init(ObjectClass *klass, void *data) k->class_by_name = cpu_common_class_by_name; k->reset = cpu_common_reset; k->get_arch_id = cpu_common_get_arch_id; + k->has_work = cpu_common_has_work; k->get_paging_enabled = cpu_common_get_paging_enabled; k->get_memory_mapping = cpu_common_get_memory_mapping; k->write_elf32_qemunote = cpu_common_write_elf32_qemunote;
target-alpha/cpu.c +16 -0
@@ -31,6 +31,21 @@ static void alpha_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static bool alpha_cpu_has_work (CPUState *cs) +{ +/* Here we are checking to see if the CPU should wake up from HALT. +We will have gotten into this state only for WTINT from PALmode. */ +/* ??? I'm not sure how the IPL state works with WTINT to keep a CPU +asleep even if (some) interrupts have been asserted. For now, +assume that if a CPU really wants to stay asleep, it will mask +interrupts at the chipset level, which will prevent these bits +from being set in the first place. */ +return cs->interrupt_request & (CPU_INTERRUPT_HARD + |CPU_INTERRUPT_TIMER + |CPU_INTERRUPT_SMP + |CPU_INTERRUPT_MCHK ); +} +static void alpha_cpu_realizefn (DeviceState *dev,Error **errp) {CPUState *cs =CPU (dev);
@@ -271,6 +286,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) dc->realize = alpha_cpu_realizefn; cc->class_by_name = alpha_cpu_class_by_name; + cc->has_work = alpha_cpu_has_work; cc->do_interrupt = alpha_cpu_do_interrupt; cc->dump_state = alpha_cpu_dump_state; cc->set_pc = alpha_cpu_set_pc;
target-alpha/cpu.h +0 -15
@@ -498,21 +498,6 @@ static inline void cpu_get_tb_cpu_state(CPUAlphaState *env, target_ulong *pc, *pflags = flags; } -static inline bool cpu_has_work (CPUState *cpu) -{ -/* Here we are checking to see if the CPU should wake up from HALT. -We will have gotten into this state only for WTINT from PALmode. */ -/* ??? I'm not sure how the IPL state works with WTINT to keep a CPU -asleep even if (some) interrupts have been asserted. For now, -assume that if a CPU really wants to stay asleep, it will mask -interrupts at the chipset level, which will prevent these bits -from being set in the first place. */ -return cpu->interrupt_request & (CPU_INTERRUPT_HARD - |CPU_INTERRUPT_TIMER - |CPU_INTERRUPT_SMP - |CPU_INTERRUPT_MCHK ); -} -#include "exec/exec-all.h" #endif /* !defined (__CPU_ALPHA_H__) */
target-arm/cpu.c +7 -0
@@ -34,6 +34,12 @@ static void arm_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.regs[15 ] = value; } +static bool arm_cpu_has_work (CPUState *cs) +{ +return cs->interrupt_request & + (CPU_INTERRUPT_FIQ |CPU_INTERRUPT_HARD |CPU_INTERRUPT_EXITTB ); +} +static void cp_reg_reset (gpointer key,gpointer value,gpointer opaque) {/* Reset a single ARMCPRegInfo register */
@@ -890,6 +896,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->reset = arm_cpu_reset; cc->class_by_name = arm_cpu_class_by_name; + cc->has_work = arm_cpu_has_work; cc->do_interrupt = arm_cpu_do_interrupt; cc->dump_state = arm_cpu_dump_state; cc->set_pc = arm_cpu_set_pc;
target-arm/cpu.h +0 -6
@@ -814,12 +814,6 @@ static inline void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, } } -static inline bool cpu_has_work (CPUState *cpu) -{ -return cpu->interrupt_request & - (CPU_INTERRUPT_FIQ |CPU_INTERRUPT_HARD |CPU_INTERRUPT_EXITTB ); -} -#include "exec/exec-all.h" /* Load an instruction and return it in the standard little-endian order */
target-cris/cpu.c +6 -0
@@ -33,6 +33,11 @@ static void cris_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static bool cris_cpu_has_work (CPUState *cs) +{ +return cs->interrupt_request & (CPU_INTERRUPT_HARD |CPU_INTERRUPT_NMI ); +} +/* CPUClass::reset() */ static void cris_cpu_reset (CPUState *s) {
@@ -257,6 +262,7 @@ static void cris_cpu_class_init(ObjectClass *oc, void *data) cc->reset = cris_cpu_reset; cc->class_by_name = cris_cpu_class_by_name; + cc->has_work = cris_cpu_has_work; cc->do_interrupt = cris_cpu_do_interrupt; cc->dump_state = cris_cpu_dump_state; cc->set_pc = cris_cpu_set_pc;
target-cris/cpu.h +0 -5
@@ -272,11 +272,6 @@ static inline void cpu_get_tb_cpu_state(CPUCRISState *env, target_ulong *pc,#define cpu_list cris_cpu_listvoid cris_cpu_list (FILE *f,fprintf_function cpu_fprintf); -static inline bool cpu_has_work (CPUState *cpu) -{ -return cpu->interrupt_request & (CPU_INTERRUPT_HARD |CPU_INTERRUPT_NMI ); -} -#include "exec/exec-all.h" #endif
target-i386/cpu.c +15 -0
@@ -2676,6 +2676,20 @@ static void x86_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) cpu->env.eip = tb->pc - tb->cs_base; } +static bool x86_cpu_has_work (CPUState *cs) +{ +X86CPU *cpu =X86_CPU (cs); +CPUX86State *env = &cpu->env; + +return ((cs->interrupt_request & (CPU_INTERRUPT_HARD | +CPU_INTERRUPT_POLL )) && + (env->eflags &IF_MASK )) || + (cs->interrupt_request & (CPU_INTERRUPT_NMI | +CPU_INTERRUPT_INIT | +CPU_INTERRUPT_SIPI | +CPU_INTERRUPT_MCE )); +} +static Property x86_cpu_properties[] = {DEFINE_PROP_BOOL ("pmu" ,X86CPU , enable_pmu, false),DEFINE_PROP_END_OF_LIST ()
@@ -2696,6 +2710,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->reset = x86_cpu_reset; cc->reset_dump_flags =CPU_DUMP_FPU |CPU_DUMP_CCOP ; + cc->has_work = x86_cpu_has_work; cc->do_interrupt = x86_cpu_do_interrupt; cc->dump_state = x86_cpu_dump_state; cc->set_pc = x86_cpu_set_pc;
target-i386/cpu.h +0 -14
@@ -1161,20 +1161,6 @@ void optimize_flags_init(void);#include "hw/i386/apic.h" #endif -static inline bool cpu_has_work (CPUState *cs) -{ -X86CPU *cpu =X86_CPU (cs); -CPUX86State *env = &cpu->env; - -return ((cs->interrupt_request & (CPU_INTERRUPT_HARD | -CPU_INTERRUPT_POLL )) && - (env->eflags &IF_MASK )) || - (cs->interrupt_request & (CPU_INTERRUPT_NMI | -CPU_INTERRUPT_INIT | -CPU_INTERRUPT_SIPI | -CPU_INTERRUPT_MCE )); -} -#include "exec/exec-all.h" static inline void cpu_get_tb_cpu_state(CPUX86State *env, target_ulong *pc,
target-lm32/cpu.c +6 -0
@@ -29,6 +29,11 @@ static void lm32_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static bool lm32_cpu_has_work (CPUState *cs) +{ +return cs->interrupt_request &CPU_INTERRUPT_HARD ; +} +/* CPUClass::reset() */ static void lm32_cpu_reset (CPUState *s) {
@@ -86,6 +91,7 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data) lcc->parent_reset = cc->reset; cc->reset = lm32_cpu_reset; + cc->has_work = lm32_cpu_has_work; cc->do_interrupt = lm32_cpu_do_interrupt; cc->dump_state = lm32_cpu_dump_state; cc->set_pc = lm32_cpu_set_pc;
target-lm32/cpu.h +0 -5
@@ -225,11 +225,6 @@ static inline void cpu_get_tb_cpu_state(CPULM32State *env, target_ulong *pc, *flags = 0; } -static inline bool cpu_has_work (CPUState *cpu) -{ -return cpu->interrupt_request &CPU_INTERRUPT_HARD ; -} -#include "exec/exec-all.h" #endif
target-m68k/cpu.c +6 -0
@@ -30,6 +30,11 @@ static void m68k_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static bool m68k_cpu_has_work (CPUState *cs) +{ +return cs->interrupt_request &CPU_INTERRUPT_HARD ; +} +static void m68k_set_feature (CPUM68KState *env,int feature) { env->features |= (1u << feature);
@@ -189,6 +194,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) cc->reset = m68k_cpu_reset; cc->class_by_name = m68k_cpu_class_by_name; + cc->has_work = m68k_cpu_has_work; cc->do_interrupt = m68k_cpu_do_interrupt; cc->dump_state = m68k_cpu_dump_state; cc->set_pc = m68k_cpu_set_pc;
target-m68k/cpu.h +0 -5
@@ -253,11 +253,6 @@ static inline void cpu_get_tb_cpu_state(CPUM68KState *env, target_ulong *pc, | ((env->macsr >> 4) & 0xf); /* Bits 0-3 */ } -static inline bool cpu_has_work (CPUState *cpu) -{ -return cpu->interrupt_request &CPU_INTERRUPT_HARD ; -} -#include "exec/exec-all.h" #endif
target-microblaze/cpu.c +6 -0
@@ -33,6 +33,11 @@ static void mb_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.sregs[SR_PC ] = value; } +static bool mb_cpu_has_work (CPUState *cs) +{ +return cs->interrupt_request & (CPU_INTERRUPT_HARD |CPU_INTERRUPT_NMI ); +} +/* CPUClass::reset() */ static void mb_cpu_reset (CPUState *s) {
@@ -139,6 +144,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data) mcc->parent_reset = cc->reset; cc->reset = mb_cpu_reset; + cc->has_work = mb_cpu_has_work; cc->do_interrupt = mb_cpu_do_interrupt; cc->dump_state = mb_cpu_dump_state; cc->set_pc = mb_cpu_set_pc;
target-microblaze/cpu.h +0 -5
@@ -358,11 +358,6 @@ void mb_cpu_unassigned_access(CPUState *cpu, hwaddr addr, unsigned size);#endif -static inline bool cpu_has_work (CPUState *cpu) -{ -return cpu->interrupt_request & (CPU_INTERRUPT_HARD |CPU_INTERRUPT_NMI ); -} -#include "exec/exec-all.h" #endif
target-mips/cpu.c +30 -0
@@ -45,6 +45,35 @@ static void mips_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) env->hflags |= tb->flags &MIPS_HFLAG_BMASK ; } +static bool mips_cpu_has_work (CPUState *cs) +{ +MIPSCPU *cpu =MIPS_CPU (cs); +CPUMIPSState *env = &cpu->env; +bool has_work = false; + +/* It is implementation dependent if non-enabled interrupts +wake-up the CPU, however most of the implementations only +check for interrupts that can be taken. */ +if ((cs->interrupt_request &CPU_INTERRUPT_HARD ) && +cpu_mips_hw_interrupts_pending (env)) { + has_work = true; + } + +/* MIPS-MT has the ability to halt the CPU. */ +if (env->CP0_Config3 & (1 <<CP0C3_MT )) { +/* The QEMU model will issue an _WAKE request whenever the CPUs +should be woken up. */ +if (cs->interrupt_request &CPU_INTERRUPT_WAKE ) { + has_work = true; + } + +if (!mips_vpe_active (env)) { + has_work = false; + } + } +return has_work; +} +/* CPUClass::reset() */ static void mips_cpu_reset (CPUState *s) {
@@ -97,6 +126,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) mcc->parent_reset = cc->reset; cc->reset = mips_cpu_reset; + 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;
target-mips/cpu.h +0 -28
@@ -702,34 +702,6 @@ static inline int mips_vpe_active(CPUMIPSState *env)return active; } -static inline bool cpu_has_work (CPUState *cpu) -{ -CPUMIPSState *env = &MIPS_CPU (cpu)->env; -bool has_work = false; - -/* It is implementation dependent if non-enabled interrupts -wake-up the CPU, however most of the implementations only -check for interrupts that can be taken. */ -if ((cpu->interrupt_request &CPU_INTERRUPT_HARD ) && -cpu_mips_hw_interrupts_pending (env)) { - has_work = true; - } - -/* MIPS-MT has the ability to halt the CPU. */ -if (env->CP0_Config3 & (1 <<CP0C3_MT )) { -/* The QEMU model will issue an _WAKE request whenever the CPUs -should be woken up. */ -if (cpu->interrupt_request &CPU_INTERRUPT_WAKE ) { - has_work = true; - } - -if (!mips_vpe_active (env)) { - has_work = false; - } - } -return has_work; -} -#include "exec/exec-all.h" static inline void compute_hflags (CPUMIPSState *env)
target-moxie/cpu.c +6 -0
@@ -29,6 +29,11 @@ static void moxie_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static bool moxie_cpu_has_work (CPUState *cs) +{ +return cs->interrupt_request &CPU_INTERRUPT_HARD ; +} +static void moxie_cpu_reset (CPUState *s) {MoxieCPU *cpu =MOXIE_CPU (s);
@@ -99,6 +104,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->dump_state = moxie_cpu_dump_state; cc->set_pc = moxie_cpu_set_pc;
target-moxie/cpu.h +0 -5
@@ -152,11 +152,6 @@ static inline void cpu_get_tb_cpu_state(CPUMoxieState *env, target_ulong *pc, *flags =0 ; } -static inline int cpu_has_work (CPUState *cpu) -{ -return cpu->interrupt_request &CPU_INTERRUPT_HARD ; -} -int cpu_moxie_handle_mmu_fault (CPUMoxieState *env,target_ulong address,int rw,int mmu_idx);
target-openrisc/cpu.c +7 -0
@@ -27,6 +27,12 @@ static void openrisc_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static bool openrisc_cpu_has_work (CPUState *cs) +{ +return cs->interrupt_request & (CPU_INTERRUPT_HARD | +CPU_INTERRUPT_TIMER ); +} +/* CPUClass::reset() */ static void openrisc_cpu_reset (CPUState *s) {
@@ -153,6 +159,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data) cc->reset = openrisc_cpu_reset; cc->class_by_name = openrisc_cpu_class_by_name; + cc->has_work = openrisc_cpu_has_work; cc->do_interrupt = openrisc_cpu_do_interrupt; cc->dump_state = openrisc_cpu_dump_state; cc->set_pc = openrisc_cpu_set_pc;
target-openrisc/cpu.h +0 -5
@@ -418,11 +418,6 @@ static inline int cpu_mmu_index(CPUOpenRISCState *env) }#define CPU_INTERRUPT_TIMER CPU_INTERRUPT_TGT_INT_0 -static inline bool cpu_has_work (CPUState *cpu) -{ -return cpu->interrupt_request & (CPU_INTERRUPT_HARD | -CPU_INTERRUPT_TIMER ); -}#include "exec/exec-all.h"
target-ppc/cpu.h +0 -8
@@ -2134,14 +2134,6 @@ static inline bool msr_is_64bit(CPUPPCState *env, target_ulong msr)extern void (*cpu_ppc_hypercall)(PowerPCCPU *); -static inline bool cpu_has_work (CPUState *cpu) -{ -PowerPCCPU *ppc_cpu =POWERPC_CPU (cpu); -CPUPPCState *env = &ppc_cpu->env; - -return msr_ee && (cpu->interrupt_request &CPU_INTERRUPT_HARD ); -} -#include "exec/exec-all.h" void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUPPCState *env);
target-ppc/translate_init.c +9 -0
@@ -8437,6 +8437,14 @@ static void ppc_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.nip = value; } +static bool ppc_cpu_has_work (CPUState *cs) +{ +PowerPCCPU *cpu =POWERPC_CPU (cs); +CPUPPCState *env = &cpu->env; + +return msr_ee && (cs->interrupt_request &CPU_INTERRUPT_HARD ); +} +/* CPUClass::reset() */ static void ppc_cpu_reset (CPUState *s) {
@@ -8561,6 +8569,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->reset = ppc_cpu_reset; cc->class_by_name = ppc_cpu_class_by_name; + 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;
target-s390x/cpu.c +10 -0
@@ -65,6 +65,15 @@ static void s390_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.psw.addr = value; } +static bool s390_cpu_has_work (CPUState *cs) +{ +S390CPU *cpu =S390_CPU (cs); +CPUS390XState *env = &cpu->env; + +return (cs->interrupt_request &CPU_INTERRUPT_HARD ) && + (env->psw.mask &PSW_MASK_EXT ); +} +#if !defined(CONFIG_USER_ONLY )/* S390CPUClass::load_normal() */ static void s390_cpu_load_normal (CPUState *s)
@@ -217,6 +226,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) scc->cpu_reset = s390_cpu_reset; scc->initial_cpu_reset = s390_cpu_initial_reset; cc->reset = s390_cpu_full_reset; + cc->has_work = s390_cpu_has_work; cc->do_interrupt = s390_cpu_do_interrupt; cc->dump_state = s390_cpu_dump_state; cc->set_pc = s390_cpu_set_pc;
target-s390x/cpu.h +0 -9
@@ -1036,15 +1036,6 @@ static inline void cpu_inject_crw_mchk(S390CPU *cpu)cpu_interrupt (CPU (cpu),CPU_INTERRUPT_HARD ); } -static inline bool cpu_has_work (CPUState *cpu) -{ -S390CPU *s390_cpu =S390_CPU (cpu); -CPUS390XState *env = &s390_cpu->env; - -return (cpu->interrupt_request &CPU_INTERRUPT_HARD ) && - (env->psw.mask &PSW_MASK_EXT ); -} -/* fpu_helper.c */ uint32_t set_cc_nz_f32 (float32 v);uint32_t set_cc_nz_f64 (float64 v);
target-sh4/cpu.c +6 -0
@@ -39,6 +39,11 @@ static void superh_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) cpu->env.flags = tb->flags; } +static bool superh_cpu_has_work (CPUState *cs) +{ +return cs->interrupt_request &CPU_INTERRUPT_HARD ; +} +/* CPUClass::reset() */ static void superh_cpu_reset (CPUState *s) {
@@ -283,6 +288,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) cc->reset = superh_cpu_reset; cc->class_by_name = superh_cpu_class_by_name; + cc->has_work = superh_cpu_has_work; cc->do_interrupt = superh_cpu_do_interrupt; cc->dump_state = superh_cpu_dump_state; cc->set_pc = superh_cpu_set_pc;
target-sh4/cpu.h +0 -5
@@ -352,11 +352,6 @@ static inline void cpu_get_tb_cpu_state(CPUSH4State *env, target_ulong *pc, | (env->movcal_backup ? TB_FLAG_PENDING_MOVCA : 0); /* Bit 4 */ } -static inline bool cpu_has_work (CPUState *cpu) -{ -return cpu->interrupt_request &CPU_INTERRUPT_HARD ; -} -#include "exec/exec-all.h" #endif /* _CPU_SH4_H */
target-sparc/cpu.c +10 -0
@@ -739,6 +739,15 @@ static void sparc_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) cpu->env.npc = tb->cs_base; } +static bool sparc_cpu_has_work (CPUState *cs) +{ +SPARCCPU *cpu =SPARC_CPU (cs); +CPUSPARCState *env = &cpu->env; + +return (cs->interrupt_request &CPU_INTERRUPT_HARD ) && +cpu_interrupts_enabled (env); +} +static void sparc_cpu_realizefn (DeviceState *dev,Error **errp) {SPARCCPUClass *scc =SPARC_CPU_GET_CLASS (dev);
@@ -782,6 +791,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data) scc->parent_reset = cc->reset; cc->reset = sparc_cpu_reset; + cc->has_work = sparc_cpu_has_work; cc->do_interrupt = sparc_cpu_do_interrupt; cc->dump_state = sparc_cpu_dump_state;#if !defined(TARGET_SPARC64 ) && !defined(CONFIG_USER_ONLY )
target-sparc/cpu.h +0 -9
@@ -747,15 +747,6 @@ static inline bool tb_am_enabled(int tb_flags) #endif } -static inline bool cpu_has_work (CPUState *cpu) -{ -SPARCCPU *sparc_cpu =SPARC_CPU (cpu); -CPUSPARCState *env1 = &sparc_cpu->env; - -return (cpu->interrupt_request &CPU_INTERRUPT_HARD ) && -cpu_interrupts_enabled (env1); -} -#include "exec/exec-all.h" #endif
target-unicore32/cpu.c +7 -0
@@ -23,6 +23,12 @@ static void uc32_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.regs[31 ] = value; } +static bool uc32_cpu_has_work (CPUState *cs) +{ +return cs->interrupt_request & + (CPU_INTERRUPT_HARD |CPU_INTERRUPT_EXITTB ); +} +static inline void set_feature (CPUUniCore32State *env,int feature) { env->features |= feature;
@@ -138,6 +144,7 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data) dc->realize = uc32_cpu_realizefn; cc->class_by_name = uc32_cpu_class_by_name; + cc->has_work = uc32_cpu_has_work; cc->do_interrupt = uc32_cpu_do_interrupt; cc->dump_state = uc32_cpu_dump_state; cc->set_pc = uc32_cpu_set_pc;
target-unicore32/cpu.h +0 -6
@@ -160,10 +160,4 @@ static inline void cpu_get_tb_cpu_state(CPUUniCore32State *env, target_ulong *pcvoid uc32_translate_init (void );void switch_mode (CPUUniCore32State *,int ); -static inline bool cpu_has_work (CPUState *cpu) -{ -return cpu->interrupt_request & - (CPU_INTERRUPT_HARD |CPU_INTERRUPT_EXITTB ); -} -#endif /* QEMU_UNICORE32_CPU_H */
target-xtensa/cpu.c +8 -0
@@ -40,6 +40,13 @@ static void xtensa_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static bool xtensa_cpu_has_work (CPUState *cs) +{ +XtensaCPU *cpu =XTENSA_CPU (cs); + +return cpu->env.pending_irq_level; +} +/* CPUClass::reset() */ static void xtensa_cpu_reset (CPUState *s) {
@@ -132,6 +139,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data) cc->reset = xtensa_cpu_reset; cc->class_by_name = xtensa_cpu_class_by_name; + cc->has_work = xtensa_cpu_has_work; cc->do_interrupt = xtensa_cpu_do_interrupt; cc->dump_state = xtensa_cpu_dump_state; cc->set_pc = xtensa_cpu_set_pc;
target-xtensa/cpu.h +0 -7
@@ -519,11 +519,4 @@ static inline void cpu_get_tb_cpu_state(CPUXtensaState *env, target_ulong *pc,#include "exec/cpu-all.h" #include "exec/exec-all.h" -static inline int cpu_has_work (CPUState *cpu) -{ -CPUXtensaState *env = &XTENSA_CPU (cpu)->env; - -return env->pending_irq_level; -} -#endif
Signature · 1 line
1.8.1.4
Re: [Qemu-devel] [RFC qom-cpu 01/41] cpu: Turn cpu_has_work() into a CPUClass hook
Quoted 882 lines · Andreas Färber
Default to false.
Tidy variable naming and inline cast uses while at it.
Signed-off-by Andreas Färber <[email protected]>--- cpu-exec.c | 5 ----- cpus.c | 2 +- include/qom/cpu.h | 12 ++++++++++-- qom/cpu.c | 6 ++++++ target-alpha/cpu.c | 16 ++++++++++++++++ target-alpha/cpu.h | 15 --------------- target-arm/cpu.c | 7 +++++++ target-arm/cpu.h | 6 ------ target-cris/cpu.c | 6 ++++++ target-cris/cpu.h | 5 ----- target-i386/cpu.c | 15 +++++++++++++++ target-i386/cpu.h | 14 -------------- target-lm32/cpu.c | 6 ++++++ target-lm32/cpu.h | 5 ----- target-m68k/cpu.c | 6 ++++++ target-m68k/cpu.h | 5 ----- target-microblaze/cpu.c | 6 ++++++ target-microblaze/cpu.h | 5 ----- target-mips/cpu.c | 30 ++++++++++++++++++++++++++++++ target-mips/cpu.h | 28 ---------------------------- target-moxie/cpu.c | 6 ++++++ target-moxie/cpu.h | 5 ----- target-openrisc/cpu.c | 7 +++++++ target-openrisc/cpu.h | 5 ----- target-ppc/cpu.h | 8 -------- target-ppc/translate_init.c | 9 +++++++++ target-s390x/cpu.c | 10 ++++++++++ target-s390x/cpu.h | 9 --------- target-sh4/cpu.c | 6 ++++++ target-sh4/cpu.h | 5 ----- target-sparc/cpu.c | 10 ++++++++++ target-sparc/cpu.h | 9 --------- target-unicore32/cpu.c | 7 +++++++ target-unicore32/cpu.h | 6 ------ target-xtensa/cpu.c | 8 ++++++++ target-xtensa/cpu.h | 7 ------- 36 files changed, 172 insertions(+), 145 deletions(-)cpu-exec.c +0
-5@@ -23,11 +23,6 @@#include "qemu/atomic.h" #include "sysemu/qtest.h" -bool qemu_cpu_has_work (CPUState *cpu) -{ -return cpu_has_work (cpu); -} -void cpu_loop_exit (CPUArchState *env) {CPUState *cpu =ENV_GET_CPU (env);cpus.c +1
-1@@ -75,7 +75,7 @@ static bool cpu_thread_is_idle(CPUState *cpu)if (cpu_is_stopped (cpu)) {return true; } -if (!cpu->halted ||qemu_cpu_has_work (cpu) || +if (!cpu->halted ||cpu_has_work (cpu) ||kvm_halt_in_kernel ()) {return false; }include/qom/cpu.h +10
-2@@ -69,6 +69,7 @@ struct TranslationBlock;* instantiatable CPU type. * @reset: Callback to reset the #CPUState to its initial state. * @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_unassigned_access: Callback for unassigned access handling. * @memory_rw_debug: Callback for GDB memory access. @@ -98,6 +99,7 @@ typedef struct CPUClass {void (*reset)(CPUState *cpu);int reset_dump_flags; +bool (*has_work)(CPUState *cpu);void (*do_interrupt)(CPUState *cpu);CPUUnassignedAccess do_unassigned_access; int (*memory_rw_debug)(CPUState *cpu, vaddr addr,@@ -344,14 +346,20 @@ void cpu_reset(CPUState *cpu);ObjectClass *cpu_class_by_name (const char *typename,const char *cpu_model);/** -* qemu_cpu_has_work: +* cpu_has_work: * @cpu: The vCPU to check. * * Checks whether the CPU has work to do. * * Returns: %true if the CPU has work, %false otherwise. */ -bool qemu_cpu_has_work (CPUState *cpu); +static inline bool cpu_has_work (CPUState *cpu) +{ +CPUClass *cc =CPU_GET_CLASS (cpu); + +g_assert (cc->has_work); +return cc->has_work (cpu); +}/** * qemu_cpu_is_self: qom/cpu.c +6
-0@@ -200,6 +200,11 @@ static void cpu_common_reset(CPUState *cpu) cpu->halted =0 ; } +static bool cpu_common_has_work (CPUState *cs) +{ +return false; +} +ObjectClass *cpu_class_by_name (const char *typename,const char *cpu_model) {CPUClass *cc =CPU_CLASS (object_class_by_name (typename));@@ -244,6 +249,7 @@ static void cpu_class_init(ObjectClass *klass, void *data) k->class_by_name = cpu_common_class_by_name; k->reset = cpu_common_reset; k->get_arch_id = cpu_common_get_arch_id; + k->has_work = cpu_common_has_work; k->get_paging_enabled = cpu_common_get_paging_enabled; k->get_memory_mapping = cpu_common_get_memory_mapping; k->write_elf32_qemunote = cpu_common_write_elf32_qemunote;target-alpha/cpu.c +16
-0@@ -31,6 +31,21 @@ static void alpha_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static bool alpha_cpu_has_work (CPUState *cs) +{ +/* Here we are checking to see if the CPU should wake up from HALT. +We will have gotten into this state only for WTINT from PALmode. */ +/* ??? I'm not sure how the IPL state works with WTINT to keep a CPU +asleep even if (some) interrupts have been asserted. For now, +assume that if a CPU really wants to stay asleep, it will mask +interrupts at the chipset level, which will prevent these bits +from being set in the first place. */ +return cs->interrupt_request & (CPU_INTERRUPT_HARD + |CPU_INTERRUPT_TIMER + |CPU_INTERRUPT_SMP + |CPU_INTERRUPT_MCHK ); +} +static void alpha_cpu_realizefn (DeviceState *dev,Error **errp) {CPUState *cs =CPU (dev);@@ -271,6 +286,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) dc->realize = alpha_cpu_realizefn; cc->class_by_name = alpha_cpu_class_by_name; + cc->has_work = alpha_cpu_has_work; cc->do_interrupt = alpha_cpu_do_interrupt; cc->dump_state = alpha_cpu_dump_state; cc->set_pc = alpha_cpu_set_pc;target-alpha/cpu.h +0
-15@@ -498,21 +498,6 @@ static inline void cpu_get_tb_cpu_state(CPUAlphaState *env, target_ulong *pc, *pflags = flags; } -static inline bool cpu_has_work (CPUState *cpu) -{ -/* Here we are checking to see if the CPU should wake up from HALT. -We will have gotten into this state only for WTINT from PALmode. */ -/* ??? I'm not sure how the IPL state works with WTINT to keep a CPU -asleep even if (some) interrupts have been asserted. For now, -assume that if a CPU really wants to stay asleep, it will mask -interrupts at the chipset level, which will prevent these bits -from being set in the first place. */ -return cpu->interrupt_request & (CPU_INTERRUPT_HARD - |CPU_INTERRUPT_TIMER - |CPU_INTERRUPT_SMP - |CPU_INTERRUPT_MCHK ); -} -#include "exec/exec-all.h" #endif /* !defined (__CPU_ALPHA_H__) */ target-arm/cpu.c +7
-0@@ -34,6 +34,12 @@ static void arm_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.regs[15 ] = value; } +static bool arm_cpu_has_work (CPUState *cs) +{ +return cs->interrupt_request & + (CPU_INTERRUPT_FIQ |CPU_INTERRUPT_HARD |CPU_INTERRUPT_EXITTB ); +} +static void cp_reg_reset (gpointer key,gpointer value,gpointer opaque) {/* Reset a single ARMCPRegInfo register */ @@ -890,6 +896,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->reset = arm_cpu_reset; cc->class_by_name = arm_cpu_class_by_name; + cc->has_work = arm_cpu_has_work; cc->do_interrupt = arm_cpu_do_interrupt; cc->dump_state = arm_cpu_dump_state; cc->set_pc = arm_cpu_set_pc;target-arm/cpu.h +0
-6@@ -814,12 +814,6 @@ static inline void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, } } -static inline bool cpu_has_work (CPUState *cpu) -{ -return cpu->interrupt_request & - (CPU_INTERRUPT_FIQ |CPU_INTERRUPT_HARD |CPU_INTERRUPT_EXITTB ); -} -#include "exec/exec-all.h" /* Load an instruction and return it in the standard little-endian order */ target-cris/cpu.c +6
-0@@ -33,6 +33,11 @@ static void cris_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static bool cris_cpu_has_work (CPUState *cs) +{ +return cs->interrupt_request & (CPU_INTERRUPT_HARD |CPU_INTERRUPT_NMI ); +} +/* CPUClass::reset() */ static void cris_cpu_reset (CPUState *s) {@@ -257,6 +262,7 @@ static void cris_cpu_class_init(ObjectClass *oc, void *data) cc->reset = cris_cpu_reset; cc->class_by_name = cris_cpu_class_by_name; + cc->has_work = cris_cpu_has_work; cc->do_interrupt = cris_cpu_do_interrupt; cc->dump_state = cris_cpu_dump_state; cc->set_pc = cris_cpu_set_pc;target-cris/cpu.h +0
-5@@ -272,11 +272,6 @@ static inline void cpu_get_tb_cpu_state(CPUCRISState *env, target_ulong *pc,#define cpu_list cris_cpu_listvoid cris_cpu_list (FILE *f,fprintf_function cpu_fprintf); -static inline bool cpu_has_work (CPUState *cpu) -{ -return cpu->interrupt_request & (CPU_INTERRUPT_HARD |CPU_INTERRUPT_NMI ); -} -#include "exec/exec-all.h" #endif target-i386/cpu.c +15
-0@@ -2676,6 +2676,20 @@ static void x86_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) cpu->env.eip = tb->pc - tb->cs_base; } +static bool x86_cpu_has_work (CPUState *cs) +{ +X86CPU *cpu =X86_CPU (cs); +CPUX86State *env = &cpu->env; + +return ((cs->interrupt_request & (CPU_INTERRUPT_HARD | +CPU_INTERRUPT_POLL )) && + (env->eflags &IF_MASK )) || + (cs->interrupt_request & (CPU_INTERRUPT_NMI | +CPU_INTERRUPT_INIT | +CPU_INTERRUPT_SIPI | +CPU_INTERRUPT_MCE )); +} +static Property x86_cpu_properties[] = {DEFINE_PROP_BOOL ("pmu" ,X86CPU , enable_pmu, false),DEFINE_PROP_END_OF_LIST ()@@ -2696,6 +2710,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->reset = x86_cpu_reset; cc->reset_dump_flags =CPU_DUMP_FPU |CPU_DUMP_CCOP ; + cc->has_work = x86_cpu_has_work; cc->do_interrupt = x86_cpu_do_interrupt; cc->dump_state = x86_cpu_dump_state; cc->set_pc = x86_cpu_set_pc;target-i386/cpu.h +0
-14@@ -1161,20 +1161,6 @@ void optimize_flags_init(void);#include "hw/i386/apic.h" #endif -static inline bool cpu_has_work (CPUState *cs) -{ -X86CPU *cpu =X86_CPU (cs); -CPUX86State *env = &cpu->env; - -return ((cs->interrupt_request & (CPU_INTERRUPT_HARD | -CPU_INTERRUPT_POLL )) && - (env->eflags &IF_MASK )) || - (cs->interrupt_request & (CPU_INTERRUPT_NMI | -CPU_INTERRUPT_INIT | -CPU_INTERRUPT_SIPI | -CPU_INTERRUPT_MCE )); -} -#include "exec/exec-all.h" static inline void cpu_get_tb_cpu_state(CPUX86State *env, target_ulong *pc,target-lm32/cpu.c +6
-0@@ -29,6 +29,11 @@ static void lm32_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static bool lm32_cpu_has_work (CPUState *cs) +{ +return cs->interrupt_request &CPU_INTERRUPT_HARD ; +} +/* CPUClass::reset() */ static void lm32_cpu_reset (CPUState *s) {@@ -86,6 +91,7 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data) lcc->parent_reset = cc->reset; cc->reset = lm32_cpu_reset; + cc->has_work = lm32_cpu_has_work; cc->do_interrupt = lm32_cpu_do_interrupt; cc->dump_state = lm32_cpu_dump_state; cc->set_pc = lm32_cpu_set_pc;target-lm32/cpu.h +0
-5@@ -225,11 +225,6 @@ static inline void cpu_get_tb_cpu_state(CPULM32State *env, target_ulong *pc, *flags = 0; } -static inline bool cpu_has_work (CPUState *cpu) -{ -return cpu->interrupt_request &CPU_INTERRUPT_HARD ; -} -#include "exec/exec-all.h" #endif target-m68k/cpu.c +6
-0@@ -30,6 +30,11 @@ static void m68k_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static bool m68k_cpu_has_work (CPUState *cs) +{ +return cs->interrupt_request &CPU_INTERRUPT_HARD ; +} +static void m68k_set_feature (CPUM68KState *env,int feature) { env->features |= (1u << feature);@@ -189,6 +194,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) cc->reset = m68k_cpu_reset; cc->class_by_name = m68k_cpu_class_by_name; + cc->has_work = m68k_cpu_has_work; cc->do_interrupt = m68k_cpu_do_interrupt; cc->dump_state = m68k_cpu_dump_state; cc->set_pc = m68k_cpu_set_pc;target-m68k/cpu.h +0
-5@@ -253,11 +253,6 @@ static inline void cpu_get_tb_cpu_state(CPUM68KState *env, target_ulong *pc, | ((env->macsr >> 4) & 0xf); /* Bits 0-3 */ } -static inline bool cpu_has_work (CPUState *cpu) -{ -return cpu->interrupt_request &CPU_INTERRUPT_HARD ; -} -#include "exec/exec-all.h" #endif target-microblaze/cpu.c +6
-0@@ -33,6 +33,11 @@ static void mb_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.sregs[SR_PC ] = value; } +static bool mb_cpu_has_work (CPUState *cs) +{ +return cs->interrupt_request & (CPU_INTERRUPT_HARD |CPU_INTERRUPT_NMI ); +} +/* CPUClass::reset() */ static void mb_cpu_reset (CPUState *s) {@@ -139,6 +144,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data) mcc->parent_reset = cc->reset; cc->reset = mb_cpu_reset; + cc->has_work = mb_cpu_has_work; cc->do_interrupt = mb_cpu_do_interrupt; cc->dump_state = mb_cpu_dump_state; cc->set_pc = mb_cpu_set_pc;target-microblaze/cpu.h +0
-5@@ -358,11 +358,6 @@ void mb_cpu_unassigned_access(CPUState *cpu, hwaddr addr, unsigned size);#endif -static inline bool cpu_has_work (CPUState *cpu) -{ -return cpu->interrupt_request & (CPU_INTERRUPT_HARD |CPU_INTERRUPT_NMI ); -} -#include "exec/exec-all.h" #endif target-mips/cpu.c +30
-0@@ -45,6 +45,35 @@ static void mips_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) env->hflags |= tb->flags &MIPS_HFLAG_BMASK ; } +static bool mips_cpu_has_work (CPUState *cs) +{ +MIPSCPU *cpu =MIPS_CPU (cs); +CPUMIPSState *env = &cpu->env; +bool has_work = false; + +/* It is implementation dependent if non-enabled interrupts +wake-up the CPU, however most of the implementations only +check for interrupts that can be taken. */ +if ((cs->interrupt_request &CPU_INTERRUPT_HARD ) && +cpu_mips_hw_interrupts_pending (env)) { + has_work = true; + } + +/* MIPS-MT has the ability to halt the CPU. */ +if (env->CP0_Config3 & (1 <<CP0C3_MT )) { +/* The QEMU model will issue an _WAKE request whenever the CPUs +should be woken up. */ +if (cs->interrupt_request &CPU_INTERRUPT_WAKE ) { + has_work = true; + } + +if (!mips_vpe_active (env)) { + has_work = false; + } + } +return has_work; +} +/* CPUClass::reset() */ static void mips_cpu_reset (CPUState *s) {@@ -97,6 +126,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) mcc->parent_reset = cc->reset; cc->reset = mips_cpu_reset; + 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;target-mips/cpu.h +0
-28@@ -702,34 +702,6 @@ static inline int mips_vpe_active(CPUMIPSState *env)return active; } -static inline bool cpu_has_work (CPUState *cpu) -{ -CPUMIPSState *env = &MIPS_CPU (cpu)->env; -bool has_work = false; - -/* It is implementation dependent if non-enabled interrupts -wake-up the CPU, however most of the implementations only -check for interrupts that can be taken. */ -if ((cpu->interrupt_request &CPU_INTERRUPT_HARD ) && -cpu_mips_hw_interrupts_pending (env)) { - has_work = true; - } - -/* MIPS-MT has the ability to halt the CPU. */ -if (env->CP0_Config3 & (1 <<CP0C3_MT )) { -/* The QEMU model will issue an _WAKE request whenever the CPUs -should be woken up. */ -if (cpu->interrupt_request &CPU_INTERRUPT_WAKE ) { - has_work = true; - } - -if (!mips_vpe_active (env)) { - has_work = false; - } - } -return has_work; -} -#include "exec/exec-all.h" static inline void compute_hflags (CPUMIPSState *env)target-moxie/cpu.c +6
-0@@ -29,6 +29,11 @@ static void moxie_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static bool moxie_cpu_has_work (CPUState *cs) +{ +return cs->interrupt_request &CPU_INTERRUPT_HARD ; +} +static void moxie_cpu_reset (CPUState *s) {MoxieCPU *cpu =MOXIE_CPU (s);@@ -99,6 +104,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->dump_state = moxie_cpu_dump_state; cc->set_pc = moxie_cpu_set_pc;target-moxie/cpu.h +0
-5@@ -152,11 +152,6 @@ static inline void cpu_get_tb_cpu_state(CPUMoxieState *env, target_ulong *pc, *flags =0 ; } -static inline int cpu_has_work (CPUState *cpu) -{ -return cpu->interrupt_request &CPU_INTERRUPT_HARD ; -} -int cpu_moxie_handle_mmu_fault (CPUMoxieState *env,target_ulong address,int rw,int mmu_idx);target-openrisc/cpu.c +7
-0@@ -27,6 +27,12 @@ static void openrisc_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static bool openrisc_cpu_has_work (CPUState *cs) +{ +return cs->interrupt_request & (CPU_INTERRUPT_HARD | +CPU_INTERRUPT_TIMER ); +} +/* CPUClass::reset() */ static void openrisc_cpu_reset (CPUState *s) {@@ -153,6 +159,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data) cc->reset = openrisc_cpu_reset; cc->class_by_name = openrisc_cpu_class_by_name; + cc->has_work = openrisc_cpu_has_work; cc->do_interrupt = openrisc_cpu_do_interrupt; cc->dump_state = openrisc_cpu_dump_state; cc->set_pc = openrisc_cpu_set_pc;target-openrisc/cpu.h +0
-5@@ -418,11 +418,6 @@ static inline int cpu_mmu_index(CPUOpenRISCState *env) }#define CPU_INTERRUPT_TIMER CPU_INTERRUPT_TGT_INT_0 -static inline bool cpu_has_work (CPUState *cpu) -{ -return cpu->interrupt_request & (CPU_INTERRUPT_HARD | -CPU_INTERRUPT_TIMER ); -}#include "exec/exec-all.h" target-ppc/cpu.h +0
-8@@ -2134,14 +2134,6 @@ static inline bool msr_is_64bit(CPUPPCState *env, target_ulong msr)extern void (*cpu_ppc_hypercall)(PowerPCCPU *); -static inline bool cpu_has_work (CPUState *cpu) -{ -PowerPCCPU *ppc_cpu =POWERPC_CPU (cpu); -CPUPPCState *env = &ppc_cpu->env; - -return msr_ee && (cpu->interrupt_request &CPU_INTERRUPT_HARD ); -} -#include "exec/exec-all.h" void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUPPCState *env);target-ppc/translate_init.c +9
-0@@ -8437,6 +8437,14 @@ static void ppc_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.nip = value; } +static bool ppc_cpu_has_work (CPUState *cs) +{ +PowerPCCPU *cpu =POWERPC_CPU (cs); +CPUPPCState *env = &cpu->env; + +return msr_ee && (cs->interrupt_request &CPU_INTERRUPT_HARD ); +} +/* CPUClass::reset() */ static void ppc_cpu_reset (CPUState *s) {@@ -8561,6 +8569,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->reset = ppc_cpu_reset; cc->class_by_name = ppc_cpu_class_by_name; + 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;target-s390x/cpu.c +10
-0@@ -65,6 +65,15 @@ static void s390_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.psw.addr = value; } +static bool s390_cpu_has_work (CPUState *cs) +{ +S390CPU *cpu =S390_CPU (cs); +CPUS390XState *env = &cpu->env; + +return (cs->interrupt_request &CPU_INTERRUPT_HARD ) && + (env->psw.mask &PSW_MASK_EXT ); +} +#if !defined(CONFIG_USER_ONLY )/* S390CPUClass::load_normal() */ static void s390_cpu_load_normal (CPUState *s)@@ -217,6 +226,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) scc->cpu_reset = s390_cpu_reset; scc->initial_cpu_reset = s390_cpu_initial_reset; cc->reset = s390_cpu_full_reset; + cc->has_work = s390_cpu_has_work; cc->do_interrupt = s390_cpu_do_interrupt; cc->dump_state = s390_cpu_dump_state; cc->set_pc = s390_cpu_set_pc;target-s390x/cpu.h +0
-9@@ -1036,15 +1036,6 @@ static inline void cpu_inject_crw_mchk(S390CPU *cpu)cpu_interrupt (CPU (cpu),CPU_INTERRUPT_HARD ); } -static inline bool cpu_has_work (CPUState *cpu) -{ -S390CPU *s390_cpu =S390_CPU (cpu); -CPUS390XState *env = &s390_cpu->env; - -return (cpu->interrupt_request &CPU_INTERRUPT_HARD ) && - (env->psw.mask &PSW_MASK_EXT ); -} -/* fpu_helper.c */ uint32_t set_cc_nz_f32 (float32 v);uint32_t set_cc_nz_f64 (float64 v);target-sh4/cpu.c +6
-0@@ -39,6 +39,11 @@ static void superh_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) cpu->env.flags = tb->flags; } +static bool superh_cpu_has_work (CPUState *cs) +{ +return cs->interrupt_request &CPU_INTERRUPT_HARD ; +} +/* CPUClass::reset() */ static void superh_cpu_reset (CPUState *s) {@@ -283,6 +288,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) cc->reset = superh_cpu_reset; cc->class_by_name = superh_cpu_class_by_name; + cc->has_work = superh_cpu_has_work; cc->do_interrupt = superh_cpu_do_interrupt; cc->dump_state = superh_cpu_dump_state; cc->set_pc = superh_cpu_set_pc;target-sh4/cpu.h +0
-5@@ -352,11 +352,6 @@ static inline void cpu_get_tb_cpu_state(CPUSH4State *env, target_ulong *pc, | (env->movcal_backup ? TB_FLAG_PENDING_MOVCA : 0); /* Bit 4 */ } -static inline bool cpu_has_work (CPUState *cpu) -{ -return cpu->interrupt_request &CPU_INTERRUPT_HARD ; -} -#include "exec/exec-all.h" #endif /* _CPU_SH4_H */ target-sparc/cpu.c +10
-0@@ -739,6 +739,15 @@ static void sparc_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) cpu->env.npc = tb->cs_base; } +static bool sparc_cpu_has_work (CPUState *cs) +{ +SPARCCPU *cpu =SPARC_CPU (cs); +CPUSPARCState *env = &cpu->env; + +return (cs->interrupt_request &CPU_INTERRUPT_HARD ) && +cpu_interrupts_enabled (env); +} +static void sparc_cpu_realizefn (DeviceState *dev,Error **errp) {SPARCCPUClass *scc =SPARC_CPU_GET_CLASS (dev);@@ -782,6 +791,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data) scc->parent_reset = cc->reset; cc->reset = sparc_cpu_reset; + cc->has_work = sparc_cpu_has_work; cc->do_interrupt = sparc_cpu_do_interrupt; cc->dump_state = sparc_cpu_dump_state;#if !defined(TARGET_SPARC64 ) && !defined(CONFIG_USER_ONLY )target-sparc/cpu.h +0
-9@@ -747,15 +747,6 @@ static inline bool tb_am_enabled(int tb_flags) #endif } -static inline bool cpu_has_work (CPUState *cpu) -{ -SPARCCPU *sparc_cpu =SPARC_CPU (cpu); -CPUSPARCState *env1 = &sparc_cpu->env; - -return (cpu->interrupt_request &CPU_INTERRUPT_HARD ) && -cpu_interrupts_enabled (env1); -} -#include "exec/exec-all.h" #endif target-unicore32/cpu.c +7
-0@@ -23,6 +23,12 @@ static void uc32_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.regs[31 ] = value; } +static bool uc32_cpu_has_work (CPUState *cs) +{ +return cs->interrupt_request & + (CPU_INTERRUPT_HARD |CPU_INTERRUPT_EXITTB ); +} +static inline void set_feature (CPUUniCore32State *env,int feature) { env->features |= feature;@@ -138,6 +144,7 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data) dc->realize = uc32_cpu_realizefn; cc->class_by_name = uc32_cpu_class_by_name; + cc->has_work = uc32_cpu_has_work; cc->do_interrupt = uc32_cpu_do_interrupt; cc->dump_state = uc32_cpu_dump_state; cc->set_pc = uc32_cpu_set_pc;target-unicore32/cpu.h +0
-6@@ -160,10 +160,4 @@ static inline void cpu_get_tb_cpu_state(CPUUniCore32State *env, target_ulong *pcvoid uc32_translate_init (void );void switch_mode (CPUUniCore32State *,int ); -static inline bool cpu_has_work (CPUState *cpu) -{ -return cpu->interrupt_request & - (CPU_INTERRUPT_HARD |CPU_INTERRUPT_EXITTB ); -} -#endif /* QEMU_UNICORE32_CPU_H */ target-xtensa/cpu.c +8
-0@@ -40,6 +40,13 @@ static void xtensa_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static bool xtensa_cpu_has_work (CPUState *cs) +{ +XtensaCPU *cpu =XTENSA_CPU (cs); + +return cpu->env.pending_irq_level; +} +/* CPUClass::reset() */ static void xtensa_cpu_reset (CPUState *s) {@@ -132,6 +139,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data) cc->reset = xtensa_cpu_reset; cc->class_by_name = xtensa_cpu_class_by_name; + cc->has_work = xtensa_cpu_has_work; cc->do_interrupt = xtensa_cpu_do_interrupt; cc->dump_state = xtensa_cpu_dump_state; cc->set_pc = xtensa_cpu_set_pc;target-xtensa/cpu.h +0
-0@@ -519,11 +519,4 @@ static inline void cpu_get_tb_cpu_state(CPUXtensaState *env, target_ulong *pc,#include "exec/cpu-all.h"
target-xtensa/cpu.h static inline void cpu_get_tb_cpu_state(CPUXtensaState *env, target_ulong *pc, · line 522
Quoted 10 lines
target-xtensa/cpu.h +0
-7#include "exec/exec-all.h" -static inline int cpu_has_work (CPUState *cpu) -{ -CPUXtensaState *env = &XTENSA_CPU (cpu)->env; - -return env->pending_irq_level; -} -#endif
target-openrisc: Tested-by: Jia Liu <[email protected]>
Quoted 3 lines
--
1.8.1.4
Re: [Qemu-devel] [RFC qom-cpu 01/41] cpu: Turn cpu_has_work() into a CPUClass hook
In reply to Andreas FärberAm 04.09.2013 11:04, schrieb Andreas Färber:
Quoted 5 lines
Default to false.
Tidy variable naming and inline cast uses while at it.
Signed-off-by Andreas Färber <[email protected]>
If I've re-read the IRC transcript correctly, Paolo objected to patch 03/41 and had doubts about 02/41. I have therefore applied this 01/41 to qom-cpu to crack down on functions new targets need to implement in cpu.h:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu
Regards,
Andreas
Quoted 38 lines
--- cpu-exec.c | 5 ----- cpus.c | 2 +- include/qom/cpu.h | 12 ++++++++++-- qom/cpu.c | 6 ++++++ target-alpha/cpu.c | 16 ++++++++++++++++ target-alpha/cpu.h | 15 --------------- target-arm/cpu.c | 7 +++++++ target-arm/cpu.h | 6 ------ target-cris/cpu.c | 6 ++++++ target-cris/cpu.h | 5 ----- target-i386/cpu.c | 15 +++++++++++++++ target-i386/cpu.h | 14 -------------- target-lm32/cpu.c | 6 ++++++ target-lm32/cpu.h | 5 ----- target-m68k/cpu.c | 6 ++++++ target-m68k/cpu.h | 5 ----- target-microblaze/cpu.c | 6 ++++++ target-microblaze/cpu.h | 5 ----- target-mips/cpu.c | 30 ++++++++++++++++++++++++++++++ target-mips/cpu.h | 28 ---------------------------- target-moxie/cpu.c | 6 ++++++ target-moxie/cpu.h | 5 ----- target-openrisc/cpu.c | 7 +++++++ target-openrisc/cpu.h | 5 ----- target-ppc/cpu.h | 8 -------- target-ppc/translate_init.c | 9 +++++++++ target-s390x/cpu.c | 10 ++++++++++ target-s390x/cpu.h | 9 --------- target-sh4/cpu.c | 6 ++++++ target-sh4/cpu.h | 5 ----- target-sparc/cpu.c | 10 ++++++++++ target-sparc/cpu.h | 9 --------- target-unicore32/cpu.c | 7 +++++++ target-unicore32/cpu.h | 6 ------ target-xtensa/cpu.c | 8 ++++++++ target-xtensa/cpu.h | 7 ------- 36 files changed, 172 insertions(+), 145 deletions(-)
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
RFC 2/41 cpu: Turn cpu_mmu_index() into a CPUClass hook
In reply to Andreas FärberDefault to 0.
--- cputlb.c | 7 +++---- include/exec/softmmu_header.h | 4 ++-- include/qom/cpu.h | 15 +++++++++++++++ qom/cpu.c | 6 ++++++ target-alpha/cpu.c | 14 ++++++++++++++ target-alpha/cpu.h | 11 ----------- target-alpha/translate.c | 2 +- target-arm/cpu.c | 8 ++++++++ target-arm/cpu.h | 4 ---- target-cris/cpu.c | 8 ++++++++ target-cris/cpu.h | 4 ---- target-cris/translate.c | 6 +++--- target-cris/translate_v10.c | 2 +- target-i386/cpu.c | 11 +++++++++++ target-i386/cpu.h | 6 ------ target-i386/translate.c | 2 +- target-lm32/cpu.h | 4 ---- target-m68k/cpu.c | 8 ++++++++ target-m68k/cpu.h | 4 ---- target-microblaze/cpu.c | 15 +++++++++++++++ target-microblaze/cpu.h | 11 ----------- target-microblaze/mmu.c | 3 ++- target-microblaze/translate.c | 14 +++++++------- target-mips/cpu.c | 8 ++++++++ target-mips/cpu.h | 4 ---- target-moxie/cpu.h | 5 ----- target-openrisc/cpu.c | 11 +++++++++++ target-openrisc/cpu.h | 8 -------- target-openrisc/translate.c | 2 +- target-ppc/cpu.h | 4 ---- target-ppc/translate_init.c | 8 ++++++++ target-s390x/cpu.c | 12 ++++++++++++ target-s390x/cpu.h | 9 --------- target-sh4/cpu.c | 8 ++++++++ target-sh4/cpu.h | 4 ---- target-sparc/cpu.c | 25 +++++++++++++++++++++++++ target-sparc/cpu.h | 19 ------------------- target-sparc/mmu_helper.c | 2 +- target-sparc/translate.c | 2 +- target-unicore32/cpu.c | 8 ++++++++ target-unicore32/cpu.h | 4 ---- target-xtensa/cpu.c | 8 ++++++++ target-xtensa/cpu.h | 5 ----- 43 files changed, 196 insertions(+), 129 deletions(-)
cputlb.c +3 -4
@@ -316,12 +316,14 @@ void tlb_set_page(CPUArchState *env, target_ulong vaddr,*/ tb_page_addr_t get_page_addr_code (CPUArchState *env1,target_ulong addr) { +CPUState *cpu =ENV_GET_CPU (env1); +CPUClass *cc =CPU_GET_CLASS (cpu);int mmu_idx, page_index, pd;void *p;MemoryRegion *mr; page_index = (addr >>TARGET_PAGE_BITS ) & (CPU_TLB_SIZE -1 ); - mmu_idx =cpu_mmu_index (env1); + mmu_idx = cc->mmu_index (cpu);if (unlikely (env1->tlb_table[mmu_idx][page_index].addr_code != (addr &TARGET_PAGE_MASK ))) {cpu_ldub_code (env1, addr);
@@ -329,9 +331,6 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr) pd = env1->iotlb[mmu_idx][page_index] & ~TARGET_PAGE_MASK ; mr =iotlb_to_region (pd);if (memory_region_is_unassigned (mr)) { -CPUState *cpu =ENV_GET_CPU (env1); -CPUClass *cc =CPU_GET_CLASS (cpu); -if (cc->do_unassigned_access) { cc->do_unassigned_access (cpu, addr, false, true,0 ,4 ); }else {
include/exec/softmmu_header.h +2 -2
@@ -54,12 +54,12 @@#elif ACCESS_TYPE == (NB_MMU_MODES ) -#define CPU_MMU_INDEX (cpu_mmu_index(env)) +#define CPU_MMU_INDEX (cpu_mmu_index(ENV_GET_CPU(env)))#define MMUSUFFIX _mmu#elif ACCESS_TYPE == (NB_MMU_MODES +1 ) -#define CPU_MMU_INDEX (cpu_mmu_index(env)) +#define CPU_MMU_INDEX (cpu_mmu_index(ENV_GET_CPU(env)))#define MMUSUFFIX _cmmu#else
include/qom/cpu.h +15 -0
@@ -76,6 +76,7 @@ struct TranslationBlock;* @dump_state: Callback for dumping state. * @dump_statistics: Callback for dumping statistics. * @get_arch_id: Callback for getting architecture-dependent CPU ID. +* @mmu_index: Callback for obtaining MMU index. * @get_paging_enabled: Callback for inquiring whether paging is enabled. * @get_memory_mapping: Callback for obtaining the memory mappings. * @set_pc: Callback for setting the Program Counter register.
@@ -109,6 +110,7 @@ typedef struct CPUClass {void (*dump_statistics)(CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags);int64_t (*get_arch_id)(CPUState *cpu); +int (*mmu_index)(const CPUState *cpu);bool (*get_paging_enabled)(const CPUState *cpu);void (*get_memory_mapping)(CPUState *cpu,MemoryMappingList *list,Error **errp);
@@ -217,6 +219,19 @@ DECLARE_TLS(CPUState *, current_cpu);#define current_cpu tls_var(current_cpu)/** +* cpu_mmu_index: +* @cpu: The CPU whose MMU index is to be obtained. +* +* Returns: MMU index for @cpu. +*/ +static inline int cpu_mmu_index (CPUState *cpu) +{ +CPUClass *cc =CPU_GET_CLASS (cpu); + +return cc->mmu_index (cpu); +} + +/** * cpu_paging_enabled: * @cpu: The CPU whose state is to be inspected. *
qom/cpu.c +6 -0
@@ -200,6 +200,11 @@ static void cpu_common_reset(CPUState *cpu) cpu->halted =0 ; } +static int cpu_common_mmu_index (const CPUState *cs) +{ +return 0 ; +} +static bool cpu_common_has_work (CPUState *cs) {return false;
@@ -249,6 +254,7 @@ static void cpu_class_init(ObjectClass *klass, void *data) k->class_by_name = cpu_common_class_by_name; k->reset = cpu_common_reset; k->get_arch_id = cpu_common_get_arch_id; + k->mmu_index = cpu_common_mmu_index; k->has_work = cpu_common_has_work; k->get_paging_enabled = cpu_common_get_paging_enabled; k->get_memory_mapping = cpu_common_get_memory_mapping;
target-alpha/cpu.c +14 -0
@@ -31,6 +31,19 @@ static void alpha_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static int alpha_cpu_mmu_index (const CPUState *cs) +{ +AlphaCPU *cpu =ALPHA_CPU (cs); + +if (cpu->env.pal_mode) { +return MMU_KERNEL_IDX ; + }else if (cpu->env.ps &PS_USER_MODE ) { +return MMU_USER_IDX ; + }else { +return MMU_KERNEL_IDX ; + } +} +static bool alpha_cpu_has_work (CPUState *cs) {/* Here we are checking to see if the CPU should wake up from HALT.
@@ -289,6 +302,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) cc->has_work = alpha_cpu_has_work; cc->do_interrupt = alpha_cpu_do_interrupt; cc->dump_state = alpha_cpu_dump_state; + cc->mmu_index = alpha_cpu_mmu_index; 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;
target-alpha/cpu.h +0 -11
@@ -378,17 +378,6 @@ enum {PS_USER_MODE =8 }; -static inline int cpu_mmu_index (CPUAlphaState *env) -{ -if (env->pal_mode) { -return MMU_KERNEL_IDX ; - }else if (env->ps &PS_USER_MODE ) { -return MMU_USER_IDX ; - }else { -return MMU_KERNEL_IDX ; - } -} -enum {IR_V0 =0 ,IR_T0 =1 ,
target-alpha/translate.c +1 -1
@@ -3458,7 +3458,7 @@ static inline void gen_intermediate_code_internal(AlphaCPU *cpu, ctx.tb = tb; ctx.pc = pc_start; - ctx.mem_idx =cpu_mmu_index (env); + ctx.mem_idx =cpu_mmu_index (cs); ctx.implver = env->implver; ctx.singlestep_enabled = cs->singlestep_enabled;
target-arm/cpu.c +8 -0
@@ -34,6 +34,13 @@ static void arm_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.regs[15 ] = value; } +static int arm_cpu_mmu_index (const CPUState *cs) +{ +ARMCPU *cpu =ARM_CPU (cs); + +return (cpu->env.uncached_cpsr &CPSR_M ) ==ARM_CPU_MODE_USR ?1 :0 ; +} +static bool arm_cpu_has_work (CPUState *cs) { return cs->interrupt_request &
@@ -899,6 +906,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->has_work = arm_cpu_has_work; cc->do_interrupt = arm_cpu_do_interrupt; cc->dump_state = arm_cpu_dump_state; + cc->mmu_index = arm_cpu_mmu_index; cc->set_pc = arm_cpu_set_pc; cc->gdb_read_register = arm_cpu_gdb_read_register; cc->gdb_write_register = arm_cpu_gdb_write_register;
target-arm/cpu.h +0 -4
@@ -750,10 +750,6 @@ static inline CPUARMState *cpu_init(const char *cpu_model)#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 -static inline int cpu_mmu_index (CPUARMState *env) -{ -return (env->uncached_cpsr &CPSR_M ) ==ARM_CPU_MODE_USR ?1 :0 ; -}#include "exec/cpu-all.h"
target-cris/cpu.c +8 -0
@@ -33,6 +33,13 @@ static void cris_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static int cris_cpu_mmu_index (const CPUState *cs) +{ +CRISCPU *cpu =CRIS_CPU (cs); + +return (cpu->env.pregs[PR_CCS ] &U_FLAG ) ?1 :0 ; +} +static bool cris_cpu_has_work (CPUState *cs) {return cs->interrupt_request & (CPU_INTERRUPT_HARD |CPU_INTERRUPT_NMI );
@@ -265,6 +272,7 @@ static void cris_cpu_class_init(ObjectClass *oc, void *data) cc->has_work = cris_cpu_has_work; cc->do_interrupt = cris_cpu_do_interrupt; cc->dump_state = cris_cpu_dump_state; + cc->mmu_index = cris_cpu_mmu_index; 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;
target-cris/cpu.h +0 -4
@@ -238,10 +238,6 @@ static inline CPUCRISState *cpu_init(const char *cpu_model)#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 -static inline int cpu_mmu_index (CPUCRISState *env) -{ -return !!(env->pregs[PR_CCS ] &U_FLAG ); -}int cpu_cris_handle_mmu_fault (CPUCRISState *env,target_ulong address,int rw,int mmu_idx);
target-cris/translate.c +3 -3
@@ -1125,7 +1125,7 @@ static inline void cris_prepare_jmp (DisasContext *dc, unsigned int type)static void gen_load64 (DisasContext *dc,TCGv_i64 dst,TCGv addr) { -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index (CPU (cris_env_get_cpu (dc->env)));/* If we get a fault on a delayslot we must keep the jmp state in the cpu-state to be able to re-execute the jmp. */
@@ -1139,7 +1139,7 @@ static void gen_load64(DisasContext *dc, TCGv_i64 dst, TCGv addr)static void gen_load (DisasContext *dc,TCGv dst,TCGv addr,unsigned int size,int sign) { -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index (CPU (cris_env_get_cpu (dc->env)));/* If we get a fault on a delayslot we must keep the jmp state in the cpu-state to be able to re-execute the jmp. */
@@ -1169,7 +1169,7 @@ static void gen_load(DisasContext *dc, TCGv dst, TCGv addr,static void gen_store (DisasContext *dc,TCGv addr,TCGv val,unsigned int size) { -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index (CPU (cris_env_get_cpu (dc->env)));/* If we get a fault on a delayslot we must keep the jmp state in the cpu-state to be able to re-execute the jmp. */
target-cris/translate_v10.c +1 -1
@@ -96,7 +96,7 @@ static void gen_store_v10_conditional(DisasContext *dc, TCGv addr, TCGv val,static void gen_store_v10 (DisasContext *dc,TCGv addr,TCGv val,unsigned int size) { -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index (CPU (cris_env_get_cpu (dc->env)));/* If we get a fault on a delayslot we must keep the jmp state in the cpu-state to be able to re-execute the jmp. */
target-i386/cpu.c +11 -0
@@ -2676,6 +2676,16 @@ static void x86_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) cpu->env.eip = tb->pc - tb->cs_base; } +static int x86_cpu_mmu_index (const CPUState *cs) +{ +X86CPU *cpu =X86_CPU (cs); +CPUX86State *env = &cpu->env; + +return (env->hflags &HF_CPL_MASK ) ==3 ?MMU_USER_IDX : + ((env->hflags &HF_SMAP_MASK ) && (env->eflags &AC_MASK )) + ?MMU_KSMAP_IDX :MMU_KERNEL_IDX ; +} +static bool x86_cpu_has_work (CPUState *cs) {X86CPU *cpu =X86_CPU (cs);
@@ -2713,6 +2723,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->has_work = x86_cpu_has_work; cc->do_interrupt = x86_cpu_do_interrupt; cc->dump_state = x86_cpu_dump_state; + cc->mmu_index = x86_cpu_mmu_index; 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;
target-i386/cpu.h +0 -6
@@ -1123,12 +1123,6 @@ static inline CPUX86State *cpu_init(const char *cpu_model)#define MMU_KERNEL_IDX 0#define MMU_USER_IDX 1#define MMU_KSMAP_IDX 2 -static inline int cpu_mmu_index (CPUX86State *env) -{ -return (env->hflags &HF_CPL_MASK ) ==3 ?MMU_USER_IDX : - ((env->hflags &HF_SMAP_MASK ) && (env->eflags &AC_MASK )) - ?MMU_KSMAP_IDX :MMU_KERNEL_IDX ; -}#define CC_DST (env->cc_dst)#define CC_SRC (env->cc_src)
target-i386/translate.c +1 -1
@@ -8291,7 +8291,7 @@ static inline void gen_intermediate_code_internal(X86CPU *cpu,/* select memory access functions */ dc->mem_index =0 ;if (flags &HF_SOFTMMU_MASK ) { - dc->mem_index = (cpu_mmu_index (env) +1 ) <<2 ; + dc->mem_index = (cpu_mmu_index (cs) +1 ) <<2 ; } dc->cpuid_features = env->features[FEAT_1_EDX ]; dc->cpuid_ext_features = env->features[FEAT_1_ECX ];
target-lm32/cpu.h +0 -4
@@ -36,10 +36,6 @@ typedef struct CPULM32State CPULM32State;#define NB_MMU_MODES 1#define TARGET_PAGE_BITS 12 -static inline int cpu_mmu_index (CPULM32State *env) -{ -return 0 ; -}#define TARGET_PHYS_ADDR_SPACE_BITS 32#define TARGET_VIRT_ADDR_SPACE_BITS 32
target-m68k/cpu.c +8 -0
@@ -30,6 +30,13 @@ static void m68k_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static int m68k_cpu_mmu_index (const CPUState *cs) +{ +M68kCPU *cpu =M68K_CPU (cs); + +return (cpu->env.sr &SR_S ) ==0 ?MMU_USER_IDX :0 ; +} +static bool m68k_cpu_has_work (CPUState *cs) {return cs->interrupt_request &CPU_INTERRUPT_HARD ;
@@ -197,6 +204,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) cc->has_work = m68k_cpu_has_work; cc->do_interrupt = m68k_cpu_do_interrupt; cc->dump_state = m68k_cpu_dump_state; + cc->mmu_index = m68k_cpu_mmu_index; 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;
target-m68k/cpu.h +0 -4
@@ -232,10 +232,6 @@ static inline CPUM68KState *cpu_init(const char *cpu_model)#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 -static inline int cpu_mmu_index (CPUM68KState *env) -{ -return (env->sr &SR_S ) ==0 ?1 :0 ; -}int cpu_m68k_handle_mmu_fault (CPUM68KState *env,target_ulong address,int rw,int mmu_idx);
target-microblaze/cpu.c +15 -0
@@ -33,6 +33,20 @@ static void mb_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.sregs[SR_PC ] = value; } +static int mb_cpu_mmu_index (const CPUState *cs) +{ +MicroBlazeCPU *cpu =MICROBLAZE_CPU (cs); + +/* Are we in nommu mode?. */ +if (!(cpu->env.sregs[SR_MSR ] &MSR_VM )) { +return MMU_NOMMU_IDX ; + } +if (cpu->env.sregs[SR_MSR ] &MSR_UM ) { +return MMU_USER_IDX ; + } +return MMU_KERNEL_IDX ; +} +static bool mb_cpu_has_work (CPUState *cs) {return cs->interrupt_request & (CPU_INTERRUPT_HARD |CPU_INTERRUPT_NMI );
@@ -147,6 +161,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->dump_state = mb_cpu_dump_state; + cc->mmu_index = mb_cpu_mmu_index; cc->set_pc = mb_cpu_set_pc; cc->gdb_read_register = mb_cpu_gdb_read_register; cc->gdb_write_register = mb_cpu_gdb_write_register;
target-microblaze/cpu.h +0 -11
@@ -316,17 +316,6 @@ static inline CPUMBState *cpu_init(const char *cpu_model)#define MMU_USER_IDX 2/* See NB_MMU_MODES further up the file. */ -static inline int cpu_mmu_index (CPUMBState *env) -{ -/* Are we in nommu mode?. */ -if (!(env->sregs[SR_MSR ] &MSR_VM )) -return MMU_NOMMU_IDX ; - -if (env->sregs[SR_MSR ] &MSR_UM ) -return MMU_USER_IDX ; -return MMU_KERNEL_IDX ; -} -int cpu_mb_handle_mmu_fault (CPUMBState *env,target_ulong address,int rw,int mmu_idx);#define cpu_handle_mmu_fault cpu_mb_handle_mmu_fault
target-microblaze/mmu.c +2 -1
@@ -218,6 +218,7 @@ uint32_t mmu_read(CPUMBState *env, uint32_t rn)void mmu_write (CPUMBState *env,uint32_t rn,uint32_t v) { +MicroBlazeCPU *cpu =mb_env_get_cpu (env);unsigned int i;D (qemu_log ("%s rn=%d=%x old=%x\n" , __func__, rn, v, env->mmu.regs[rn]));
@@ -277,7 +278,7 @@ void mmu_write(CPUMBState *env, uint32_t rn, uint32_t v) } hit =mmu_translate (&env->mmu, &lu, - v &TLB_EPN_MASK ,0 ,cpu_mmu_index (env)); + v &TLB_EPN_MASK ,0 ,cpu_mmu_index (CPU (cpu)));if (hit) { env->mmu.regs[MMU_R_TLBX ] = lu.idx; }else
target-microblaze/translate.c +7 -7
@@ -440,7 +440,7 @@ static void dec_msr(DisasContext *dc) {TCGv t0, t1;unsigned int sr, to, rn; -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index (CPU (mb_env_get_cpu (dc->env))); sr = dc->imm & ((1 <<14 ) -1 ); to = dc->imm & (1 <<14 );
@@ -751,7 +751,7 @@ static void dec_bit(DisasContext *dc) {TCGv t0, t1;unsigned int op; -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index (CPU (mb_env_get_cpu (dc->env))); op = dc->ir & ((1 <<9 ) -1 );switch (op) {
@@ -874,7 +874,7 @@ static void dec_imm(DisasContext *dc)static inline void gen_load (DisasContext *dc,TCGv dst,TCGv addr,unsigned int size) { -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index (CPU (mb_env_get_cpu (dc->env)));if (size ==1 ) {tcg_gen_qemu_ld8u (dst, addr, mem_index);
@@ -1093,7 +1093,7 @@ static void dec_load(DisasContext *dc)static void gen_store (DisasContext *dc,TCGv addr,TCGv val,unsigned int size) { -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index (CPU (mb_env_get_cpu (dc->env)));if (size ==1 )tcg_gen_qemu_st8 (val, addr, mem_index);
@@ -1308,7 +1308,7 @@ static void dec_bcc(DisasContext *dc)static void dec_br (DisasContext *dc) {unsigned int dslot, link, abs, mbar; -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index (CPU (mb_env_get_cpu (dc->env))); dslot = dc->ir & (1 <<20 ); abs = dc->ir & (1 <<19 );
@@ -1440,7 +1440,7 @@ static inline void do_rte(DisasContext *dc)static void dec_rts (DisasContext *dc) {unsigned int b_bit, i_bit, e_bit; -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index (CPU (mb_env_get_cpu (dc->env))); i_bit = dc->ir & (1 <<21 ); b_bit = dc->ir & (1 <<22 );
@@ -1616,7 +1616,7 @@ static void dec_null(DisasContext *dc)/* Insns connected to FSL or AXI stream attached devices. */ static void dec_stream (DisasContext *dc) { -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index (CPU (mb_env_get_cpu (dc->env)));TCGv_i32 t_id, t_ctrl;int ctrl;
target-mips/cpu.c +8 -0
@@ -45,6 +45,13 @@ static void mips_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) env->hflags |= tb->flags &MIPS_HFLAG_BMASK ; } +static int mips_cpu_mmu_index (const CPUState *cs) +{ +MIPSCPU *cpu =MIPS_CPU (cs); + +return cpu->env.hflags &MIPS_HFLAG_KSU ; +} +static bool mips_cpu_has_work (CPUState *cs) {MIPSCPU *cpu =MIPS_CPU (cs);
@@ -129,6 +136,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->has_work = mips_cpu_has_work; cc->do_interrupt = mips_cpu_do_interrupt; cc->dump_state = mips_cpu_dump_state; + cc->mmu_index = mips_cpu_mmu_index; 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;
target-mips/cpu.h +0 -4
@@ -516,10 +516,6 @@ extern uint32_t cpu_rddsp(uint32_t mask_num, CPUMIPSState *env);#define MMU_MODE1_SUFFIX _super#define MMU_MODE2_SUFFIX _user#define MMU_USER_IDX 2 -static inline int cpu_mmu_index (CPUMIPSState *env) -{ -return env->hflags &MIPS_HFLAG_KSU ; -}static inline int cpu_mips_hw_interrupts_pending (CPUMIPSState *env) {
target-moxie/cpu.h +0 -5
@@ -136,11 +136,6 @@ static inline CPUMoxieState *cpu_init(const char *cpu_model)#define cpu_gen_code cpu_moxie_gen_code#define cpu_signal_handler cpu_moxie_signal_handler -static inline int cpu_mmu_index (CPUMoxieState *env) -{ -return 0 ; -} -#include "exec/cpu-all.h" #include "exec/exec-all.h"
target-openrisc/cpu.c +11 -0
@@ -27,6 +27,16 @@ static void openrisc_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static int openrisc_cpu_mmu_index (const CPUState *cs) +{ +OpenRISCCPU *cpu =OPENRISC_CPU (cs); + +if (!(cpu->env.sr &SR_IME )) { +return MMU_NOMMU_IDX ; + } +return (cpu->env.sr &SR_SM ) ==0 ?MMU_USER_IDX :MMU_SUPERVISOR_IDX ; +} +static bool openrisc_cpu_has_work (CPUState *cs) { return cs->interrupt_request & (CPU_INTERRUPT_HARD |
@@ -162,6 +172,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data) cc->has_work = openrisc_cpu_has_work; cc->do_interrupt = openrisc_cpu_do_interrupt; cc->dump_state = openrisc_cpu_dump_state; + cc->mmu_index = openrisc_cpu_mmu_index; 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;
target-openrisc/cpu.h +0 -8
@@ -409,14 +409,6 @@ static inline void cpu_get_tb_cpu_state(CPUOpenRISCState *env, *flags = (env->flags &D_FLAG ); } -static inline int cpu_mmu_index (CPUOpenRISCState *env) -{ -if (!(env->sr &SR_IME )) { -return MMU_NOMMU_IDX ; - } -return (env->sr &SR_SM ) ==0 ?MMU_USER_IDX :MMU_SUPERVISOR_IDX ; -} -#define CPU_INTERRUPT_TIMER CPU_INTERRUPT_TGT_INT_0#include "exec/exec-all.h"
target-openrisc/translate.c +1 -1
@@ -1679,7 +1679,7 @@ static inline void gen_intermediate_code_internal(OpenRISCCPU *cpu, dc->ppc = pc_start; dc->pc = pc_start; dc->flags = cpu->env.cpucfgr; - dc->mem_idx =cpu_mmu_index (&cpu->env); + dc->mem_idx =cpu_mmu_index (cs); dc->synced_flags = dc->tb_flags = tb->flags; dc->delayed_branch = !!(dc->tb_flags &D_FLAG ); dc->singlestep_enabled = cs->singlestep_enabled;
target-ppc/cpu.h +0 -4
@@ -1183,10 +1183,6 @@ static inline CPUPPCState *cpu_init(const char *cpu_model)#define MMU_MODE1_SUFFIX _kernel#define MMU_MODE2_SUFFIX _hypv#define MMU_USER_IDX 0 -static inline int cpu_mmu_index (CPUPPCState *env) -{ -return env->mmu_idx; -}#include "exec/cpu-all.h"
target-ppc/translate_init.c +8 -0
@@ -8437,6 +8437,13 @@ static void ppc_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.nip = value; } +static int ppc_cpu_mmu_index (const CPUState *cs) +{ +PowerPCCPU *cpu =POWERPC_CPU (cs); + +return cpu->env.mmu_idx; +} +static bool ppc_cpu_has_work (CPUState *cs) {PowerPCCPU *cpu =POWERPC_CPU (cs);
@@ -8573,6 +8580,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = ppc_cpu_do_interrupt; cc->dump_state = ppc_cpu_dump_state; cc->dump_statistics = ppc_cpu_dump_statistics; + cc->mmu_index = ppc_cpu_mmu_index; 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;
target-s390x/cpu.c +12 -0
@@ -65,6 +65,17 @@ static void s390_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.psw.addr = value; } +static int s390_cpu_mmu_index (const CPUState *cs) +{ +S390CPU *cpu =S390_CPU (cs); + +if (cpu->env.psw.mask &PSW_MASK_PSTATE ) { +return 1 ; + } + +return 0 ; +} +static bool s390_cpu_has_work (CPUState *cs) {S390CPU *cpu =S390_CPU (cs);
@@ -229,6 +240,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->has_work = s390_cpu_has_work; cc->do_interrupt = s390_cpu_do_interrupt; cc->dump_state = s390_cpu_dump_state; + cc->mmu_index = s390_cpu_mmu_index; cc->set_pc = s390_cpu_set_pc; cc->gdb_read_register = s390_cpu_gdb_read_register; cc->gdb_write_register = s390_cpu_gdb_write_register;
target-s390x/cpu.h +0 -9
@@ -273,15 +273,6 @@ typedef struct CPUS390XState {#define FLAG_MASK_64 (PSW_MASK_64 >> 32)#define FLAG_MASK_32 0x00001000 -static inline int cpu_mmu_index (CPUS390XState *env) -{ -if (env->psw.mask &PSW_MASK_PSTATE ) { -return 1 ; - } - -return 0 ; -} -static inline void cpu_get_tb_cpu_state (CPUS390XState * env,target_ulong *pc,target_ulong *cs_base,int *flags) {
target-sh4/cpu.c +8 -0
@@ -39,6 +39,13 @@ static void superh_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) cpu->env.flags = tb->flags; } +static int superh_cpu_mmu_index (const CPUState *cs) +{ +SuperHCPU *cpu =SUPERH_CPU (cs); + +return (cpu->env.sr &SR_MD ) ==0 ?1 :0 ; +} +static bool superh_cpu_has_work (CPUState *cs) {return cs->interrupt_request &CPU_INTERRUPT_HARD ;
@@ -291,6 +298,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) cc->has_work = superh_cpu_has_work; cc->do_interrupt = superh_cpu_do_interrupt; cc->dump_state = superh_cpu_dump_state; + cc->mmu_index = superh_cpu_mmu_index; cc->set_pc = superh_cpu_set_pc; cc->synchronize_from_tb = superh_cpu_synchronize_from_tb; cc->gdb_read_register = superh_cpu_gdb_read_register;
target-sh4/cpu.h +0 -4
@@ -240,10 +240,6 @@ static inline CPUSH4State *cpu_init(const char *cpu_model)#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 -static inline int cpu_mmu_index (CPUSH4State *env) -{ -return (env->sr &SR_MD ) ==0 ?1 :0 ; -}#include "exec/cpu-all.h"
target-sparc/cpu.c +25 -0
@@ -739,6 +739,30 @@ static void sparc_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) cpu->env.npc = tb->cs_base; } +static int sparc_cpu_mmu_index (const CPUState *cs) +{ +#if defined(CONFIG_USER_ONLY ) +return MMU_USER_IDX ; +#else +SPARCCPU *cpu =SPARC_CPU (cs); +CPUSPARCState *env = &cpu->env; + +#if !defined(TARGET_SPARC64 ) +return env->psrs; +#else +if (env->tl >0 ) { +return MMU_NUCLEUS_IDX ; + }else if (cpu_hypervisor_mode (env)) { +return MMU_HYPV_IDX ; + }else if (cpu_supervisor_mode (env)) { +return MMU_KERNEL_IDX ; + }else { +return MMU_USER_IDX ; + } +#endif +#endif +} +static bool sparc_cpu_has_work (CPUState *cs) {SPARCCPU *cpu =SPARC_CPU (cs);
@@ -797,6 +821,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data)#if !defined(TARGET_SPARC64 ) && !defined(CONFIG_USER_ONLY ) cc->memory_rw_debug = sparc_cpu_memory_rw_debug;#endif + cc->mmu_index = sparc_cpu_mmu_index; cc->set_pc = sparc_cpu_set_pc; cc->synchronize_from_tb = sparc_cpu_synchronize_from_tb; cc->gdb_read_register = sparc_cpu_gdb_read_register;
target-sparc/cpu.h +0 -19
@@ -647,25 +647,6 @@ static inline int cpu_supervisor_mode(CPUSPARCState *env1) }#endif -static inline int cpu_mmu_index (CPUSPARCState *env1) -{ -#if defined(CONFIG_USER_ONLY ) -return MMU_USER_IDX ; -#elif !defined(TARGET_SPARC64 ) -return env1->psrs; -#else -if (env1->tl >0 ) { -return MMU_NUCLEUS_IDX ; - }else if (cpu_hypervisor_mode (env1)) { -return MMU_HYPV_IDX ; - }else if (cpu_supervisor_mode (env1)) { -return MMU_KERNEL_IDX ; - }else { -return MMU_USER_IDX ; - } -#endif -} -static inline int cpu_interrupts_enabled (CPUSPARCState *env1) {#if !defined (TARGET_SPARC64 )
target-sparc/mmu_helper.c +1 -1
@@ -842,7 +842,7 @@ hwaddr sparc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)SPARCCPU *cpu =SPARC_CPU (cs);CPUSPARCState *env = &cpu->env;hwaddr phys_addr; -int mmu_idx =cpu_mmu_index (env); +int mmu_idx =cpu_mmu_index (cs);MemoryRegionSection section;if (cpu_sparc_get_phys_page (env, &phys_addr, addr,2 , mmu_idx) !=0 ) {
target-sparc/translate.c +1 -1
@@ -5241,7 +5241,7 @@ static inline void gen_intermediate_code_internal(SPARCCPU *cpu, last_pc = dc->pc; dc->npc = (target_ulong ) tb->cs_base; dc->cc_op =CC_OP_DYNAMIC ; - dc->mem_idx =cpu_mmu_index (env); + dc->mem_idx =cpu_mmu_index (cs); dc->def = env->def; dc->fpu_enabled =tb_fpu_enabled (tb->flags); dc->address_mask_32bit =tb_am_enabled (tb->flags);
target-unicore32/cpu.c +8 -0
@@ -23,6 +23,13 @@ static void uc32_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.regs[31 ] = value; } +static int uc32_cpu_mmu_index (const CPUState *cs) +{ +UniCore32CPU *cpu =UNICORE32_CPU (cs); + +return (cpu->env.uncached_asr &ASR_M ) ==ASR_MODE_USER ?MMU_USER_IDX :0 ; +} +static bool uc32_cpu_has_work (CPUState *cs) { return cs->interrupt_request &
@@ -147,6 +154,7 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data) cc->has_work = uc32_cpu_has_work; cc->do_interrupt = uc32_cpu_do_interrupt; cc->dump_state = uc32_cpu_dump_state; + cc->mmu_index = uc32_cpu_mmu_index; cc->set_pc = uc32_cpu_set_pc;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = uc32_cpu_get_phys_page_debug;
target-unicore32/cpu.h +0 -4
@@ -137,10 +137,6 @@ int uc32_cpu_handle_mmu_fault(CPUUniCore32State *env, target_ulong address, int#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 -static inline int cpu_mmu_index (CPUUniCore32State *env) -{ -return (env->uncached_asr &ASR_M ) ==ASR_MODE_USER ?1 :0 ; -}#include "exec/cpu-all.h" #include "cpu-qom.h"
target-xtensa/cpu.c +8 -0
@@ -40,6 +40,13 @@ static void xtensa_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static int xtensa_cpu_mmu_index (const CPUState *cs) +{ +XtensaCPU *cpu =XTENSA_CPU (cs); + +return xtensa_get_cring (&cpu->env); +} +static bool xtensa_cpu_has_work (CPUState *cs) {XtensaCPU *cpu =XTENSA_CPU (cs);
@@ -142,6 +149,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data) cc->has_work = xtensa_cpu_has_work; cc->do_interrupt = xtensa_cpu_do_interrupt; cc->dump_state = xtensa_cpu_dump_state; + cc->mmu_index = xtensa_cpu_mmu_index; cc->set_pc = xtensa_cpu_set_pc; cc->gdb_read_register = xtensa_cpu_gdb_read_register; cc->gdb_write_register = xtensa_cpu_gdb_write_register;
target-xtensa/cpu.h +0 -5
@@ -472,11 +472,6 @@ static inline xtensa_tlb_entry *xtensa_tlb_get_entry(CPUXtensaState *env,#define MMU_MODE2_SUFFIX _ring2#define MMU_MODE3_SUFFIX _ring3 -static inline int cpu_mmu_index (CPUXtensaState *env) -{ -return xtensa_get_cring (env); -} -#define XTENSA_TBFLAG_RING_MASK 0x3#define XTENSA_TBFLAG_EXCM 0x4#define XTENSA_TBFLAG_LITBASE 0x8
Signature · 1 line
1.8.1.4
Re: [Qemu-devel] [RFC qom-cpu 02/41] cpu: Turn cpu_mmu_index() into a CPUClass hook
Quoted 1,035 lines · Andreas Färber
Default to 0.
Signed-off-by Andreas Färber <[email protected]>--- cputlb.c | 7 +++---- include/exec/softmmu_header.h | 4 ++-- include/qom/cpu.h | 15 +++++++++++++++ qom/cpu.c | 6 ++++++ target-alpha/cpu.c | 14 ++++++++++++++ target-alpha/cpu.h | 11 ----------- target-alpha/translate.c | 2 +- target-arm/cpu.c | 8 ++++++++ target-arm/cpu.h | 4 ---- target-cris/cpu.c | 8 ++++++++ target-cris/cpu.h | 4 ---- target-cris/translate.c | 6 +++--- target-cris/translate_v10.c | 2 +- target-i386/cpu.c | 11 +++++++++++ target-i386/cpu.h | 6 ------ target-i386/translate.c | 2 +- target-lm32/cpu.h | 4 ---- target-m68k/cpu.c | 8 ++++++++ target-m68k/cpu.h | 4 ---- target-microblaze/cpu.c | 15 +++++++++++++++ target-microblaze/cpu.h | 11 ----------- target-microblaze/mmu.c | 3 ++- target-microblaze/translate.c | 14 +++++++------- target-mips/cpu.c | 8 ++++++++ target-mips/cpu.h | 4 ---- target-moxie/cpu.h | 5 ----- target-openrisc/cpu.c | 11 +++++++++++ target-openrisc/cpu.h | 8 -------- target-openrisc/translate.c | 2 +- target-ppc/cpu.h | 4 ---- target-ppc/translate_init.c | 8 ++++++++ target-s390x/cpu.c | 12 ++++++++++++ target-s390x/cpu.h | 9 --------- target-sh4/cpu.c | 8 ++++++++ target-sh4/cpu.h | 4 ---- target-sparc/cpu.c | 25 +++++++++++++++++++++++++ target-sparc/cpu.h | 19 ------------------- target-sparc/mmu_helper.c | 2 +- target-sparc/translate.c | 2 +- target-unicore32/cpu.c | 8 ++++++++ target-unicore32/cpu.h | 4 ---- target-xtensa/cpu.c | 8 ++++++++ target-xtensa/cpu.h | 5 ----- 43 files changed, 196 insertions(+), 129 deletions(-)cputlb.c +3
-4@@ -316,12 +316,14 @@ void tlb_set_page(CPUArchState *env, target_ulong vaddr,*/ tb_page_addr_t get_page_addr_code (CPUArchState *env1,target_ulong addr) { +CPUState *cpu =ENV_GET_CPU (env1); +CPUClass *cc =CPU_GET_CLASS (cpu);int mmu_idx, page_index, pd;void *p;MemoryRegion *mr; page_index = (addr >>TARGET_PAGE_BITS ) & (CPU_TLB_SIZE -1 ); - mmu_idx =cpu_mmu_index (env1); + mmu_idx = cc->mmu_index (cpu);if (unlikely (env1->tlb_table[mmu_idx][page_index].addr_code != (addr &TARGET_PAGE_MASK ))) {cpu_ldub_code (env1, addr);@@ -329,9 +331,6 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr) pd = env1->iotlb[mmu_idx][page_index] & ~TARGET_PAGE_MASK ; mr =iotlb_to_region (pd);if (memory_region_is_unassigned (mr)) { -CPUState *cpu =ENV_GET_CPU (env1); -CPUClass *cc =CPU_GET_CLASS (cpu); -if (cc->do_unassigned_access) { cc->do_unassigned_access (cpu, addr, false, true,0 ,4 ); }else {include/exec/softmmu_header.h +2
-2@@ -54,12 +54,12 @@#elif ACCESS_TYPE == (NB_MMU_MODES ) -#define CPU_MMU_INDEX (cpu_mmu_index(env)) +#define CPU_MMU_INDEX (cpu_mmu_index(ENV_GET_CPU(env)))#define MMUSUFFIX _mmu#elif ACCESS_TYPE == (NB_MMU_MODES +1 ) -#define CPU_MMU_INDEX (cpu_mmu_index(env)) +#define CPU_MMU_INDEX (cpu_mmu_index(ENV_GET_CPU(env)))#define MMUSUFFIX _cmmu#else include/qom/cpu.h +15
-0@@ -76,6 +76,7 @@ struct TranslationBlock;* @dump_state: Callback for dumping state. * @dump_statistics: Callback for dumping statistics. * @get_arch_id: Callback for getting architecture-dependent CPU ID. +* @mmu_index: Callback for obtaining MMU index. * @get_paging_enabled: Callback for inquiring whether paging is enabled. * @get_memory_mapping: Callback for obtaining the memory mappings. * @set_pc: Callback for setting the Program Counter register. @@ -109,6 +110,7 @@ typedef struct CPUClass {void (*dump_statistics)(CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags);int64_t (*get_arch_id)(CPUState *cpu); +int (*mmu_index)(const CPUState *cpu);bool (*get_paging_enabled)(const CPUState *cpu);void (*get_memory_mapping)(CPUState *cpu,MemoryMappingList *list,Error **errp);@@ -217,6 +219,19 @@ DECLARE_TLS(CPUState *, current_cpu);#define current_cpu tls_var(current_cpu)/** +* cpu_mmu_index: +* @cpu: The CPU whose MMU index is to be obtained. +* +* Returns: MMU index for @cpu. +*/ +static inline int cpu_mmu_index (CPUState *cpu) +{ +CPUClass *cc =CPU_GET_CLASS (cpu); + +return cc->mmu_index (cpu); +} + +/** * cpu_paging_enabled: * @cpu: The CPU whose state is to be inspected. * qom/cpu.c +6
-0@@ -200,6 +200,11 @@ static void cpu_common_reset(CPUState *cpu) cpu->halted =0 ; } +static int cpu_common_mmu_index (const CPUState *cs) +{ +return 0 ; +} +static bool cpu_common_has_work (CPUState *cs) {return false;@@ -249,6 +254,7 @@ static void cpu_class_init(ObjectClass *klass, void *data) k->class_by_name = cpu_common_class_by_name; k->reset = cpu_common_reset; k->get_arch_id = cpu_common_get_arch_id; + k->mmu_index = cpu_common_mmu_index; k->has_work = cpu_common_has_work; k->get_paging_enabled = cpu_common_get_paging_enabled; k->get_memory_mapping = cpu_common_get_memory_mapping;target-alpha/cpu.c +14
-0@@ -31,6 +31,19 @@ static void alpha_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static int alpha_cpu_mmu_index (const CPUState *cs) +{ +AlphaCPU *cpu =ALPHA_CPU (cs); + +if (cpu->env.pal_mode) { +return MMU_KERNEL_IDX ; + }else if (cpu->env.ps &PS_USER_MODE ) { +return MMU_USER_IDX ; + }else { +return MMU_KERNEL_IDX ; + } +} +static bool alpha_cpu_has_work (CPUState *cs) {/* Here we are checking to see if the CPU should wake up from HALT. @@ -289,6 +302,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) cc->has_work = alpha_cpu_has_work; cc->do_interrupt = alpha_cpu_do_interrupt; cc->dump_state = alpha_cpu_dump_state; + cc->mmu_index = alpha_cpu_mmu_index; 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;target-alpha/cpu.h +0
-11@@ -378,17 +378,6 @@ enum {PS_USER_MODE =8 }; -static inline int cpu_mmu_index (CPUAlphaState *env) -{ -if (env->pal_mode) { -return MMU_KERNEL_IDX ; - }else if (env->ps &PS_USER_MODE ) { -return MMU_USER_IDX ; - }else { -return MMU_KERNEL_IDX ; - } -} -enum {IR_V0 =0 ,IR_T0 =1 ,target-alpha/translate.c +1
-1@@ -3458,7 +3458,7 @@ static inline void gen_intermediate_code_internal(AlphaCPU *cpu, ctx.tb = tb; ctx.pc = pc_start; - ctx.mem_idx =cpu_mmu_index (env); + ctx.mem_idx =cpu_mmu_index (cs); ctx.implver = env->implver; ctx.singlestep_enabled = cs->singlestep_enabled;target-arm/cpu.c +8
-0@@ -34,6 +34,13 @@ static void arm_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.regs[15 ] = value; } +static int arm_cpu_mmu_index (const CPUState *cs) +{ +ARMCPU *cpu =ARM_CPU (cs); + +return (cpu->env.uncached_cpsr &CPSR_M ) ==ARM_CPU_MODE_USR ?1 :0 ; +} +static bool arm_cpu_has_work (CPUState *cs) { return cs->interrupt_request &@@ -899,6 +906,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->has_work = arm_cpu_has_work; cc->do_interrupt = arm_cpu_do_interrupt; cc->dump_state = arm_cpu_dump_state; + cc->mmu_index = arm_cpu_mmu_index; cc->set_pc = arm_cpu_set_pc; cc->gdb_read_register = arm_cpu_gdb_read_register; cc->gdb_write_register = arm_cpu_gdb_write_register;target-arm/cpu.h +0
-4@@ -750,10 +750,6 @@ static inline CPUARMState *cpu_init(const char *cpu_model)#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 -static inline int cpu_mmu_index (CPUARMState *env) -{ -return (env->uncached_cpsr &CPSR_M ) ==ARM_CPU_MODE_USR ?1 :0 ; -}#include "exec/cpu-all.h" target-cris/cpu.c +8
-0@@ -33,6 +33,13 @@ static void cris_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static int cris_cpu_mmu_index (const CPUState *cs) +{ +CRISCPU *cpu =CRIS_CPU (cs); + +return (cpu->env.pregs[PR_CCS ] &U_FLAG ) ?1 :0 ; +} +static bool cris_cpu_has_work (CPUState *cs) {return cs->interrupt_request & (CPU_INTERRUPT_HARD |CPU_INTERRUPT_NMI );@@ -265,6 +272,7 @@ static void cris_cpu_class_init(ObjectClass *oc, void *data) cc->has_work = cris_cpu_has_work; cc->do_interrupt = cris_cpu_do_interrupt; cc->dump_state = cris_cpu_dump_state; + cc->mmu_index = cris_cpu_mmu_index; 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;target-cris/cpu.h +0
-4@@ -238,10 +238,6 @@ static inline CPUCRISState *cpu_init(const char *cpu_model)#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 -static inline int cpu_mmu_index (CPUCRISState *env) -{ -return !!(env->pregs[PR_CCS ] &U_FLAG ); -}int cpu_cris_handle_mmu_fault (CPUCRISState *env,target_ulong address,int rw,int mmu_idx);target-cris/translate.c +3
-3@@ -1125,7 +1125,7 @@ static inline void cris_prepare_jmp (DisasContext *dc, unsigned int type)static void gen_load64 (DisasContext *dc,TCGv_i64 dst,TCGv addr) { -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index (CPU (cris_env_get_cpu (dc->env)));/* If we get a fault on a delayslot we must keep the jmp state in the cpu-state to be able to re-execute the jmp. */ @@ -1139,7 +1139,7 @@ static void gen_load64(DisasContext *dc, TCGv_i64 dst, TCGv addr)static void gen_load (DisasContext *dc,TCGv dst,TCGv addr,unsigned int size,int sign) { -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index (CPU (cris_env_get_cpu (dc->env)));/* If we get a fault on a delayslot we must keep the jmp state in the cpu-state to be able to re-execute the jmp. */ @@ -1169,7 +1169,7 @@ static void gen_load(DisasContext *dc, TCGv dst, TCGv addr,static void gen_store (DisasContext *dc,TCGv addr,TCGv val,unsigned int size) { -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index (CPU (cris_env_get_cpu (dc->env)));/* If we get a fault on a delayslot we must keep the jmp state in the cpu-state to be able to re-execute the jmp. */ target-cris/translate_v10.c +1
-1@@ -96,7 +96,7 @@ static void gen_store_v10_conditional(DisasContext *dc, TCGv addr, TCGv val,static void gen_store_v10 (DisasContext *dc,TCGv addr,TCGv val,unsigned int size) { -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index (CPU (cris_env_get_cpu (dc->env)));/* If we get a fault on a delayslot we must keep the jmp state in the cpu-state to be able to re-execute the jmp. */ target-i386/cpu.c +11
-0@@ -2676,6 +2676,16 @@ static void x86_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) cpu->env.eip = tb->pc - tb->cs_base; } +static int x86_cpu_mmu_index (const CPUState *cs) +{ +X86CPU *cpu =X86_CPU (cs); +CPUX86State *env = &cpu->env; + +return (env->hflags &HF_CPL_MASK ) ==3 ?MMU_USER_IDX : + ((env->hflags &HF_SMAP_MASK ) && (env->eflags &AC_MASK )) + ?MMU_KSMAP_IDX :MMU_KERNEL_IDX ; +} +static bool x86_cpu_has_work (CPUState *cs) {X86CPU *cpu =X86_CPU (cs);@@ -2713,6 +2723,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->has_work = x86_cpu_has_work; cc->do_interrupt = x86_cpu_do_interrupt; cc->dump_state = x86_cpu_dump_state; + cc->mmu_index = x86_cpu_mmu_index; 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;target-i386/cpu.h +0
-6@@ -1123,12 +1123,6 @@ static inline CPUX86State *cpu_init(const char *cpu_model)#define MMU_KERNEL_IDX 0#define MMU_USER_IDX 1#define MMU_KSMAP_IDX 2 -static inline int cpu_mmu_index (CPUX86State *env) -{ -return (env->hflags &HF_CPL_MASK ) ==3 ?MMU_USER_IDX : - ((env->hflags &HF_SMAP_MASK ) && (env->eflags &AC_MASK )) - ?MMU_KSMAP_IDX :MMU_KERNEL_IDX ; -}#define CC_DST (env->cc_dst)#define CC_SRC (env->cc_src)target-i386/translate.c +1
-1@@ -8291,7 +8291,7 @@ static inline void gen_intermediate_code_internal(X86CPU *cpu,/* select memory access functions */ dc->mem_index =0 ;if (flags &HF_SOFTMMU_MASK ) { - dc->mem_index = (cpu_mmu_index (env) +1 ) <<2 ; + dc->mem_index = (cpu_mmu_index (cs) +1 ) <<2 ; } dc->cpuid_features = env->features[FEAT_1_EDX ]; dc->cpuid_ext_features = env->features[FEAT_1_ECX ];target-lm32/cpu.h +0
-4@@ -36,10 +36,6 @@ typedef struct CPULM32State CPULM32State;#define NB_MMU_MODES 1#define TARGET_PAGE_BITS 12 -static inline int cpu_mmu_index (CPULM32State *env) -{ -return 0 ; -}#define TARGET_PHYS_ADDR_SPACE_BITS 32#define TARGET_VIRT_ADDR_SPACE_BITS 32target-m68k/cpu.c +8
-0@@ -30,6 +30,13 @@ static void m68k_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static int m68k_cpu_mmu_index (const CPUState *cs) +{ +M68kCPU *cpu =M68K_CPU (cs); + +return (cpu->env.sr &SR_S ) ==0 ?MMU_USER_IDX :0 ; +} +static bool m68k_cpu_has_work (CPUState *cs) {return cs->interrupt_request &CPU_INTERRUPT_HARD ;@@ -197,6 +204,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) cc->has_work = m68k_cpu_has_work; cc->do_interrupt = m68k_cpu_do_interrupt; cc->dump_state = m68k_cpu_dump_state; + cc->mmu_index = m68k_cpu_mmu_index; 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;target-m68k/cpu.h +0
-4@@ -232,10 +232,6 @@ static inline CPUM68KState *cpu_init(const char *cpu_model)#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 -static inline int cpu_mmu_index (CPUM68KState *env) -{ -return (env->sr &SR_S ) ==0 ?1 :0 ; -}int cpu_m68k_handle_mmu_fault (CPUM68KState *env,target_ulong address,int rw,int mmu_idx);target-microblaze/cpu.c +15
-0@@ -33,6 +33,20 @@ static void mb_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.sregs[SR_PC ] = value; } +static int mb_cpu_mmu_index (const CPUState *cs) +{ +MicroBlazeCPU *cpu =MICROBLAZE_CPU (cs); + +/* Are we in nommu mode?. */ +if (!(cpu->env.sregs[SR_MSR ] &MSR_VM )) { +return MMU_NOMMU_IDX ; + } +if (cpu->env.sregs[SR_MSR ] &MSR_UM ) { +return MMU_USER_IDX ; + } +return MMU_KERNEL_IDX ; +} +static bool mb_cpu_has_work (CPUState *cs) {return cs->interrupt_request & (CPU_INTERRUPT_HARD |CPU_INTERRUPT_NMI );@@ -147,6 +161,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->dump_state = mb_cpu_dump_state; + cc->mmu_index = mb_cpu_mmu_index; cc->set_pc = mb_cpu_set_pc; cc->gdb_read_register = mb_cpu_gdb_read_register; cc->gdb_write_register = mb_cpu_gdb_write_register;target-microblaze/cpu.h +0
-11@@ -316,17 +316,6 @@ static inline CPUMBState *cpu_init(const char *cpu_model)#define MMU_USER_IDX 2/* See NB_MMU_MODES further up the file. */ -static inline int cpu_mmu_index (CPUMBState *env) -{ -/* Are we in nommu mode?. */ -if (!(env->sregs[SR_MSR ] &MSR_VM )) -return MMU_NOMMU_IDX ; - -if (env->sregs[SR_MSR ] &MSR_UM ) -return MMU_USER_IDX ; -return MMU_KERNEL_IDX ; -} -int cpu_mb_handle_mmu_fault (CPUMBState *env,target_ulong address,int rw,int mmu_idx);#define cpu_handle_mmu_fault cpu_mb_handle_mmu_faulttarget-microblaze/mmu.c +2
-1@@ -218,6 +218,7 @@ uint32_t mmu_read(CPUMBState *env, uint32_t rn)void mmu_write (CPUMBState *env,uint32_t rn,uint32_t v) { +MicroBlazeCPU *cpu =mb_env_get_cpu (env);unsigned int i;D (qemu_log ("%s rn=%d=%x old=%x\n" , __func__, rn, v, env->mmu.regs[rn]));@@ -277,7 +278,7 @@ void mmu_write(CPUMBState *env, uint32_t rn, uint32_t v) } hit =mmu_translate (&env->mmu, &lu, - v &TLB_EPN_MASK ,0 ,cpu_mmu_index (env)); + v &TLB_EPN_MASK ,0 ,cpu_mmu_index (CPU (cpu)));if (hit) { env->mmu.regs[MMU_R_TLBX ] = lu.idx; }else target-microblaze/translate.c +7
-7@@ -440,7 +440,7 @@ static void dec_msr(DisasContext *dc) {TCGv t0, t1;unsigned int sr, to, rn; -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index (CPU (mb_env_get_cpu (dc->env))); sr = dc->imm & ((1 <<14 ) -1 ); to = dc->imm & (1 <<14 );@@ -751,7 +751,7 @@ static void dec_bit(DisasContext *dc) {TCGv t0, t1;unsigned int op; -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index (CPU (mb_env_get_cpu (dc->env))); op = dc->ir & ((1 <<9 ) -1 );switch (op) {@@ -874,7 +874,7 @@ static void dec_imm(DisasContext *dc)static inline void gen_load (DisasContext *dc,TCGv dst,TCGv addr,unsigned int size) { -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index (CPU (mb_env_get_cpu (dc->env)));if (size ==1 ) {tcg_gen_qemu_ld8u (dst, addr, mem_index);@@ -1093,7 +1093,7 @@ static void dec_load(DisasContext *dc)static void gen_store (DisasContext *dc,TCGv addr,TCGv val,unsigned int size) { -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index (CPU (mb_env_get_cpu (dc->env)));if (size ==1 )tcg_gen_qemu_st8 (val, addr, mem_index);@@ -1308,7 +1308,7 @@ static void dec_bcc(DisasContext *dc)static void dec_br (DisasContext *dc) {unsigned int dslot, link, abs, mbar; -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index (CPU (mb_env_get_cpu (dc->env))); dslot = dc->ir & (1 <<20 ); abs = dc->ir & (1 <<19 );@@ -1440,7 +1440,7 @@ static inline void do_rte(DisasContext *dc)static void dec_rts (DisasContext *dc) {unsigned int b_bit, i_bit, e_bit; -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index (CPU (mb_env_get_cpu (dc->env))); i_bit = dc->ir & (1 <<21 ); b_bit = dc->ir & (1 <<22 );@@ -1616,7 +1616,7 @@ static void dec_null(DisasContext *dc)/* Insns connected to FSL or AXI stream attached devices. */ static void dec_stream (DisasContext *dc) { -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index (CPU (mb_env_get_cpu (dc->env)));TCGv_i32 t_id, t_ctrl;int ctrl;target-mips/cpu.c +8
-0@@ -45,6 +45,13 @@ static void mips_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) env->hflags |= tb->flags &MIPS_HFLAG_BMASK ; } +static int mips_cpu_mmu_index (const CPUState *cs) +{ +MIPSCPU *cpu =MIPS_CPU (cs); + +return cpu->env.hflags &MIPS_HFLAG_KSU ; +} +static bool mips_cpu_has_work (CPUState *cs) {MIPSCPU *cpu =MIPS_CPU (cs);@@ -129,6 +136,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->has_work = mips_cpu_has_work; cc->do_interrupt = mips_cpu_do_interrupt; cc->dump_state = mips_cpu_dump_state; + cc->mmu_index = mips_cpu_mmu_index; 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;target-mips/cpu.h +0
-4@@ -516,10 +516,6 @@ extern uint32_t cpu_rddsp(uint32_t mask_num, CPUMIPSState *env);#define MMU_MODE1_SUFFIX _super#define MMU_MODE2_SUFFIX _user#define MMU_USER_IDX 2 -static inline int cpu_mmu_index (CPUMIPSState *env) -{ -return env->hflags &MIPS_HFLAG_KSU ; -}static inline int cpu_mips_hw_interrupts_pending (CPUMIPSState *env) {target-moxie/cpu.h +0
-5@@ -136,11 +136,6 @@ static inline CPUMoxieState *cpu_init(const char *cpu_model)#define cpu_gen_code cpu_moxie_gen_code#define cpu_signal_handler cpu_moxie_signal_handler -static inline int cpu_mmu_index (CPUMoxieState *env) -{ -return 0 ; -} -#include "exec/cpu-all.h" #include "exec/exec-all.h" target-openrisc/cpu.c +11
-0@@ -27,6 +27,16 @@ static void openrisc_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static int openrisc_cpu_mmu_index (const CPUState *cs) +{ +OpenRISCCPU *cpu =OPENRISC_CPU (cs); + +if (!(cpu->env.sr &SR_IME )) { +return MMU_NOMMU_IDX ; + } +return (cpu->env.sr &SR_SM ) ==0 ?MMU_USER_IDX :MMU_SUPERVISOR_IDX ; +} +static bool openrisc_cpu_has_work (CPUState *cs) { return cs->interrupt_request & (CPU_INTERRUPT_HARD |@@ -162,6 +172,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data) cc->has_work = openrisc_cpu_has_work; cc->do_interrupt = openrisc_cpu_do_interrupt; cc->dump_state = openrisc_cpu_dump_state; + cc->mmu_index = openrisc_cpu_mmu_index; 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;target-openrisc/cpu.h +0
-8@@ -409,14 +409,6 @@ static inline void cpu_get_tb_cpu_state(CPUOpenRISCState *env, *flags = (env->flags &D_FLAG ); } -static inline int cpu_mmu_index (CPUOpenRISCState *env) -{ -if (!(env->sr &SR_IME )) { -return MMU_NOMMU_IDX ; - } -return (env->sr &SR_SM ) ==0 ?MMU_USER_IDX :MMU_SUPERVISOR_IDX ; -} -#define CPU_INTERRUPT_TIMER CPU_INTERRUPT_TGT_INT_0#include "exec/exec-all.h" target-openrisc/translate.c +1
-1@@ -1679,7 +1679,7 @@ static inline void gen_intermediate_code_internal(OpenRISCCPU *cpu, dc->ppc = pc_start; dc->pc = pc_start; dc->flags = cpu->env.cpucfgr; - dc->mem_idx =cpu_mmu_index (&cpu->env); + dc->mem_idx =cpu_mmu_index (cs); dc->synced_flags = dc->tb_flags = tb->flags; dc->delayed_branch = !!(dc->tb_flags &D_FLAG ); dc->singlestep_enabled = cs->singlestep_enabled;target-ppc/cpu.h +0
-4@@ -1183,10 +1183,6 @@ static inline CPUPPCState *cpu_init(const char *cpu_model)#define MMU_MODE1_SUFFIX _kernel#define MMU_MODE2_SUFFIX _hypv#define MMU_USER_IDX 0 -static inline int cpu_mmu_index (CPUPPCState *env) -{ -return env->mmu_idx; -}#include "exec/cpu-all.h" target-ppc/translate_init.c +8
-0@@ -8437,6 +8437,13 @@ static void ppc_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.nip = value; } +static int ppc_cpu_mmu_index (const CPUState *cs) +{ +PowerPCCPU *cpu =POWERPC_CPU (cs); + +return cpu->env.mmu_idx; +} +static bool ppc_cpu_has_work (CPUState *cs) {PowerPCCPU *cpu =POWERPC_CPU (cs);@@ -8573,6 +8580,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = ppc_cpu_do_interrupt; cc->dump_state = ppc_cpu_dump_state; cc->dump_statistics = ppc_cpu_dump_statistics; + cc->mmu_index = ppc_cpu_mmu_index; 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;target-s390x/cpu.c +12
-0@@ -65,6 +65,17 @@ static void s390_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.psw.addr = value; } +static int s390_cpu_mmu_index (const CPUState *cs) +{ +S390CPU *cpu =S390_CPU (cs); + +if (cpu->env.psw.mask &PSW_MASK_PSTATE ) { +return 1 ; + } + +return 0 ; +} +static bool s390_cpu_has_work (CPUState *cs) {S390CPU *cpu =S390_CPU (cs);@@ -229,6 +240,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->has_work = s390_cpu_has_work; cc->do_interrupt = s390_cpu_do_interrupt; cc->dump_state = s390_cpu_dump_state; + cc->mmu_index = s390_cpu_mmu_index; cc->set_pc = s390_cpu_set_pc; cc->gdb_read_register = s390_cpu_gdb_read_register; cc->gdb_write_register = s390_cpu_gdb_write_register;target-s390x/cpu.h +0
-9@@ -273,15 +273,6 @@ typedef struct CPUS390XState {#define FLAG_MASK_64 (PSW_MASK_64 >> 32)#define FLAG_MASK_32 0x00001000 -static inline int cpu_mmu_index (CPUS390XState *env) -{ -if (env->psw.mask &PSW_MASK_PSTATE ) { -return 1 ; - } - -return 0 ; -} -static inline void cpu_get_tb_cpu_state (CPUS390XState * env,target_ulong *pc,target_ulong *cs_base,int *flags) {target-sh4/cpu.c +8
-0@@ -39,6 +39,13 @@ static void superh_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) cpu->env.flags = tb->flags; } +static int superh_cpu_mmu_index (const CPUState *cs) +{ +SuperHCPU *cpu =SUPERH_CPU (cs); + +return (cpu->env.sr &SR_MD ) ==0 ?1 :0 ; +} +static bool superh_cpu_has_work (CPUState *cs) {return cs->interrupt_request &CPU_INTERRUPT_HARD ;@@ -291,6 +298,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) cc->has_work = superh_cpu_has_work; cc->do_interrupt = superh_cpu_do_interrupt; cc->dump_state = superh_cpu_dump_state; + cc->mmu_index = superh_cpu_mmu_index; cc->set_pc = superh_cpu_set_pc; cc->synchronize_from_tb = superh_cpu_synchronize_from_tb; cc->gdb_read_register = superh_cpu_gdb_read_register;target-sh4/cpu.h +0
-4@@ -240,10 +240,6 @@ static inline CPUSH4State *cpu_init(const char *cpu_model)#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 -static inline int cpu_mmu_index (CPUSH4State *env) -{ -return (env->sr &SR_MD ) ==0 ?1 :0 ; -}#include "exec/cpu-all.h" target-sparc/cpu.c +25
-0@@ -739,6 +739,30 @@ static void sparc_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) cpu->env.npc = tb->cs_base; } +static int sparc_cpu_mmu_index (const CPUState *cs) +{ +#if defined(CONFIG_USER_ONLY ) +return MMU_USER_IDX ; +#else +SPARCCPU *cpu =SPARC_CPU (cs); +CPUSPARCState *env = &cpu->env; + +#if !defined(TARGET_SPARC64 ) +return env->psrs; +#else +if (env->tl >0 ) { +return MMU_NUCLEUS_IDX ; + }else if (cpu_hypervisor_mode (env)) { +return MMU_HYPV_IDX ; + }else if (cpu_supervisor_mode (env)) { +return MMU_KERNEL_IDX ; + }else { +return MMU_USER_IDX ; + } +#endif +#endif +} +static bool sparc_cpu_has_work (CPUState *cs) {SPARCCPU *cpu =SPARC_CPU (cs);@@ -797,6 +821,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data)#if !defined(TARGET_SPARC64 ) && !defined(CONFIG_USER_ONLY ) cc->memory_rw_debug = sparc_cpu_memory_rw_debug;#endif + cc->mmu_index = sparc_cpu_mmu_index; cc->set_pc = sparc_cpu_set_pc; cc->synchronize_from_tb = sparc_cpu_synchronize_from_tb; cc->gdb_read_register = sparc_cpu_gdb_read_register;target-sparc/cpu.h +0
-19@@ -647,25 +647,6 @@ static inline int cpu_supervisor_mode(CPUSPARCState *env1) }#endif -static inline int cpu_mmu_index (CPUSPARCState *env1) -{ -#if defined(CONFIG_USER_ONLY ) -return MMU_USER_IDX ; -#elif !defined(TARGET_SPARC64 ) -return env1->psrs; -#else -if (env1->tl >0 ) { -return MMU_NUCLEUS_IDX ; - }else if (cpu_hypervisor_mode (env1)) { -return MMU_HYPV_IDX ; - }else if (cpu_supervisor_mode (env1)) { -return MMU_KERNEL_IDX ; - }else { -return MMU_USER_IDX ; - } -#endif -} -static inline int cpu_interrupts_enabled (CPUSPARCState *env1) {#if !defined (TARGET_SPARC64 )target-sparc/mmu_helper.c +1
-1@@ -842,7 +842,7 @@ hwaddr sparc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)SPARCCPU *cpu =SPARC_CPU (cs);CPUSPARCState *env = &cpu->env;hwaddr phys_addr; -int mmu_idx =cpu_mmu_index (env); +int mmu_idx =cpu_mmu_index (cs);MemoryRegionSection section;if (cpu_sparc_get_phys_page (env, &phys_addr, addr,2 , mmu_idx) !=0 ) {target-sparc/translate.c +1
-1@@ -5241,7 +5241,7 @@ static inline void gen_intermediate_code_internal(SPARCCPU *cpu, last_pc = dc->pc; dc->npc = (target_ulong ) tb->cs_base; dc->cc_op =CC_OP_DYNAMIC ; - dc->mem_idx =cpu_mmu_index (env); + dc->mem_idx =cpu_mmu_index (cs); dc->def = env->def; dc->fpu_enabled =tb_fpu_enabled (tb->flags); dc->address_mask_32bit =tb_am_enabled (tb->flags);target-unicore32/cpu.c +8
-0@@ -23,6 +23,13 @@ static void uc32_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.regs[31 ] = value; } +static int uc32_cpu_mmu_index (const CPUState *cs) +{ +UniCore32CPU *cpu =UNICORE32_CPU (cs); + +return (cpu->env.uncached_asr &ASR_M ) ==ASR_MODE_USER ?MMU_USER_IDX :0 ; +} +static bool uc32_cpu_has_work (CPUState *cs) { return cs->interrupt_request &@@ -147,6 +154,7 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data) cc->has_work = uc32_cpu_has_work; cc->do_interrupt = uc32_cpu_do_interrupt; cc->dump_state = uc32_cpu_dump_state; + cc->mmu_index = uc32_cpu_mmu_index; cc->set_pc = uc32_cpu_set_pc;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = uc32_cpu_get_phys_page_debug;target-unicore32/cpu.h +0
-4@@ -137,10 +137,6 @@ int uc32_cpu_handle_mmu_fault(CPUUniCore32State *env, target_ulong address, int#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 -static inline int cpu_mmu_index (CPUUniCore32State *env) -{ -return (env->uncached_asr &ASR_M ) ==ASR_MODE_USER ?1 :0 ; -}#include "exec/cpu-all.h" #include "cpu-qom.h" target-xtensa/cpu.c +8
-0@@ -40,6 +40,13 @@ static void xtensa_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static int xtensa_cpu_mmu_index (const CPUState *cs) +{ +XtensaCPU *cpu =XTENSA_CPU (cs); + +return xtensa_get_cring (&cpu->env); +} +static bool xtensa_cpu_has_work (CPUState *cs) {XtensaCPU *cpu =XTENSA_CPU (cs);@@ -142,6 +149,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data) cc->has_work = xtensa_cpu_has_work; cc->do_interrupt = xtensa_cpu_do_interrupt; cc->dump_state = xtensa_cpu_dump_state; + cc->mmu_index = xtensa_cpu_mmu_index; cc->set_pc = xtensa_cpu_set_pc; cc->gdb_read_register = xtensa_cpu_gdb_read_register; cc->gdb_write_register = xtensa_cpu_gdb_write_register;target-xtensa/cpu.h +0
-0@@ -472,11 +472,6 @@ static inline xtensa_tlb_entry *xtensa_tlb_get_entry(CPUXtensaState *env,#define MMU_MODE2_SUFFIX _ring2
target-xtensa/cpu.h static inline xtensa_tlb_entry *xtensa_tlb_get_entry(CPUXtensaState *env, · line 477
Quoted 10 lines
target-xtensa/cpu.h +0
-5#define MMU_MODE3_SUFFIX _ring3 -static inline int cpu_mmu_index (CPUXtensaState *env) -{ -return xtensa_get_cring (env); -} -#define XTENSA_TBFLAG_RING_MASK 0x3#define XTENSA_TBFLAG_EXCM 0x4#define XTENSA_TBFLAG_LITBASE 0x8
target-openrisc: Tested-by: Jia Liu <[email protected]>
Quoted 3 lines
--
1.8.1.4
Re: [Qemu-devel] [RFC qom-cpu 02/41] cpu: Turn cpu_mmu_index() into a CPUClass hook
Am 04.09.2013 14:42, schrieb Jia Liu:
Quoted 4 lines · Andreas Färber
Quoted 3 lines
Default to 0.
Signed-off-by Andreas Färber <[email protected]>
Paolo has indicated that patches 2 and 3 shouldn't be applied since they touch on TCG hot paths, replacing an inline function with a dispatched one, thereby possibly leading to performance regressions.
Unfortunately that still means for me that I need to write a boilerplate inline function returning MMU index 0 for each of my new microcontroller targets... :/
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
RFC 3/41 cpu: Turn cpu_get_tb_cpu_state() into a CPUClass hook
In reply to Andreas Färber--- cpu-exec.c | 6 ++++-- exec.c | 10 ++++++---- hw/i386/kvmvapic.c | 8 +++++--- include/qom/cpu.h | 4 ++++ target-alpha/cpu.c | 24 ++++++++++++++++++++++++ target-alpha/cpu.h | 21 --------------------- target-arm/cpu.c | 28 ++++++++++++++++++++++++++++ target-arm/cpu.h | 24 ------------------------ target-cris/cpu.c | 14 ++++++++++++++ target-cris/cpu.h | 10 ---------- target-i386/cpu.c | 13 +++++++++++++ target-i386/cpu.h | 9 --------- target-lm32/cpu.c | 11 +++++++++++ target-lm32/cpu.h | 9 --------- target-m68k/cpu.c | 14 ++++++++++++++ target-m68k/cpu.h | 11 ----------- target-microblaze/cpu.c | 13 +++++++++++++ target-microblaze/cpu.h | 9 --------- target-mips/cpu.c | 12 ++++++++++++ target-mips/cpu.h | 8 -------- target-moxie/cpu.c | 11 +++++++++++ target-moxie/cpu.h | 8 -------- target-openrisc/cpu.c | 12 ++++++++++++ target-openrisc/cpu.h | 10 ---------- target-ppc/cpu.h | 8 -------- target-ppc/translate_init.c | 11 +++++++++++ target-s390x/cpu.c | 13 +++++++++++++ target-s390x/cpu.h | 9 --------- target-sh4/cpu.c | 17 +++++++++++++++++ target-sh4/cpu.h | 13 ------------- target-sparc/cpu.c | 31 +++++++++++++++++++++++++++++++ target-sparc/cpu.h | 27 --------------------------- target-unicore32/cpu.c | 14 ++++++++++++++ target-unicore32/cpu.h | 11 ----------- target-xtensa/cpu.c | 34 ++++++++++++++++++++++++++++++++++ target-xtensa/cpu.h | 30 ------------------------------ translate-all.c | 18 ++++++++++++------ 37 files changed, 303 insertions(+), 232 deletions(-)
cpu-exec.c +4 -2
@@ -153,14 +153,16 @@ static TranslationBlock *tb_find_slow(CPUArchState *env,static inline TranslationBlock *tb_find_fast (CPUArchState *env) { +CPUState *cpu =ENV_GET_CPU (env); +CPUClass *cc =CPU_GET_CLASS (cpu);TranslationBlock *tb; -target_ulong cs_base, pc; +vaddr cs_base, pc;int flags;/* we record a subset of the CPU state. It will always be the same before a given translated block is executed. */ -cpu_get_tb_cpu_state (env, &pc, &cs_base, &flags); + cc->get_tb_cpu_state (cpu, &pc, &cs_base, &flags); tb = env->tb_jmp_cache[tb_jmp_cache_hash_func (pc)];if (unlikely (!tb || tb->pc != pc || tb->cs_base != cs_base || tb->flags != flags)) {
exec.c +6 -4
@@ -1478,8 +1478,10 @@ static const MemoryRegionOps notdirty_mem_ops = {/* Generate a debug exception if a watchpoint has been hit. */ static void check_watchpoint (int offset,int len_mask,int flags) { -CPUArchState *env = current_cpu->env_ptr; -target_ulong pc, cs_base; +CPUState *cpu = current_cpu; +CPUArchState *env = cpu->env_ptr; +CPUClass *cc =CPU_GET_CLASS (cpu); +vaddr pc, cs_base;target_ulong vaddr;CPUWatchpoint *wp;int cpu_flags;
@@ -1488,7 +1490,7 @@ static void check_watchpoint(int offset, int len_mask, int flags)/* We re-entered the check after replacing the TB. Now raise * the debug interrupt so that is will trigger after the * current instruction. */ -cpu_interrupt (ENV_GET_CPU (env),CPU_INTERRUPT_DEBUG ); +cpu_interrupt (cpu,CPU_INTERRUPT_DEBUG );return ; } vaddr = (env->mem_io_vaddr &TARGET_PAGE_MASK ) + offset;
@@ -1503,7 +1505,7 @@ static void check_watchpoint(int offset, int len_mask, int flags) env->exception_index =EXCP_DEBUG ;cpu_loop_exit (env); }else { -cpu_get_tb_cpu_state (env, &pc, &cs_base, &cpu_flags); + cc->get_tb_cpu_state (cpu, &pc, &cs_base, &cpu_flags);tb_gen_code (env, pc, cs_base, cpu_flags,1 );cpu_resume_from_signal (env,NULL ); }
hw/i386/kvmvapic.c +5 -3
@@ -395,8 +395,8 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)VAPICHandlers *handlers;uint8_t opcode[2 ];uint32_t imm32; -target_ulong current_pc =0 ; -target_ulong current_cs_base =0 ; +vaddr current_pc =0 ; +vaddr current_cs_base =0 ;int current_flags =0 ;if (smp_cpus ==1 ) {
@@ -406,8 +406,10 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip) }if (!kvm_enabled ()) { +CPUClass *cc =CPU_GET_CLASS (cs); +cpu_restore_state (env, env->mem_io_pc); -cpu_get_tb_cpu_state (env, ¤t_pc, ¤t_cs_base, + cc->get_tb_cpu_state (cs, ¤t_pc, ¤t_cs_base, ¤t_flags); }
include/qom/cpu.h +4 -0
@@ -80,6 +80,8 @@ struct TranslationBlock;* @get_paging_enabled: Callback for inquiring whether paging is enabled. * @get_memory_mapping: Callback for obtaining the memory mappings. * @set_pc: Callback for setting the Program Counter register. +* @get_tb_cpu_state: Callback for obtaining state for a TCG +* #TranslationBlock. * @synchronize_from_tb: Callback for synchronizing state from a TCG * #TranslationBlock. * @get_phys_page_debug: Callback for obtaining a physical address.
@@ -115,6 +117,8 @@ typedef struct CPUClass {void (*get_memory_mapping)(CPUState *cpu,MemoryMappingList *list,Error **errp);void (*set_pc)(CPUState *cpu,vaddr value); +void (*get_tb_cpu_state)(const CPUState *cpu,vaddr *pc,vaddr *cs_base, +int *flags);void (*synchronize_from_tb)(CPUState *cpu,struct TranslationBlock *tb);hwaddr (*get_phys_page_debug)(CPUState *cpu,vaddr addr);int (*gdb_read_register)(CPUState *cpu,uint8_t *buf,int reg);
target-alpha/cpu.c +24 -0
@@ -31,6 +31,29 @@ static void alpha_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static void alpha_cpu_get_tb_cpu_state (const CPUState *cs,vaddr *pc, +vaddr *cs_base,int *pflags) +{ +AlphaCPU *cpu =ALPHA_CPU (cs); +CPUAlphaState *env = &cpu->env; +int flags =0 ; + + *pc = env->pc; + *cs_base =0 ; + +if (env->pal_mode) { + flags =TB_FLAGS_PAL_MODE ; + }else { + flags = env->ps &PS_USER_MODE ; + } +if (env->fen) { + flags |=TB_FLAGS_FEN ; + } + flags |= env->amask <<TB_FLAGS_AMASK_SHIFT ; + + *pflags = flags; +} +static int alpha_cpu_mmu_index (const CPUState *cs) {AlphaCPU *cpu =ALPHA_CPU (cs);
@@ -304,6 +327,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) cc->dump_state = alpha_cpu_dump_state; cc->mmu_index = alpha_cpu_mmu_index; cc->set_pc = alpha_cpu_set_pc; + cc->get_tb_cpu_state = alpha_cpu_get_tb_cpu_state; cc->gdb_read_register = alpha_cpu_gdb_read_register; cc->gdb_write_register = alpha_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY
target-alpha/cpu.h +0 -21
@@ -466,27 +466,6 @@ enum { TB_FLAGS_AMASK_PREFETCH = AMASK_PREFETCH << TB_FLAGS_AMASK_SHIFT, }; -static inline void cpu_get_tb_cpu_state (CPUAlphaState *env,target_ulong *pc, -target_ulong *cs_base,int *pflags) -{ -int flags =0 ; - - *pc = env->pc; - *cs_base =0 ; - -if (env->pal_mode) { - flags =TB_FLAGS_PAL_MODE ; - }else { - flags = env->ps &PS_USER_MODE ; - } -if (env->fen) { - flags |=TB_FLAGS_FEN ; - } - flags |= env->amask <<TB_FLAGS_AMASK_SHIFT ; - - *pflags = flags; -} -#include "exec/exec-all.h" #endif /* !defined (__CPU_ALPHA_H__) */
target-arm/cpu.c +28 -0
@@ -34,6 +34,33 @@ static void arm_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.regs[15 ] = value; } +static void arm_cpu_get_tb_cpu_state (const CPUState *cs,vaddr *pc, +vaddr *cs_base,int *flags) +{ +ARMCPU *cpu =ARM_CPU (cs); +CPUARMState *env = &cpu->env; +int privmode; + + *pc = env->regs[15 ]; + *cs_base =0 ; + *flags = (env->thumb <<ARM_TBFLAG_THUMB_SHIFT ) + | (env->vfp.vec_len <<ARM_TBFLAG_VECLEN_SHIFT ) + | (env->vfp.vec_stride <<ARM_TBFLAG_VECSTRIDE_SHIFT ) + | (env->condexec_bits <<ARM_TBFLAG_CONDEXEC_SHIFT ) + | (env->bswap_code <<ARM_TBFLAG_BSWAP_CODE_SHIFT ); +if (arm_feature (env,ARM_FEATURE_M )) { + privmode = !((env->v7m.exception ==0 ) && (env->v7m.control &1 )); + }else { + privmode = (env->uncached_cpsr &CPSR_M ) !=ARM_CPU_MODE_USR ; + } +if (privmode) { + *flags |=ARM_TBFLAG_PRIV_MASK ; + } +if (env->vfp.xregs[ARM_VFP_FPEXC ] & (1 <<30 )) { + *flags |=ARM_TBFLAG_VFPEN_MASK ; + } +} +static int arm_cpu_mmu_index (const CPUState *cs) {ARMCPU *cpu =ARM_CPU (cs);
@@ -908,6 +935,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->dump_state = arm_cpu_dump_state; cc->mmu_index = arm_cpu_mmu_index; cc->set_pc = arm_cpu_set_pc; + cc->get_tb_cpu_state = arm_cpu_get_tb_cpu_state; cc->gdb_read_register = arm_cpu_gdb_read_register; cc->gdb_write_register = arm_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY
target-arm/cpu.h +0 -24
@@ -786,30 +786,6 @@ static inline CPUARMState *cpu_init(const char *cpu_model)#define ARM_TBFLAG_BSWAP_CODE (F ) \ (((F) & ARM_TBFLAG_BSWAP_CODE_MASK) >> ARM_TBFLAG_BSWAP_CODE_SHIFT) -static inline void cpu_get_tb_cpu_state (CPUARMState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) -{ -int privmode; - *pc = env->regs[15 ]; - *cs_base =0 ; - *flags = (env->thumb <<ARM_TBFLAG_THUMB_SHIFT ) - | (env->vfp.vec_len <<ARM_TBFLAG_VECLEN_SHIFT ) - | (env->vfp.vec_stride <<ARM_TBFLAG_VECSTRIDE_SHIFT ) - | (env->condexec_bits <<ARM_TBFLAG_CONDEXEC_SHIFT ) - | (env->bswap_code <<ARM_TBFLAG_BSWAP_CODE_SHIFT ); -if (arm_feature (env,ARM_FEATURE_M )) { - privmode = !((env->v7m.exception ==0 ) && (env->v7m.control &1 )); - }else { - privmode = (env->uncached_cpsr &CPSR_M ) !=ARM_CPU_MODE_USR ; - } -if (privmode) { - *flags |=ARM_TBFLAG_PRIV_MASK ; - } -if (env->vfp.xregs[ARM_VFP_FPEXC ] & (1 <<30 )) { - *flags |=ARM_TBFLAG_VFPEN_MASK ; - } -} -#include "exec/exec-all.h" /* Load an instruction and return it in the standard little-endian order */
target-cris/cpu.c +14 -0
@@ -33,6 +33,19 @@ static void cris_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static void cris_cpu_get_tb_cpu_state (const CPUState *cs,vaddr *pc, +vaddr *cs_base,int *flags) +{ +CRISCPU *cpu =CRIS_CPU (cs); +CPUCRISState *env = &cpu->env; + + *pc = env->pc; + *cs_base =0 ; + *flags = env->dslot | + (env->pregs[PR_CCS ] & (S_FLAG |P_FLAG |U_FLAG | +X_FLAG |PFIX_FLAG )); +} +static int cris_cpu_mmu_index (const CPUState *cs) {CRISCPU *cpu =CRIS_CPU (cs);
@@ -274,6 +287,7 @@ static void cris_cpu_class_init(ObjectClass *oc, void *data) cc->dump_state = cris_cpu_dump_state; cc->mmu_index = cris_cpu_mmu_index; cc->set_pc = cris_cpu_set_pc; + cc->get_tb_cpu_state = cris_cpu_get_tb_cpu_state; cc->gdb_read_register = cris_cpu_gdb_read_register; cc->gdb_write_register = cris_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY
target-cris/cpu.h +0 -10
@@ -255,16 +255,6 @@ int cpu_cris_handle_mmu_fault(CPUCRISState *env, target_ulong address, int rw,#include "exec/cpu-all.h" -static inline void cpu_get_tb_cpu_state (CPUCRISState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) -{ - *pc = env->pc; - *cs_base =0 ; - *flags = env->dslot | - (env->pregs[PR_CCS ] & (S_FLAG |P_FLAG |U_FLAG - |X_FLAG |PFIX_FLAG )); -} -#define cpu_list cris_cpu_listvoid cris_cpu_list (FILE *f,fprintf_function cpu_fprintf);
target-i386/cpu.c +13 -0
@@ -2669,6 +2669,18 @@ static void x86_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.eip = value; } +static void x86_cpu_get_tb_cpu_state (const CPUState *cs,vaddr *pc, +vaddr *cs_base,int *flags) +{ +X86CPU *cpu =X86_CPU (cs); +CPUX86State *env = &cpu->env; + + *cs_base = env->segs[R_CS ].base; + *pc = *cs_base + env->eip; + *flags = env->hflags | + (env->eflags & (IOPL_MASK |TF_MASK |RF_MASK |VM_MASK |AC_MASK )); +} +static void x86_cpu_synchronize_from_tb (CPUState *cs,TranslationBlock *tb) {X86CPU *cpu =X86_CPU (cs);
@@ -2725,6 +2737,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->dump_state = x86_cpu_dump_state; cc->mmu_index = x86_cpu_mmu_index; cc->set_pc = x86_cpu_set_pc; + cc->get_tb_cpu_state = x86_cpu_get_tb_cpu_state; 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;
target-i386/cpu.h +0 -9
@@ -1157,15 +1157,6 @@ void optimize_flags_init(void);#include "exec/exec-all.h" -static inline void cpu_get_tb_cpu_state (CPUX86State *env,target_ulong *pc, -target_ulong *cs_base,int *flags) -{ - *cs_base = env->segs[R_CS ].base; - *pc = *cs_base + env->eip; - *flags = env->hflags | - (env->eflags & (IOPL_MASK |TF_MASK |RF_MASK |VM_MASK |AC_MASK )); -} -void do_cpu_init (X86CPU *cpu);void do_cpu_sipi (X86CPU *cpu);
target-lm32/cpu.c +11 -0
@@ -29,6 +29,16 @@ static void lm32_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static void lm32_cpu_get_tb_cpu_state (const CPUState *cs,vaddr *pc, +vaddr *cs_base,int *flags) +{ +LM32CPU *cpu =LM32_CPU (cs); + + *pc = cpu->env.pc; + *cs_base =0 ; + *flags =0 ; +} +static bool lm32_cpu_has_work (CPUState *cs) {return cs->interrupt_request &CPU_INTERRUPT_HARD ;
@@ -95,6 +105,7 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = lm32_cpu_do_interrupt; cc->dump_state = lm32_cpu_dump_state; cc->set_pc = lm32_cpu_set_pc; + cc->get_tb_cpu_state = lm32_cpu_get_tb_cpu_state; cc->gdb_read_register = lm32_cpu_gdb_read_register; cc->gdb_write_register = lm32_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY
target-lm32/cpu.h +0 -9
@@ -212,15 +212,6 @@ int cpu_lm32_handle_mmu_fault(CPULM32State *env, target_ulong address, int rw,#define cpu_handle_mmu_fault cpu_lm32_handle_mmu_fault#include "exec/cpu-all.h" - -static inline void cpu_get_tb_cpu_state (CPULM32State *env,target_ulong *pc, -target_ulong *cs_base,int *flags) -{ - *pc = env->pc; - *cs_base =0 ; - *flags =0 ; -} -#include "exec/exec-all.h" #endif
target-m68k/cpu.c +14 -0
@@ -30,6 +30,19 @@ static void m68k_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static void m68k_cpu_get_tb_cpu_state (const CPUState *cs,vaddr *pc, +vaddr *cs_base,int *flags) +{ +M68kCPU *cpu =M68K_CPU (cs); +CPUM68KState *env = &cpu->env; + + *pc = env->pc; + *cs_base =0 ; + *flags = (env->fpcr &M68K_FPCR_PREC )/* Bit 6 */ + | (env->sr &SR_S )/* Bit 13 */ + | ((env->macsr >>4 ) &0xf );/* Bits 0-3 */ +} +static int m68k_cpu_mmu_index (const CPUState *cs) {M68kCPU *cpu =M68K_CPU (cs);
@@ -206,6 +219,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) cc->dump_state = m68k_cpu_dump_state; cc->mmu_index = m68k_cpu_mmu_index; cc->set_pc = m68k_cpu_set_pc; + cc->get_tb_cpu_state = m68k_cpu_get_tb_cpu_state; cc->gdb_read_register = m68k_cpu_gdb_read_register; cc->gdb_write_register = m68k_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY
target-m68k/cpu.h +0 -11
@@ -238,17 +238,6 @@ int cpu_m68k_handle_mmu_fault(CPUM68KState *env, target_ulong address, int rw,#define cpu_handle_mmu_fault cpu_m68k_handle_mmu_fault#include "exec/cpu-all.h" - -static inline void cpu_get_tb_cpu_state (CPUM68KState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) -{ - *pc = env->pc; - *cs_base =0 ; - *flags = (env->fpcr &M68K_FPCR_PREC )/* Bit 6 */ - | (env->sr &SR_S )/* Bit 13 */ - | ((env->macsr >>4 ) &0xf );/* Bits 0-3 */ -} -#include "exec/exec-all.h" #endif
target-microblaze/cpu.c +13 -0
@@ -33,6 +33,18 @@ static void mb_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.sregs[SR_PC ] = value; } +static void mb_cpu_get_tb_cpu_state (const CPUState *cs,vaddr *pc, +vaddr *cs_base,int *flags) +{ +MicroBlazeCPU *cpu =MICROBLAZE_CPU (cs); +CPUMBState *env = &cpu->env; + + *pc = env->sregs[SR_PC ]; + *cs_base =0 ; + *flags = (env->iflags &IFLAGS_TB_MASK ) | + (env->sregs[SR_MSR ] & (MSR_UM |MSR_VM |MSR_EE )); +} +static int mb_cpu_mmu_index (const CPUState *cs) {MicroBlazeCPU *cpu =MICROBLAZE_CPU (cs);
@@ -163,6 +175,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data) cc->dump_state = mb_cpu_dump_state; cc->mmu_index = mb_cpu_mmu_index; cc->set_pc = mb_cpu_set_pc; + cc->get_tb_cpu_state = mb_cpu_get_tb_cpu_state; cc->gdb_read_register = mb_cpu_gdb_read_register; cc->gdb_write_register = mb_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY
target-microblaze/cpu.h +0 -9
@@ -332,15 +332,6 @@ static inline target_ulong cpu_get_pc(CPUMBState *env)return env->sregs[SR_PC ]; } -static inline void cpu_get_tb_cpu_state (CPUMBState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) -{ - *pc = env->sregs[SR_PC ]; - *cs_base =0 ; - *flags = (env->iflags &IFLAGS_TB_MASK ) | - (env->sregs[SR_MSR ] & (MSR_UM |MSR_VM |MSR_EE )); -} -#if !defined(CONFIG_USER_ONLY ) void mb_cpu_unassigned_access(CPUState *cpu, hwaddr addr, bool is_write, bool is_exec, int is_asi,
target-mips/cpu.c +12 -0
@@ -35,6 +35,17 @@ static void mips_cpu_set_pc(CPUState *cs, vaddr value) } } +static void mips_cpu_get_tb_cpu_state (const CPUState *cs,vaddr *pc, +vaddr *cs_base,int *flags) +{ +MIPSCPU *cpu =MIPS_CPU (cs); +CPUMIPSState *env = &cpu->env; + + *pc = env->active_tc.PC; + *cs_base =0 ; + *flags = env->hflags & (MIPS_HFLAG_TMASK |MIPS_HFLAG_BMASK ); +} +static void mips_cpu_synchronize_from_tb (CPUState *cs,TranslationBlock *tb) {MIPSCPU *cpu =MIPS_CPU (cs);
@@ -138,6 +149,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->dump_state = mips_cpu_dump_state; cc->mmu_index = mips_cpu_mmu_index; cc->set_pc = mips_cpu_set_pc; + cc->get_tb_cpu_state = mips_cpu_get_tb_cpu_state; 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;
target-mips/cpu.h +0 -8
@@ -659,14 +659,6 @@ hwaddr cpu_mips_translate_address (CPUMIPSState *env, target_ulong address,#endif target_ulong exception_resume_pc (CPUMIPSState *env); -static inline void cpu_get_tb_cpu_state (CPUMIPSState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) -{ - *pc = env->active_tc.PC; - *cs_base =0 ; - *flags = env->hflags & (MIPS_HFLAG_TMASK |MIPS_HFLAG_BMASK ); -} -static inline int mips_vpe_active (CPUMIPSState *env) {int active =1 ;
target-moxie/cpu.c +11 -0
@@ -29,6 +29,16 @@ static void moxie_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static void moxie_cpu_get_tb_cpu_state (const CPUState *cs,vaddr *pc, +vaddr *cs_base,int *flags) +{ +MoxieCPU *cpu =MOXIE_CPU (cs); + + *pc = cpu->env.pc; + *cs_base =0 ; + *flags =0 ; +} +static bool moxie_cpu_has_work (CPUState *cs) {return cs->interrupt_request &CPU_INTERRUPT_HARD ;
@@ -108,6 +118,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->get_tb_cpu_state = moxie_cpu_get_tb_cpu_state;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = moxie_cpu_get_phys_page_debug; cc->vmsd = &vmstate_moxie_cpu;
target-moxie/cpu.h +0 -8
@@ -139,14 +139,6 @@ static inline CPUMoxieState *cpu_init(const char *cpu_model)#include "exec/cpu-all.h" #include "exec/exec-all.h" -static inline void cpu_get_tb_cpu_state (CPUMoxieState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) -{ - *pc = env->pc; - *cs_base =0 ; - *flags =0 ; -} -int cpu_moxie_handle_mmu_fault (CPUMoxieState *env,target_ulong address,int rw,int mmu_idx);
target-openrisc/cpu.c +12 -0
@@ -27,6 +27,17 @@ static void openrisc_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static void openrisc_cpu_get_tb_cpu_state (const CPUState *cs,vaddr *pc, +vaddr *cs_base,int *flags) +{ +OpenRISCCPU *cpu =OPENRISC_CPU (cs); + + *pc = cpu->env.pc; + *cs_base =0 ; +/* D_FLAG -- branch instruction exception */ + *flags = (cpu->env.flags &D_FLAG ); +} +static int openrisc_cpu_mmu_index (const CPUState *cs) {OpenRISCCPU *cpu =OPENRISC_CPU (cs);
@@ -174,6 +185,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data) cc->dump_state = openrisc_cpu_dump_state; cc->mmu_index = openrisc_cpu_mmu_index; cc->set_pc = openrisc_cpu_set_pc; + cc->get_tb_cpu_state = openrisc_cpu_get_tb_cpu_state; cc->gdb_read_register = openrisc_cpu_gdb_read_register; cc->gdb_write_register = openrisc_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY
target-openrisc/cpu.h +0 -10
@@ -399,16 +399,6 @@ static inline CPUOpenRISCState *cpu_init(const char *cpu_model)#include "exec/cpu-all.h" -static inline void cpu_get_tb_cpu_state (CPUOpenRISCState *env, -target_ulong *pc, -target_ulong *cs_base,int *flags) -{ - *pc = env->pc; - *cs_base =0 ; -/* D_FLAG -- branch instruction exception */ - *flags = (env->flags &D_FLAG ); -} -#define CPU_INTERRUPT_TIMER CPU_INTERRUPT_TGT_INT_0#include "exec/exec-all.h"
target-ppc/cpu.h +0 -8
@@ -2015,14 +2015,6 @@ static inline void cpu_write_xer(CPUPPCState *env, target_ulong xer) env->xer = xer & ~((1u <<XER_SO ) | (1u <<XER_OV ) | (1u <<XER_CA )); } -static inline void cpu_get_tb_cpu_state (CPUPPCState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) -{ - *pc = env->nip; - *cs_base =0 ; - *flags = env->hflags; -} -#if !defined(CONFIG_USER_ONLY )static inline int booke206_tlbm_id (CPUPPCState *env,ppcmas_tlb_t *tlbm) {
target-ppc/translate_init.c +11 -0
@@ -8437,6 +8437,16 @@ static void ppc_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.nip = value; } +static void ppc_cpu_get_tb_cpu_state (const CPUState *cs,vaddr *pc, +vaddr *cs_base,int *flags) +{ +PowerPCCPU *cpu =POWERPC_CPU (cs); + + *pc = cpu->env.nip; + *cs_base =0 ; + *flags = cpu->env.hflags; +} +static int ppc_cpu_mmu_index (const CPUState *cs) {PowerPCCPU *cpu =POWERPC_CPU (cs);
@@ -8582,6 +8592,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->dump_statistics = ppc_cpu_dump_statistics; cc->mmu_index = ppc_cpu_mmu_index; cc->set_pc = ppc_cpu_set_pc; + cc->get_tb_cpu_state = ppc_cpu_get_tb_cpu_state; cc->gdb_read_register = ppc_cpu_gdb_read_register; cc->gdb_write_register = ppc_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY
target-s390x/cpu.c +13 -0
@@ -65,6 +65,18 @@ static void s390_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.psw.addr = value; } +static void s390_cpu_get_tb_cpu_state (const CPUState *cs,vaddr *pc, +vaddr *cs_base,int *flags) +{ +S390CPU *cpu =S390_CPU (cs); +CPUS390XState *env = &cpu->env; + + *pc = env->psw.addr; + *cs_base =0 ; + *flags = ((env->psw.mask >>32 ) & ~FLAG_MASK_CC ) | + ((env->psw.mask &PSW_MASK_32 ) ?FLAG_MASK_32 :0 ); +} +static int s390_cpu_mmu_index (const CPUState *cs) {S390CPU *cpu =S390_CPU (cs);
@@ -242,6 +254,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->dump_state = s390_cpu_dump_state; cc->mmu_index = s390_cpu_mmu_index; cc->set_pc = s390_cpu_set_pc; + cc->get_tb_cpu_state = s390_cpu_get_tb_cpu_state; cc->gdb_read_register = s390_cpu_gdb_read_register; cc->gdb_write_register = s390_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY
target-s390x/cpu.h +0 -9
@@ -273,15 +273,6 @@ typedef struct CPUS390XState {#define FLAG_MASK_64 (PSW_MASK_64 >> 32)#define FLAG_MASK_32 0x00001000 -static inline void cpu_get_tb_cpu_state (CPUS390XState * env,target_ulong *pc, -target_ulong *cs_base,int *flags) -{ - *pc = env->psw.addr; - *cs_base =0 ; - *flags = ((env->psw.mask >>32 ) & ~FLAG_MASK_CC ) | - ((env->psw.mask &PSW_MASK_32 ) ?FLAG_MASK_32 :0 ); -} -/* While the PoO talks about ILC (a number between 1-3) what is actually stored in LowCore is shifted left one bit (an even between 2-6). As this is the actual length of the insn and therefore more useful, that
target-sh4/cpu.c +17 -0
@@ -31,6 +31,22 @@ static void superh_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static void superh_cpu_get_tb_cpu_state (const CPUState *cs,vaddr *pc, +vaddr *cs_base,int *flags) +{ +SuperHCPU *cpu =SUPERH_CPU (cs); +CPUSH4State *env = &cpu->env; + + *pc = env->pc; + *cs_base =0 ; + *flags = (env->flags & (DELAY_SLOT |DELAY_SLOT_CONDITIONAL | +DELAY_SLOT_TRUE |DELAY_SLOT_CLEARME ))/* Bits 0-3 */ + | (env->fpscr & (FPSCR_FR |FPSCR_SZ |FPSCR_PR ))/* Bits 19-21 */ + | (env->sr & (SR_MD |SR_RB ))/* Bits 29-30 */ + | (env->sr &SR_FD )/* Bit 15 */ + | (env->movcal_backup ?TB_FLAG_PENDING_MOVCA :0 );/* Bit 4 */ +} +static void superh_cpu_synchronize_from_tb (CPUState *cs,TranslationBlock *tb) {SuperHCPU *cpu =SUPERH_CPU (cs);
@@ -300,6 +316,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) cc->dump_state = superh_cpu_dump_state; cc->mmu_index = superh_cpu_mmu_index; cc->set_pc = superh_cpu_set_pc; + cc->get_tb_cpu_state = superh_cpu_get_tb_cpu_state; cc->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;
target-sh4/cpu.h +0 -13
@@ -335,19 +335,6 @@ static inline int cpu_ptel_pr (uint32_t ptel)#define TB_FLAG_PENDING_MOVCA (1 << 4) -static inline void cpu_get_tb_cpu_state (CPUSH4State *env,target_ulong *pc, -target_ulong *cs_base,int *flags) -{ - *pc = env->pc; - *cs_base =0 ; - *flags = (env->flags & (DELAY_SLOT |DELAY_SLOT_CONDITIONAL - |DELAY_SLOT_TRUE |DELAY_SLOT_CLEARME ))/* Bits 0- 3 */ - | (env->fpscr & (FPSCR_FR |FPSCR_SZ |FPSCR_PR ))/* Bits 19-21 */ - | (env->sr & (SR_MD |SR_RB ))/* Bits 29-30 */ - | (env->sr &SR_FD )/* Bit 15 */ - | (env->movcal_backup ?TB_FLAG_PENDING_MOVCA :0 );/* Bit 4 */ -} -#include "exec/exec-all.h" #endif /* _CPU_SH4_H */
target-sparc/cpu.c +31 -0
@@ -731,6 +731,36 @@ static void sparc_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.npc = value +4 ; } +static void sparc_cpu_get_tb_cpu_state (const CPUState *cs,vaddr *pc, +vaddr *cs_base,int *flags) +{ +SPARCCPU *cpu =SPARC_CPU (cs); +CPUSPARCState *env = &cpu->env; + + *pc = env->pc; + *cs_base = env->npc; +#ifdef TARGET_SPARC64 +/* AM . Combined FPU enable bits . PRIV . DMMU enabled . IMMU enabled */ + *flags = (env->pstate &PS_PRIV )/* 2 */ + | ((env->lsu & (DMMU_E |IMMU_E )) >>2 )/* 1, 0 */ + | ((env->tl &0xff ) <<8 ) + | (env->dmmu.mmu_primary_context <<16 );/* 16... */ +if (env->pstate &PS_AM ) { + *flags |=TB_FLAG_AM_ENABLED ; + } +if ((env->def->features &CPU_FEATURE_FLOAT ) && (env->pstate &PS_PEF ) + && (env->fprs &FPRS_FEF )) { + *flags |=TB_FLAG_FPU_ENABLED ; + } +#else +/* FPU enable . Supervisor */ + *flags = env->psrs; +if ((env->def->features &CPU_FEATURE_FLOAT ) && env->psref) { + *flags |=TB_FLAG_FPU_ENABLED ; + } +#endif +} +static void sparc_cpu_synchronize_from_tb (CPUState *cs,TranslationBlock *tb) {SPARCCPU *cpu =SPARC_CPU (cs);
@@ -823,6 +853,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data)#endif cc->mmu_index = sparc_cpu_mmu_index; cc->set_pc = sparc_cpu_set_pc; + cc->get_tb_cpu_state = sparc_cpu_get_tb_cpu_state; cc->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;
target-sparc/cpu.h +0 -27
@@ -683,33 +683,6 @@ trap_state* cpu_tsptr(CPUSPARCState* env);#define TB_FLAG_FPU_ENABLED (1 << 4)#define TB_FLAG_AM_ENABLED (1 << 5) -static inline void cpu_get_tb_cpu_state (CPUSPARCState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) -{ - *pc = env->pc; - *cs_base = env->npc; -#ifdef TARGET_SPARC64 -// AM . Combined FPU enable bits . PRIV . DMMU enabled . IMMU enabled - *flags = (env->pstate &PS_PRIV )/* 2 */ - | ((env->lsu & (DMMU_E |IMMU_E )) >>2 )/* 1, 0 */ - | ((env->tl &0xff ) <<8 ) - | (env->dmmu.mmu_primary_context <<16 );/* 16... */ -if (env->pstate &PS_AM ) { - *flags |=TB_FLAG_AM_ENABLED ; - } -if ((env->def->features &CPU_FEATURE_FLOAT ) && (env->pstate &PS_PEF ) - && (env->fprs &FPRS_FEF )) { - *flags |=TB_FLAG_FPU_ENABLED ; - } -#else -// FPU enable . Supervisor - *flags = env->psrs; -if ((env->def->features &CPU_FEATURE_FLOAT ) && env->psref) { - *flags |=TB_FLAG_FPU_ENABLED ; - } -#endif -} -static inline bool tb_fpu_enabled (int tb_flags) {#if defined(CONFIG_USER_ONLY )
target-unicore32/cpu.c +14 -0
@@ -23,6 +23,19 @@ static void uc32_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.regs[31 ] = value; } +static void uc32_cpu_get_tb_cpu_state (const CPUState *cs,vaddr *pc, +vaddr *cs_base,int *flags) +{ +UniCore32CPU *cpu =UNICORE32_CPU (cs); + + *pc = cpu->env.regs[31 ]; + *cs_base =0 ; + *flags =0 ; +if ((cpu->env.uncached_asr &ASR_M ) !=ASR_MODE_USER ) { + *flags |= (1 <<6 ); + } +} +static int uc32_cpu_mmu_index (const CPUState *cs) {UniCore32CPU *cpu =UNICORE32_CPU (cs);
@@ -156,6 +169,7 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data) cc->dump_state = uc32_cpu_dump_state; cc->mmu_index = uc32_cpu_mmu_index; cc->set_pc = uc32_cpu_set_pc; + cc->get_tb_cpu_state = uc32_cpu_get_tb_cpu_state;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = uc32_cpu_get_phys_page_debug;#endif
target-unicore32/cpu.h +0 -11
@@ -142,17 +142,6 @@ int uc32_cpu_handle_mmu_fault(CPUUniCore32State *env, target_ulong address, int#include "cpu-qom.h" #include "exec/exec-all.h" -static inline void cpu_get_tb_cpu_state (CPUUniCore32State *env,target_ulong *pc, -target_ulong *cs_base,int *flags) -{ - *pc = env->regs[31 ]; - *cs_base =0 ; - *flags =0 ; -if ((env->uncached_asr &ASR_M ) !=ASR_MODE_USER ) { - *flags |= (1 <<6 ); - } -} -void uc32_translate_init (void );void switch_mode (CPUUniCore32State *,int );
target-xtensa/cpu.c +34 -0
@@ -40,6 +40,39 @@ static void xtensa_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static void xtensa_cpu_get_tb_cpu_state (const CPUState *cs,vaddr *pc, +vaddr *cs_base,int *flags) +{ +XtensaCPU *cpu =XTENSA_CPU (cs); +CPUXtensaState *env = &cpu->env; + + *pc = env->pc; + *cs_base =0 ; + *flags =0 ; + *flags |=xtensa_get_ring (env); +if (env->sregs[PS ] &PS_EXCM ) { + *flags |=XTENSA_TBFLAG_EXCM ; + } +if (xtensa_option_enabled (env->config,XTENSA_OPTION_EXTENDED_L32R ) && + (env->sregs[LITBASE ] &1 )) { + *flags |=XTENSA_TBFLAG_LITBASE ; + } +if (xtensa_option_enabled (env->config,XTENSA_OPTION_DEBUG )) { +if (xtensa_get_cintlevel (env) < env->config->debug_level) { + *flags |=XTENSA_TBFLAG_DEBUG ; + } +if (xtensa_get_cintlevel (env) < env->sregs[ICOUNTLEVEL ]) { + *flags |=XTENSA_TBFLAG_ICOUNT ; + } + } +if (xtensa_option_enabled (env->config,XTENSA_OPTION_COPROCESSOR )) { + *flags |= env->sregs[CPENABLE ] <<XTENSA_TBFLAG_CPENABLE_SHIFT ; + } +if (cs->singlestep_enabled && env->exception_taken) { + *flags |=XTENSA_TBFLAG_EXCEPTION ; + } +} +static int xtensa_cpu_mmu_index (const CPUState *cs) {XtensaCPU *cpu =XTENSA_CPU (cs);
@@ -151,6 +184,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data) cc->dump_state = xtensa_cpu_dump_state; cc->mmu_index = xtensa_cpu_mmu_index; cc->set_pc = xtensa_cpu_set_pc; + cc->get_tb_cpu_state = xtensa_cpu_get_tb_cpu_state; cc->gdb_read_register = xtensa_cpu_gdb_read_register; cc->gdb_write_register = xtensa_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY
target-xtensa/cpu.h +0 -30
@@ -481,36 +481,6 @@ static inline xtensa_tlb_entry *xtensa_tlb_get_entry(CPUXtensaState *env,#define XTENSA_TBFLAG_CPENABLE_SHIFT 6#define XTENSA_TBFLAG_EXCEPTION 0x4000 -static inline void cpu_get_tb_cpu_state (CPUXtensaState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) -{ - *pc = env->pc; - *cs_base =0 ; - *flags =0 ; - *flags |=xtensa_get_ring (env); -if (env->sregs[PS ] &PS_EXCM ) { - *flags |=XTENSA_TBFLAG_EXCM ; - } -if (xtensa_option_enabled (env->config,XTENSA_OPTION_EXTENDED_L32R ) && - (env->sregs[LITBASE ] &1 )) { - *flags |=XTENSA_TBFLAG_LITBASE ; - } -if (xtensa_option_enabled (env->config,XTENSA_OPTION_DEBUG )) { -if (xtensa_get_cintlevel (env) < env->config->debug_level) { - *flags |=XTENSA_TBFLAG_DEBUG ; - } -if (xtensa_get_cintlevel (env) < env->sregs[ICOUNTLEVEL ]) { - *flags |=XTENSA_TBFLAG_ICOUNT ; - } - } -if (xtensa_option_enabled (env->config,XTENSA_OPTION_COPROCESSOR )) { - *flags |= env->sregs[CPENABLE ] <<XTENSA_TBFLAG_CPENABLE_SHIFT ; - } -if (ENV_GET_CPU (env)->singlestep_enabled && env->exception_taken) { - *flags |=XTENSA_TBFLAG_EXCEPTION ; - } -} -#include "exec/cpu-all.h" #include "exec/exec-all.h"
translate-all.c +12 -6
@@ -1011,11 +1011,12 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end,PageDesc *p;int n;#ifdef TARGET_HAS_PRECISE_SMC +CPUClass *cc =NULL ;int current_tb_not_found = is_cpu_write_access;TranslationBlock *current_tb =NULL ;int current_tb_modified =0 ; -target_ulong current_pc =0 ; -target_ulong current_cs_base =0 ; +vaddr current_pc =0 ; +vaddr current_cs_base =0 ;int current_flags =0 ;#endif /* TARGET_HAS_PRECISE_SMC */
@@ -1032,6 +1033,9 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end,#if defined(TARGET_HAS_PRECISE_SMC ) || !defined(CONFIG_USER_ONLY )if (cpu !=NULL ) { env = cpu->env_ptr; +#ifdef TARGET_HAS_PRECISE_SMC + cc =CPU_GET_CLASS (cpu); +#endif }#endif
@@ -1073,7 +1077,7 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end, current_tb_modified =1 ;cpu_restore_state_from_tb (current_tb, env, env->mem_io_pc); -cpu_get_tb_cpu_state (env, ¤t_pc, ¤t_cs_base, + cc->get_tb_cpu_state (cpu, ¤t_pc, ¤t_cs_base, ¤t_flags); }#endif /* TARGET_HAS_PRECISE_SMC */
@@ -1157,10 +1161,11 @@ static void tb_invalidate_phys_page(tb_page_addr_t addr,#ifdef TARGET_HAS_PRECISE_SMC TranslationBlock *current_tb =NULL ;CPUState *cpu = current_cpu; +CPUClass *cc =NULL ;CPUArchState *env =NULL ;int current_tb_modified =0 ; -target_ulong current_pc =0 ; -target_ulong current_cs_base =0 ; +vaddr current_pc =0 ; +vaddr current_cs_base =0 ;int current_flags =0 ;#endif
@@ -1176,6 +1181,7 @@ static void tb_invalidate_phys_page(tb_page_addr_t addr, }if (cpu !=NULL ) { env = cpu->env_ptr; + cc =CPU_GET_CLASS (cpu); }#endif while (tb !=NULL ) {
@@ -1192,7 +1198,7 @@ static void tb_invalidate_phys_page(tb_page_addr_t addr, current_tb_modified =1 ;cpu_restore_state_from_tb (current_tb, env, pc); -cpu_get_tb_cpu_state (env, ¤t_pc, ¤t_cs_base, + cc->get_tb_cpu_state (cpu, ¤t_pc, ¤t_cs_base, ¤t_flags); }#endif /* TARGET_HAS_PRECISE_SMC */
Signature · 1 line
1.8.1.4
Paolo Bonzini
maintainerRe: [Qemu-devel] [RFC qom-cpu 03/41] cpu: Turn cpu_get_tb_cpu_state() into a CPUClass hook
Il 04/09/2013 11:04, Andreas Färber ha scritto:
Quoted 4 lines
static inline TranslationBlock *tb_find_fast(CPUArchState *env) {
cpu-exec.c +2
-0+CPUState *cpu =ENV_GET_CPU (env); +CPUClass *cc =CPU_GET_CLASS (cpu);
cpu-exec.c static TranslationBlock *tb_find_slow(CPUArchState *env, · line 165
Quoted 10 lines
cpu-exec.c +2
-2TranslationBlock *tb; -target_ulong cs_base, pc; +vaddr cs_base, pc;int flags;/* we record a subset of the CPU state. It will always be the same before a given translated block is executed. */ -cpu_get_tb_cpu_state (env, &pc, &cs_base, &flags); + cc->get_tb_cpu_state (cpu, &pc, &cs_base, &flags);
I'm afraid you cannot turn inline functions into indirect calls like this in hot paths.
One alternative would be to hoist the function call to the beginning of cpu_exec, and ensure that any place that modifies the result calls cpu_exit. It may be a problem for SPARC's npc stuff, for which I have no idea how it works.
Another is to change cpu-exec.c into a file that is #included by target-*/helper.c or something like that. This way cpu-exec.c can still use the inline functions.
Paolo
Re: [Qemu-devel] [RFC qom-cpu 03/41] cpu: Turn cpu_get_tb_cpu_state() into a CPUClass hook
Am 04.09.2013 12:26, schrieb Paolo Bonzini:
Quoted 16 lines
Il 04/09/2013 11:04, Andreas Färber ha scritto:
Quoted 4 lines
static inline TranslationBlock *tb_find_fast(CPUArchState *env) {
cpu-exec.c +2
-0+CPUState *cpu =ENV_GET_CPU (env); +CPUClass *cc =CPU_GET_CLASS (cpu);cpu-exec.c static TranslationBlock *tb_find_slow(CPUArchState *env, · line 165
Quoted 10 lines
cpu-exec.c +2
-2TranslationBlock *tb; -target_ulong cs_base, pc; +vaddr cs_base, pc;int flags;/* we record a subset of the CPU state. It will always be the same before a given translated block is executed. */ -cpu_get_tb_cpu_state (env, &pc, &cs_base, &flags); + cc->get_tb_cpu_state (cpu, &pc, &cs_base, &flags);
Quoted 7 lines
I'm afraid you cannot turn inline functions into indirect calls like this in hot paths.
One alternative would be to hoist the function call to the beginning of
cpu_exec, and ensure that any place that modifies the result callscpu_exit. It may be a problem for SPARC's npc stuff, for which I have no idea how it works.
Sorry, you lost me here...
Quoted 3 lines
Another is to change
cpu-exec.cinto a file that is #included bytarget-*/helper.cor something like that. This waycpu-exec.ccan still use the inline functions.
I don't see how that would help with compiling multiple CPU types into one executable. A common CPU struct type is needed to compile the core CPU code once, which in turn requires dispatching for target-specific bits, such as this one or previously gdbstub and TBD monitor.
Combining only targets with target_ulong of the same size and identical endianness is a restriction we can accept, I think - examples include 32-bit ARM+SH4A, ARM+MicroBlaze, ARM+Hexagon, ARM+Epiphany.
For performance reasons I have been careful not to have an, e.g., cpu_get_tb_cpu_state() wrapper that calls CPU_GET_CLASS() each time. Many of the "cpu" variables added are being cleaned up later in the series by argument propagation. And in placement of variables requiring CPU() cast I have been careful to place them depending on where they are/will be actually used rather than always placing them at the top. But if behavior depends on the CPU type, then it cannot be a global function - cpu.h as-is is a problem and needs to be broken up.
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Paolo Bonzini
maintainerRe: [Qemu-devel] [RFC qom-cpu 03/41] cpu: Turn cpu_get_tb_cpu_state() into a CPUClass hook
Il 04/09/2013 13:02, Andreas Färber ha scritto:
Quoted 11 lines
Am 04.09.2013 12:26, schrieb Paolo Bonzini:
Quoted 3 lines
Another is to change
cpu-exec.cinto a file that is #included bytarget-*/helper.cor something like that. This waycpu-exec.ccan still use the inline functions.I don't see how that would help with compiling multiple CPU types into one executable.
A common CPU struct type is needed to compile the core
CPU code once, which in turn requires dispatching for target-specific bits, such as this one or previously gdbstub and TBD monitor.
cpu-exec.c is all but common to the various targets. You could make cpu_exec() itself a CPU method. Then calls to cpu_get_tb_cpu_state() from cpu_exec() can remain inlined instead of being virtual calls.
Not all files have to be compiled "per target", probably only cputlb.c and cpu-exec.c.
Paolo
Quoted 15 lines
Combining only targets with
target_ulongof the same size and identical endianness is a restriction we can accept, I think - examples include 32-bit ARM+SH4A, ARM+MicroBlaze, ARM+Hexagon, ARM+Epiphany.For performance reasons I have been careful not to have an, e.g.,
cpu_get_tb_cpu_state()wrapper that callsCPU_GET_CLASS()each time. Many of the "cpu" variables added are being cleaned up later in the series by argument propagation. And in placement of variables requiringCPU()cast I have been careful to place them depending on where they are/will be actually used rather than always placing them at the top. But if behavior depends on the CPU type, then it cannot be a global function -cpu.has-is is a problem and needs to be broken up.Andreas
RFC 4/41 cpu: Turn cpu_handle_mmu_fault() into a CPUClass hook
In reply to Andreas Färber--- include/qom/cpu.h | 3 +++ target-alpha/cpu.c | 4 +++- target-alpha/cpu.h | 5 ++--- target-alpha/helper.c | 12 ++++++++---- target-alpha/mem_helper.c | 3 ++- target-arm/cpu.c | 4 +++- target-arm/cpu.h | 5 ++--- target-arm/helper.c | 13 +++++++++---- target-arm/op_helper.c | 3 ++- target-cris/cpu.c | 4 +++- target-cris/cpu.h | 3 +-- target-cris/helper.c | 24 +++++++++++++----------- target-cris/op_helper.c | 3 ++- target-i386/cpu.c | 4 +++- target-i386/cpu.h | 3 +-- target-i386/helper.c | 19 ++++++++++++------- target-i386/mem_helper.c | 3 ++- target-lm32/cpu.c | 4 +++- target-lm32/cpu.h | 3 +-- target-lm32/helper.c | 4 +++- target-lm32/op_helper.c | 3 ++- target-m68k/cpu.c | 4 +++- target-m68k/cpu.h | 3 +-- target-m68k/helper.c | 17 ++++++++++------- target-m68k/op_helper.c | 3 ++- target-microblaze/cpu.c | 4 +++- target-microblaze/cpu.h | 3 +-- target-microblaze/helper.c | 14 ++++++++------ target-microblaze/op_helper.c | 3 ++- target-mips/cpu.c | 4 +++- target-mips/cpu.h | 5 ++--- target-mips/helper.c | 15 +++++++++------ target-mips/op_helper.c | 3 ++- target-moxie/cpu.c | 4 +++- target-moxie/cpu.h | 2 +- target-moxie/helper.c | 19 +++++++++++-------- target-openrisc/cpu.c | 4 +++- target-openrisc/cpu.h | 4 +--- target-openrisc/mmu.c | 14 +++++++------- target-openrisc/mmu_helper.c | 3 ++- target-ppc/cpu.h | 4 ++-- target-ppc/translate_init.c | 4 +++- target-ppc/user_only_helper.c | 6 ++++-- target-s390x/cpu.c | 4 +++- target-s390x/cpu.h | 5 ++--- target-s390x/helper.c | 20 ++++++++++++-------- target-s390x/mem_helper.c | 3 ++- target-sh4/cpu.c | 4 +++- target-sh4/cpu.h | 5 ++--- target-sh4/helper.c | 13 +++++++++---- target-sh4/op_helper.c | 3 ++- target-sparc/cpu.c | 4 +++- target-sparc/cpu.h | 3 +-- target-sparc/ldst_helper.c | 3 ++- target-sparc/mmu_helper.c | 18 ++++++++++++------ target-unicore32/cpu.c | 4 +++- target-unicore32/cpu.h | 5 ++--- target-unicore32/helper.c | 5 ++++- target-unicore32/op_helper.c | 3 ++- target-unicore32/softmmu.c | 6 ++++-- user-exec.c | 9 +++++++-- 61 files changed, 238 insertions(+), 150 deletions(-)
include/qom/cpu.h +3 -0
@@ -84,6 +84,7 @@ struct TranslationBlock;* #TranslationBlock. * @synchronize_from_tb: Callback for synchronizing state from a TCG * #TranslationBlock. +* @handle_mmu_fault: Callback for handling an MMU fault. * @get_phys_page_debug: Callback for obtaining a physical address. * @gdb_read_register: Callback for letting GDB read a register. * @gdb_write_register: Callback for letting GDB write a register.
@@ -120,6 +121,8 @@ typedef struct CPUClass {void (*get_tb_cpu_state)(const CPUState *cpu,vaddr *pc,vaddr *cs_base,int *flags);void (*synchronize_from_tb)(CPUState *cpu,struct TranslationBlock *tb); +int (*handle_mmu_fault)(CPUState *cpu,vaddr address,int rw, +int mmu_index);hwaddr (*get_phys_page_debug)(CPUState *cpu,vaddr addr);int (*gdb_read_register)(CPUState *cpu,uint8_t *buf,int reg);int (*gdb_write_register)(CPUState *cpu,uint8_t *buf,int reg);
target-alpha/cpu.c +3 -1
@@ -330,7 +330,9 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) cc->get_tb_cpu_state = alpha_cpu_get_tb_cpu_state; cc->gdb_read_register = alpha_cpu_gdb_read_register; cc->gdb_write_register = alpha_cpu_gdb_write_register; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = alpha_cpu_handle_mmu_fault; +#else cc->do_unassigned_access = alpha_cpu_unassigned_access; cc->get_phys_page_debug = alpha_cpu_get_phys_page_debug; dc->vmsd = &vmstate_alpha_cpu;
target-alpha/cpu.h +2 -3
@@ -435,9 +435,8 @@ int cpu_alpha_exec(CPUAlphaState *s);is returned if the signal was handled by the virtual CPU. */ int cpu_alpha_signal_handler (int host_signum,void *pinfo,void *puc); -int cpu_alpha_handle_mmu_fault (CPUAlphaState *env,uint64_t address,int rw, -int mmu_idx); -#define cpu_handle_mmu_fault cpu_alpha_handle_mmu_fault +int alpha_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw, +int mmu_idx);void do_restore_state (CPUAlphaState *,uintptr_t retaddr); void QEMU_NORETURN dynamic_excp(CPUAlphaState *, uintptr_t, int, int); void QEMU_NORETURN arith_excp(CPUAlphaState *, uintptr_t, int, uint64_t);
target-alpha/helper.c +8 -4
@@ -168,11 +168,13 @@ void helper_store_fpcr(CPUAlphaState *env, uint64_t val) }#if defined(CONFIG_USER_ONLY ) -int cpu_alpha_handle_mmu_fault (CPUAlphaState *env,target_ulong address, +int alpha_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw,int mmu_idx) { - env->exception_index =EXCP_MMFAULT ; - env->trap_arg0 = address; +AlphaCPU *cpu =ALPHA_CPU (cs); + + cpu->env.exception_index =EXCP_MMFAULT ; + cpu->env.trap_arg0 = address;return 1 ; }#else
@@ -325,9 +327,11 @@ hwaddr alpha_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)return (fail >=0 ?-1 : phys); } -int cpu_alpha_handle_mmu_fault (CPUAlphaState *env,target_ulong addr,int rw, +int alpha_cpu_handle_mmu_fault (CPUState *cs,vaddr addr,int rw,int mmu_idx) { +AlphaCPU *cpu =ALPHA_CPU (cs); +CPUAlphaState *env = &cpu->env;target_ulong phys;int prot, fail;
target-alpha/mem_helper.c +2 -1
@@ -145,9 +145,10 @@ void alpha_cpu_unassigned_access(CPUState *cs, hwaddr addr,void tlb_fill (CPUAlphaState *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +AlphaCPU *cpu =alpha_env_get_cpu (env);int ret; - ret =cpu_alpha_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =alpha_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (unlikely (ret !=0 )) {if (retaddr) {cpu_restore_state (env, retaddr);
target-arm/cpu.c +3 -1
@@ -938,7 +938,9 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->get_tb_cpu_state = arm_cpu_get_tb_cpu_state; cc->gdb_read_register = arm_cpu_gdb_read_register; cc->gdb_write_register = arm_cpu_gdb_write_register; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = arm_cpu_handle_mmu_fault; +#else cc->get_phys_page_debug = arm_cpu_get_phys_page_debug; cc->vmsd = &vmstate_arm_cpu;#endif
target-arm/cpu.h +2 -3
@@ -266,9 +266,8 @@ uint32_t do_arm_semihosting(CPUARMState *env);is returned if the signal was handled by the virtual CPU. */ int cpu_arm_signal_handler (int host_signum,void *pinfo,void *puc); -int cpu_arm_handle_mmu_fault (CPUARMState *env,target_ulong address,int rw, -int mmu_idx); -#define cpu_handle_mmu_fault cpu_arm_handle_mmu_fault +int arm_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw, +int mmu_idx);#define CPSR_M (0x1f)#define CPSR_T (1 << 5)
target-arm/helper.c +9 -4
@@ -2078,9 +2078,12 @@ void arm_cpu_do_interrupt(CPUState *cs) env->exception_index =-1 ; } -int cpu_arm_handle_mmu_fault (CPUARMState *env,target_ulong address,int rw, -int mmu_idx) +int arm_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw, +int mmu_idx) { +ARMCPU *cpu =ARM_CPU (cs); +CPUARMState *env = &cpu->env; +if (rw ==2 ) { env->exception_index =EXCP_PREFETCH_ABORT ; env->cp15.c6_insn = address;
@@ -3026,9 +3029,11 @@ static inline int get_phys_addr(CPUARMState *env, uint32_t address, } } -int cpu_arm_handle_mmu_fault (CPUARMState *env,target_ulong address, -int access_type,int mmu_idx) +int arm_cpu_handle_mmu_fault (CPUState *cs,vaddr address, +int access_type,int mmu_idx) { +ARMCPU *cpu =ARM_CPU (cs); +CPUARMState *env = &cpu->env;hwaddr phys_addr;target_ulong page_size;int prot;
target-arm/op_helper.c +2 -1
@@ -74,9 +74,10 @@ uint32_t HELPER(neon_tbl)(CPUARMState *env, uint32_t ireg, uint32_t def,void tlb_fill (CPUARMState *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +ARMCPU *cpu =arm_env_get_cpu (env);int ret; - ret =cpu_arm_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =arm_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (unlikely (ret)) {if (retaddr) {/* now we have a real cpu fault */
target-cris/cpu.c +3 -1
@@ -290,7 +290,9 @@ static void cris_cpu_class_init(ObjectClass *oc, void *data) cc->get_tb_cpu_state = cris_cpu_get_tb_cpu_state; cc->gdb_read_register = cris_cpu_gdb_read_register; cc->gdb_write_register = cris_cpu_gdb_write_register; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = cris_cpu_handle_mmu_fault; +#else cc->get_phys_page_debug = cris_cpu_get_phys_page_debug;#endif
target-cris/cpu.h +1 -2
@@ -239,9 +239,8 @@ static inline CPUCRISState *cpu_init(const char *cpu_model)#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 -int cpu_cris_handle_mmu_fault (CPUCRISState *env,target_ulong address,int rw, +int cris_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw,int mmu_idx); -#define cpu_handle_mmu_fault cpu_cris_handle_mmu_fault/* Support function regs. */ #define SFR_RW_GC_CFG 0][0
target-cris/helper.c +13 -11
@@ -50,14 +50,14 @@ void crisv10_cpu_do_interrupt(CPUState *cs)cris_cpu_do_interrupt (cs); } -int cpu_cris_handle_mmu_fault (CPUCRISState * env,target_ulong address,int rw, +int cris_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw,int mmu_idx) { -CRISCPU *cpu =cris_env_get_cpu (env); +CRISCPU *cpu =CRIS_CPU (cs); - env->exception_index =0xaa ; - env->pregs[PR_EDA ] = address; -cpu_dump_state (CPU (cpu), stderr, fprintf,0 ); + cpu->env.exception_index =0xaa ; + cpu->env.pregs[PR_EDA ] = address; +cpu_dump_state (cs, stderr, fprintf,0 );return 1 ; }
@@ -73,23 +73,25 @@ static void cris_shift_ccs(CPUCRISState *env) env->pregs[PR_CCS ] = ccs; } -int cpu_cris_handle_mmu_fault (CPUCRISState *env,target_ulong address,int rw, +int cris_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw,int mmu_idx) { -D (CPUState *cpu =CPU (cris_env_get_cpu (env))); +CRISCPU *cpu =CRIS_CPU (cs); +CPUCRISState *env = &cpu->env;struct cris_mmu_result res;int prot, miss;int r =-1 ;target_ulong phy; -D (printf ("%s addr=%x pc=%x rw=%x\n" , __func__, address, env->pc, rw)); +D (printf ("%s addr=%" VADDR_PRIx" pc=%x rw=%x\n" , + __func__, address, env->pc, rw)); miss =cris_mmu_translate (&res, env, address &TARGET_PAGE_MASK , rw, mmu_idx,0 );if (miss) {if (env->exception_index ==EXCP_BUSFAULT ) {cpu_abort (env,"CRIS: Illegal recursive bus fault." -"addr=%x rw=%d\n" , +"addr=%" VADDR_PRIx" rw=%d\n" , address, rw); }
@@ -109,8 +111,8 @@ int cpu_cris_handle_mmu_fault(CPUCRISState *env, target_ulong address, int rw, r =0 ; }if (r >0 ) { -D_LOG ("%s returns %d irqreq=%x addr=%x phy=%x vec=%x pc=%x\n" , - __func__, r, cpu->interrupt_request, address, res.phy, +D_LOG ("%s returns %d irqreq=%x addr=%" VADDR_PRIx" phy=%x vec=%x" +" pc=%x\n" , __func__, r, cs->interrupt_request, address, res.phy, res.bf_vec, env->pc); }return r;
target-cris/op_helper.c +2 -1
@@ -57,11 +57,12 @@void tlb_fill (CPUCRISState *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +CRISCPU *cpu =cris_env_get_cpu (env);int ret;D_LOG ("%s pc=%x tpc=%x ra=%p\n" , __func__, env->pc, env->pregs[PR_EDA ], (void *)retaddr); - ret =cpu_cris_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =cris_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (unlikely (ret)) {if (retaddr) {/* now we have a real cpu fault */
target-i386/cpu.c +3 -1
@@ -2743,7 +2743,9 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) 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 +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = x86_cpu_handle_mmu_fault; +#else cc->get_memory_mapping = x86_cpu_get_memory_mapping; cc->get_phys_page_debug = x86_cpu_get_phys_page_debug; cc->write_elf64_note = x86_cpu_write_elf64_note;
target-i386/cpu.h +1 -2
@@ -1042,9 +1042,8 @@ void host_cpuid(uint32_t function, uint32_t count, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx);/* helper.c */ -int cpu_x86_handle_mmu_fault (CPUX86State *env,target_ulong addr, +int x86_cpu_handle_mmu_fault (CPUState *cpu,vaddr addr,int is_write,int mmu_idx); -#define cpu_handle_mmu_fault cpu_x86_handle_mmu_faultvoid x86_cpu_set_a20 (X86CPU *cpu,int a20_state);static inline bool hw_local_breakpoint_enabled (unsigned long dr7,int index)
target-i386/helper.c +12 -7
@@ -485,9 +485,12 @@ void cpu_x86_update_cr4(CPUX86State *env, uint32_t new_cr4)#if defined(CONFIG_USER_ONLY ) -int cpu_x86_handle_mmu_fault (CPUX86State *env,target_ulong addr, +int x86_cpu_handle_mmu_fault (CPUState *cs,vaddr addr,int is_write,int mmu_idx) { +X86CPU *cpu =X86_CPU (cs); +CPUX86State *env = &cpu->env; +/* user mode only emulation */ is_write &=1 ; env->cr[2 ] = addr;
@@ -508,13 +511,15 @@ int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr,# endif /* return value: --1 = cannot handle fault -0 = nothing more to do -1 = generate PF fault -*/ -int cpu_x86_handle_mmu_fault (CPUX86State *env,target_ulong addr, +* -1 = cannot handle fault +* 0 = nothing more to do +* 1 = generate PF fault +*/ +int x86_cpu_handle_mmu_fault (CPUState *cs,vaddr addr,int is_write1,int mmu_idx) { +X86CPU *cpu =X86_CPU (cs); +CPUX86State *env = &cpu->env;uint64_t ptep, pte;target_ulong pde_addr, pte_addr;int error_code, is_dirty, prot, page_size, is_write, is_user;
@@ -524,7 +529,7 @@ int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr, is_user = mmu_idx ==MMU_USER_IDX ;#if defined(DEBUG_MMU ) -printf ("MMU fault: addr=" TARGET_FMT_lx" w=%d u=%d eip=" TARGET_FMT_lx"\n" , +printf ("MMU fault: addr=%" VADDR_PRIx" w=%d u=%d eip=" TARGET_FMT_lx"\n" , addr, is_write1, is_user, env->eip);#endif is_write = is_write1 &1 ;
target-i386/mem_helper.c +2 -1
@@ -135,9 +135,10 @@ void helper_boundl(CPUX86State *env, target_ulong a0, int v)void tlb_fill (CPUX86State *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +X86CPU *cpu =x86_env_get_cpu (env);int ret; - ret =cpu_x86_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =x86_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (ret) {if (retaddr) {/* now we have a real cpu fault */
target-lm32/cpu.c +3 -1
@@ -108,7 +108,9 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data) cc->get_tb_cpu_state = lm32_cpu_get_tb_cpu_state; cc->gdb_read_register = lm32_cpu_gdb_read_register; cc->gdb_write_register = lm32_cpu_gdb_write_register; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = lm32_cpu_handle_mmu_fault; +#else cc->get_phys_page_debug = lm32_cpu_get_phys_page_debug; cc->vmsd = &vmstate_lm32_cpu;#endif
target-lm32/cpu.h +1 -2
@@ -207,9 +207,8 @@ static inline CPULM32State *cpu_init(const char *cpu_model)#define cpu_gen_code cpu_lm32_gen_code#define cpu_signal_handler cpu_lm32_signal_handler -int cpu_lm32_handle_mmu_fault (CPULM32State *env,target_ulong address,int rw, +int lm32_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw,int mmu_idx); -#define cpu_handle_mmu_fault cpu_lm32_handle_mmu_fault#include "exec/cpu-all.h" #include "exec/exec-all.h"
target-lm32/helper.c +3 -1
@@ -20,9 +20,11 @@#include "cpu.h" #include "qemu/host-utils.h" -int cpu_lm32_handle_mmu_fault (CPULM32State *env,target_ulong address,int rw, +int lm32_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw,int mmu_idx) { +LM32CPU *cpu =LM32_CPU (cs); +CPULM32State *env = &cpu->env;int prot; address &=TARGET_PAGE_MASK ;
target-lm32/op_helper.c +2 -1
@@ -80,9 +80,10 @@ uint32_t HELPER(rcsr_jrx)(CPULM32State *env)void tlb_fill (CPULM32State *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +LM32CPU *cpu =lm32_env_get_cpu (env);int ret; - ret =cpu_lm32_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =lm32_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (unlikely (ret)) {if (retaddr) {/* now we have a real cpu fault */
target-m68k/cpu.c +3 -1
@@ -222,7 +222,9 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) cc->get_tb_cpu_state = m68k_cpu_get_tb_cpu_state; cc->gdb_read_register = m68k_cpu_gdb_read_register; cc->gdb_write_register = m68k_cpu_gdb_write_register; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = m68k_cpu_handle_mmu_fault; +#else cc->get_phys_page_debug = m68k_cpu_get_phys_page_debug;#endif dc->vmsd = &vmstate_m68k_cpu;
target-m68k/cpu.h +1 -2
@@ -233,9 +233,8 @@ static inline CPUM68KState *cpu_init(const char *cpu_model)#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 -int cpu_m68k_handle_mmu_fault (CPUM68KState *env,target_ulong address,int rw, +int m68k_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw,int mmu_idx); -#define cpu_handle_mmu_fault cpu_m68k_handle_mmu_fault#include "exec/cpu-all.h" #include "exec/exec-all.h"
target-m68k/helper.c +10 -7
@@ -278,11 +278,13 @@ void m68k_switch_sp(CPUM68KState *env)#if defined(CONFIG_USER_ONLY ) -int cpu_m68k_handle_mmu_fault (CPUM68KState *env,target_ulong address,int rw, -int mmu_idx) +int m68k_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw, +int mmu_idx) { - env->exception_index =EXCP_ACCESS ; - env->mmu.ar = address; +M68kCPU *cpu =M68K_CPU (cs); + + cpu->env.exception_index =EXCP_ACCESS ; + cpu->env.mmu.ar = address;return 1 ; }
@@ -296,14 +298,15 @@ hwaddr m68k_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)return addr; } -int cpu_m68k_handle_mmu_fault (CPUM68KState *env,target_ulong address,int rw, -int mmu_idx) +int m68k_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw, +int mmu_idx) { +M68kCPU *cpu =M68K_CPU (cs);int prot; address &=TARGET_PAGE_MASK ; prot =PAGE_READ |PAGE_WRITE |PAGE_EXEC ; -tlb_set_page (env, address, address, prot, mmu_idx,TARGET_PAGE_SIZE ); +tlb_set_page (&cpu->env, address, address, prot, mmu_idx,TARGET_PAGE_SIZE );return 0 ; }
target-m68k/op_helper.c +2 -1
@@ -59,9 +59,10 @@ extern int semihosting_enabled;void tlb_fill (CPUM68KState *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +M68kCPU *cpu =m68k_env_get_cpu (env);int ret; - ret =cpu_m68k_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =m68k_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (unlikely (ret)) {if (retaddr) {/* now we have a real cpu fault */
target-microblaze/cpu.c +3 -1
@@ -178,7 +178,9 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data) cc->get_tb_cpu_state = mb_cpu_get_tb_cpu_state; cc->gdb_read_register = mb_cpu_gdb_read_register; cc->gdb_write_register = mb_cpu_gdb_write_register; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = mb_cpu_handle_mmu_fault; +#else cc->do_unassigned_access = mb_cpu_unassigned_access; cc->get_phys_page_debug = mb_cpu_get_phys_page_debug;#endif
target-microblaze/cpu.h +1 -2
@@ -316,9 +316,8 @@ static inline CPUMBState *cpu_init(const char *cpu_model)#define MMU_USER_IDX 2/* See NB_MMU_MODES further up the file. */ -int cpu_mb_handle_mmu_fault (CPUMBState *env,target_ulong address,int rw, +int mb_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw,int mmu_idx); -#define cpu_handle_mmu_fault cpu_mb_handle_mmu_faultstatic inline int cpu_interrupts_enabled (CPUMBState *env) {
target-microblaze/helper.c +8 -6
@@ -36,21 +36,23 @@ void mb_cpu_do_interrupt(CPUState *cs) env->regs[14] = env->sregs[SR_PC]; } -int cpu_mb_handle_mmu_fault (CPUMBState * env,target_ulong address,int rw, +int mb_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw,int mmu_idx) { -MicroBlazeCPU *cpu =mb_env_get_cpu (env); +MicroBlazeCPU *cpu =MICROBLAZE_CPU (cs); - env->exception_index =0xaa ; -cpu_dump_state (CPU (cpu), stderr, fprintf,0 ); + cpu->env.exception_index =0xaa ; +cpu_dump_state (cs, stderr, fprintf,0 );return 1 ; }#else /* !CONFIG_USER_ONLY */ -int cpu_mb_handle_mmu_fault (CPUMBState *env,target_ulong address,int rw, -int mmu_idx) +int mb_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw, +int mmu_idx) { +MicroBlazeCPU *cpu =MICROBLAZE_CPU (cs); +CPUMBState *env = &cpu->env;unsigned int hit;unsigned int mmu_available;int r =1 ;
target-microblaze/op_helper.c +2 -1
@@ -44,9 +44,10 @@void tlb_fill (CPUMBState *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +MicroBlazeCPU *cpu =mb_env_get_cpu (env);int ret; - ret =cpu_mb_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =mb_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (unlikely (ret)) {if (retaddr) {/* now we have a real cpu fault */
target-mips/cpu.c +3 -1
@@ -153,7 +153,9 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) 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 +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = mips_cpu_handle_mmu_fault; +#else cc->do_unassigned_access = mips_cpu_unassigned_access; cc->get_phys_page_debug = mips_cpu_get_phys_page_debug;#endif
target-mips/cpu.h +2 -3
@@ -649,9 +649,8 @@ void cpu_mips_stop_count(CPUMIPSState *env);void cpu_mips_soft_irq (CPUMIPSState *env,int irq,int level);/* helper.c */ -int cpu_mips_handle_mmu_fault (CPUMIPSState *env,target_ulong address,int rw, -int mmu_idx); -#define cpu_handle_mmu_fault cpu_mips_handle_mmu_fault +int mips_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw, +int mmu_idx);#if !defined(CONFIG_USER_ONLY )void r4k_invalidate_tlb (CPUMIPSState *env,int idx,int use_extra); hwaddr cpu_mips_translate_address (CPUMIPSState *env, target_ulong address,
target-mips/helper.c +9 -6
@@ -268,9 +268,11 @@ hwaddr mips_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) }#endif -int cpu_mips_handle_mmu_fault (CPUMIPSState *env,target_ulong address,int rw, -int mmu_idx) +int mips_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw, +int mmu_idx) { +MIPSCPU *cpu =MIPS_CPU (cs); +CPUMIPSState *env = &cpu->env;#if !defined(CONFIG_USER_ONLY )hwaddr physical;int prot;
@@ -279,9 +281,9 @@ int cpu_mips_handle_mmu_fault (CPUMIPSState *env, target_ulong address, int rw,int ret =0 ;#if 0 -log_cpu_state (CPU (mips_env_get_cpu (env)),0 ); +log_cpu_state (cs,0 );#endif -qemu_log ("%s pc " TARGET_FMT_lx" ad " TARGET_FMT_lx" rw %d mmu_idx %d\n" , +qemu_log ("%s pc " TARGET_FMT_lx" ad %" VADDR_PRIx" rw %d mmu_idx %d\n" , __func__, env->active_tc.PC, address, rw, mmu_idx); rw &=1 ;
@@ -293,8 +295,9 @@ int cpu_mips_handle_mmu_fault (CPUMIPSState *env, target_ulong address, int rw, access_type =ACCESS_INT ; ret =get_physical_address (env, &physical, &prot, address, rw, access_type); -qemu_log ("%s address=" TARGET_FMT_lx" ret %d physical " TARGET_FMT_plx" prot %d\n" , - __func__, address, ret, physical, prot); +qemu_log ("%s address=%" VADDR_PRIx" ret %d physical " TARGET_FMT_plx +" prot %d\n" , + __func__, address, ret, physical, prot);if (ret ==TLBRET_MATCH ) { tlb_set_page(env, address & TARGET_PAGE_MASK, physical & TARGET_PAGE_MASK, prot | PAGE_EXEC,
target-mips/op_helper.c +2 -1
@@ -2134,9 +2134,10 @@ static void do_unaligned_access(CPUMIPSState *env, target_ulong addr,void tlb_fill (CPUMIPSState *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +MIPSCPU *cpu =mips_env_get_cpu (env);int ret; - ret =cpu_mips_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =mips_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (ret) {do_raise_exception_err (env, env->exception_index, env->error_code, retaddr);
target-moxie/cpu.c +3 -1
@@ -119,7 +119,9 @@ static void moxie_cpu_class_init(ObjectClass *oc, void *data) cc->dump_state = moxie_cpu_dump_state; cc->set_pc = moxie_cpu_set_pc; cc->get_tb_cpu_state = moxie_cpu_get_tb_cpu_state; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = moxie_cpu_handle_mmu_fault; +#else cc->get_phys_page_debug = moxie_cpu_get_phys_page_debug; cc->vmsd = &vmstate_moxie_cpu;#endif
target-moxie/cpu.h +1 -1
@@ -139,7 +139,7 @@ static inline CPUMoxieState *cpu_init(const char *cpu_model)#include "exec/cpu-all.h" #include "exec/exec-all.h" -int cpu_moxie_handle_mmu_fault (CPUMoxieState *env,target_ulong address, +int moxie_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw,int mmu_idx);#endif /* _CPU_MOXIE_H */
target-moxie/helper.c +11 -8
@@ -49,9 +49,10 @@void tlb_fill (CPUMoxieState *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +MoxieCPU *cpu =moxie_env_get_cpu (env);int ret; - ret =cpu_moxie_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =moxie_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (unlikely (ret)) {if (retaddr) {cpu_restore_state (env, retaddr);
@@ -103,27 +104,29 @@ void helper_debug(CPUMoxieState *env)#if defined(CONFIG_USER_ONLY ) -void moxie_cpu_do_interrupt (CPUState *env) +void moxie_cpu_do_interrupt (CPUState *cs) { env->exception_index =-1 ; } -int cpu_moxie_handle_mmu_fault (CPUMoxieState *env,target_ulong address, +int moxie_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw,int mmu_idx) { -MoxieCPU *cpu =moxie_env_get_cpu (env); +MoxieCPU *cpu =MOXIE_CPU (cs); - env->exception_index =0xaa ; - env->debug1 = address; -cpu_dump_state (CPU (cpu), stderr, fprintf,0 ); + cpu->env.exception_index =0xaa ; + cpu->env.debug1 = address; +cpu_dump_state (cs, stderr, fprintf,0 );return 1 ; }#else /* !CONFIG_USER_ONLY */ -int cpu_moxie_handle_mmu_fault (CPUMoxieState *env,target_ulong address, +int moxie_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw,int mmu_idx) { +MoxieCPU *cpu =MOXIE_CPU (cs); +CPUMoxieState *env = &cpu->env;MoxieMMUResult res;int prot, miss;target_ulong phy;
target-openrisc/cpu.c +3 -1
@@ -188,7 +188,9 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data) cc->get_tb_cpu_state = openrisc_cpu_get_tb_cpu_state; cc->gdb_read_register = openrisc_cpu_gdb_read_register; cc->gdb_write_register = openrisc_cpu_gdb_write_register; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = openrisc_cpu_handle_mmu_fault; +#else cc->get_phys_page_debug = openrisc_cpu_get_phys_page_debug; dc->vmsd = &vmstate_openrisc_cpu;#endif
target-openrisc/cpu.h +1 -3
@@ -353,15 +353,13 @@ hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);int openrisc_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int openrisc_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);void openrisc_translate_init (void ); -int cpu_openrisc_handle_mmu_fault (CPUOpenRISCState *env, -target_ulong address, +int openrisc_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw,int mmu_idx);int cpu_openrisc_signal_handler (int host_signum,void *pinfo,void *puc);#define cpu_list cpu_openrisc_list#define cpu_exec cpu_openrisc_exec#define cpu_gen_code cpu_openrisc_gen_code -#define cpu_handle_mmu_fault cpu_openrisc_handle_mmu_fault#define cpu_signal_handler cpu_openrisc_signal_handler#ifndef CONFIG_USER_ONLY
target-openrisc/mmu.c +7 -7
@@ -181,19 +181,19 @@ static void cpu_openrisc_raise_mmu_exception(OpenRISCCPU *cpu, }#ifndef CONFIG_USER_ONLY -int cpu_openrisc_handle_mmu_fault (CPUOpenRISCState *env, -target_ulong address,int rw,int mmu_idx) +int openrisc_cpu_handle_mmu_fault (CPUState *cs, +vaddr address,int rw,int mmu_idx) { +OpenRISCCPU *cpu =OPENRISC_CPU (cs);int ret =0 ;hwaddr physical =0 ;int prot =0 ; -OpenRISCCPU *cpu =openrisc_env_get_cpu (env); ret =cpu_openrisc_get_phys_addr (cpu, &physical, &prot, address, rw);if (ret ==TLBRET_MATCH ) { -tlb_set_page (env, address &TARGET_PAGE_MASK , +tlb_set_page (&cpu->env, address &TARGET_PAGE_MASK , physical &TARGET_PAGE_MASK , prot |PAGE_EXEC , mmu_idx,TARGET_PAGE_SIZE ); ret =0 ;
@@ -205,11 +205,11 @@ int cpu_openrisc_handle_mmu_fault(CPUOpenRISCState *env, return ret; }#else -int cpu_openrisc_handle_mmu_fault (CPUOpenRISCState *env, -target_ulong address,int rw,int mmu_idx) +int openrisc_cpu_handle_mmu_fault (CPUState *cs, +vaddr address,int rw,int mmu_idx) { +OpenRISCCPU *cpu =OPENRISC_CPU (cs);int ret =0 ; -OpenRISCCPU *cpu =openrisc_env_get_cpu (env);cpu_openrisc_raise_mmu_exception (cpu, address, rw, ret); ret =1 ;
target-openrisc/mmu_helper.c +2 -1
@@ -39,9 +39,10 @@void tlb_fill (CPUOpenRISCState *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +OpenRISCCPU *cpu =openrisc_env_get_cpu (env);int ret; - ret =cpu_openrisc_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =openrisc_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (ret) {if (retaddr) {
target-ppc/cpu.h +2 -2
@@ -1098,8 +1098,8 @@ int cpu_ppc_signal_handler (int host_signum, void *pinfo, void *puc);void ppc_hw_interrupt (CPUPPCState *env);#if defined(CONFIG_USER_ONLY ) -int cpu_handle_mmu_fault (CPUPPCState *env,target_ulong address,int rw, -int mmu_idx); +int ppc_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw, +int mmu_idx);#endif #if !defined(CONFIG_USER_ONLY )
target-ppc/translate_init.c +3 -1
@@ -8595,7 +8595,9 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->get_tb_cpu_state = ppc_cpu_get_tb_cpu_state; cc->gdb_read_register = ppc_cpu_gdb_read_register; cc->gdb_write_register = ppc_cpu_gdb_write_register; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = ppc_cpu_handle_mmu_fault; +#else cc->get_phys_page_debug = ppc_cpu_get_phys_page_debug; cc->vmsd = &vmstate_ppc_cpu;#endif
target-ppc/user_only_helper.c +4 -2
@@ -20,9 +20,11 @@#include "cpu.h" -int cpu_handle_mmu_fault (CPUPPCState *env,target_ulong address,int rw, -int mmu_idx) +int ppc_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw, +int mmu_idx) { +PowerPCCPU *cpu =POWERPC_CPU (cs); +CPUPPCState *env = &cpu->env;int exception, error_code;if (rw ==2 ) {
target-s390x/cpu.c +3 -1
@@ -257,7 +257,9 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->get_tb_cpu_state = s390_cpu_get_tb_cpu_state; cc->gdb_read_register = s390_cpu_gdb_read_register; cc->gdb_write_register = s390_cpu_gdb_write_register; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = s390_cpu_handle_mmu_fault; +#else cc->get_phys_page_debug = s390_cpu_get_phys_page_debug; cc->write_elf64_note = s390_cpu_write_elf64_note; cc->write_elf64_qemunote = s390_cpu_write_elf64_qemunote;
target-s390x/cpu.h +2 -3
@@ -308,9 +308,8 @@ int cpu_s390x_exec(CPUS390XState *s);is returned if the signal was handled by the virtual CPU. */ int cpu_s390x_signal_handler (int host_signum,void *pinfo,void *puc); -int cpu_s390x_handle_mmu_fault (CPUS390XState *env,target_ulong address,int rw, -int mmu_idx); -#define cpu_handle_mmu_fault cpu_s390x_handle_mmu_fault +int s390_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw, +int mmu_idx);#include "ioinst.h"
target-s390x/helper.c +12 -8
@@ -94,14 +94,16 @@ void s390_cpu_do_interrupt(CPUState *cs) env->exception_index =-1 ; } -int cpu_s390x_handle_mmu_fault (CPUS390XState *env,target_ulong address, -int rw,int mmu_idx) +int s390_cpu_handle_mmu_fault (CPUState *cs,vaddr address, +int rw,int mmu_idx) { - env->exception_index =EXCP_PGM ; - env->int_pgm_code =PGM_ADDRESSING ; +S390CPU *cpu =S390_CPU (cs); + + cpu->env.exception_index =EXCP_PGM ; + cpu->env.int_pgm_code =PGM_ADDRESSING ;/* On real machines this value is dropped into LowMem. Since this is userland, simply put this someplace that cpu_loop can find it. */ - env->__excp_addr = address; + cpu->env.__excp_addr = address;return 1 ; }
@@ -377,14 +379,16 @@ int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc,return r; } -int cpu_s390x_handle_mmu_fault (CPUS390XState *env,target_ulong orig_vaddr, -int rw,int mmu_idx) +int s390_cpu_handle_mmu_fault (CPUState *cs,vaddr orig_vaddr, +int rw,int mmu_idx) { +S390CPU *cpu =S390_CPU (cs); +CPUS390XState *env = &cpu->env;uint64_t asc = env->psw.mask &PSW_MASK_ASC ;target_ulong vaddr, raddr;int prot; -DPRINTF ("%s: address 0x%" PRIx64" rw %d mmu_idx %d\n" , +DPRINTF ("%s: address 0x%" VADDR_PRIx" rw %d mmu_idx %d\n" , __func__, orig_vaddr, rw, mmu_idx); orig_vaddr &=TARGET_PAGE_MASK ;
target-s390x/mem_helper.c +2 -1
@@ -47,9 +47,10 @@void tlb_fill (CPUS390XState *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +S390CPU *cpu =s390_env_get_cpu (env);int ret; - ret =cpu_s390x_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =s390_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (unlikely (ret !=0 )) {if (likely (retaddr)) {/* now we have a real cpu fault */
target-sh4/cpu.c +3 -1
@@ -320,7 +320,9 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) cc->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; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = superh_cpu_handle_mmu_fault; +#else cc->get_phys_page_debug = superh_cpu_get_phys_page_debug;#endif dc->vmsd = &vmstate_sh_cpu;
target-sh4/cpu.h +2 -3
@@ -193,9 +193,8 @@ SuperHCPU *cpu_sh4_init(const char *cpu_model);int cpu_sh4_exec (CPUSH4State * s);int cpu_sh4_signal_handler (int host_signum,void *pinfo,void *puc); -int cpu_sh4_handle_mmu_fault (CPUSH4State * env,target_ulong address,int rw, -int mmu_idx); -#define cpu_handle_mmu_fault cpu_sh4_handle_mmu_fault +int superh_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw, +int mmu_idx);void sh4_cpu_list (FILE *f,fprintf_function cpu_fprintf);#if !defined(CONFIG_USER_ONLY )
target-sh4/helper.c +9 -4
@@ -39,9 +39,12 @@ void superh_cpu_do_interrupt(CPUState *cs) env->exception_index =-1 ; } -int cpu_sh4_handle_mmu_fault (CPUSH4State * env,target_ulong address,int rw, -int mmu_idx) +int superh_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw, +int mmu_idx) { +SuperHCPU *cpu =SUPERH_CPU (cs); +CPUSH4State *env = &cpu->env; + env->tea = address; env->exception_index =-1 ;switch (rw) {
@@ -447,9 +450,11 @@ static int get_physical_address(CPUSH4State * env, target_ulong * physical,return get_mmu_address (env, physical, prot, address, rw, access_type); } -int cpu_sh4_handle_mmu_fault (CPUSH4State * env,target_ulong address,int rw, -int mmu_idx) +int superh_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw, +int mmu_idx) { +SuperHCPU *cpu =SUPERH_CPU (cs); +CPUSH4State *env = &cpu->env;target_ulong physical;int prot, ret, access_type;
target-sh4/op_helper.c +2 -1
@@ -41,9 +41,10 @@void tlb_fill (CPUSH4State *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +SuperHCPU *cpu =sh_env_get_cpu (env);int ret; - ret =cpu_sh4_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =superh_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (ret) {/* now we have a real cpu fault */ if (retaddr) {
target-sparc/cpu.c +3 -1
@@ -857,7 +857,9 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data) cc->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; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = sparc_cpu_handle_mmu_fault; +#else cc->do_unassigned_access = sparc_cpu_unassigned_access; cc->get_phys_page_debug = sparc_cpu_get_phys_page_debug;#endif
target-sparc/cpu.h +1 -2
@@ -519,9 +519,8 @@ SPARCCPU *cpu_sparc_init(const char *cpu_model);void cpu_sparc_set_id (CPUSPARCState *env,unsigned int cpu);void sparc_cpu_list (FILE *f,fprintf_function cpu_fprintf);/* mmu_helper.c */ -int cpu_sparc_handle_mmu_fault (CPUSPARCState *env1,target_ulong address,int rw, +int sparc_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw,int mmu_idx); -#define cpu_handle_mmu_fault cpu_sparc_handle_mmu_faulttarget_ulong mmu_probe (CPUSPARCState *env,target_ulong address,int mmulev);void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUSPARCState *env);
target-sparc/ldst_helper.c +2 -1
@@ -2432,9 +2432,10 @@ static void QEMU_NORETURN do_unaligned_access(CPUSPARCState *env,void tlb_fill (CPUSPARCState *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +SPARCCPU *cpu =sparc_env_get_cpu (env);int ret; - ret =cpu_sparc_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =sparc_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (ret) {if (retaddr) {cpu_restore_state (env, retaddr);
target-sparc/mmu_helper.c +12 -6
@@ -25,13 +25,15 @@#if defined(CONFIG_USER_ONLY ) -int cpu_sparc_handle_mmu_fault (CPUSPARCState *env1,target_ulong address,int rw, +int sparc_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw,int mmu_idx) { +SPARCCPU *cpu =SPARC_CPU (cs); +if (rw &2 ) { - env1->exception_index =TT_TFAULT ; + cpu->env.exception_index =TT_TFAULT ; }else { - env1->exception_index =TT_DFAULT ; + cpu->env.exception_index =TT_DFAULT ; }return 1 ; }
@@ -197,9 +199,11 @@ static int get_physical_address(CPUSPARCState *env, hwaddr *physical, }/* Perform address translation */ -int cpu_sparc_handle_mmu_fault (CPUSPARCState *env,target_ulong address,int rw, +int sparc_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw,int mmu_idx) { +SPARCCPU *cpu =SPARC_CPU (cs); +CPUSPARCState *env = &cpu->env;hwaddr paddr;target_ulong vaddr;target_ulong page_size;
@@ -211,7 +215,7 @@ int cpu_sparc_handle_mmu_fault(CPUSPARCState *env, target_ulong address, int rw, vaddr = address;if (error_code ==0 ) {#ifdef DEBUG_MMU -printf ("Translate at " TARGET_FMT_lx" -> " TARGET_FMT_plx", vaddr " +printf ("Translate at %" VADDR_PRIx" -> " TARGET_FMT_plx", vaddr " TARGET_FMT_lx"\n" , address, paddr, vaddr);#endif tlb_set_page (env, vaddr, paddr, prot, mmu_idx, page_size);
@@ -703,9 +707,11 @@ static int get_physical_address(CPUSPARCState *env, hwaddr *physical, }/* Perform address translation */ -int cpu_sparc_handle_mmu_fault (CPUSPARCState *env,target_ulong address,int rw, +int sparc_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw,int mmu_idx) { +SPARCCPU *cpu =SPARC_CPU (cs); +CPUSPARCState *env = &cpu->env;target_ulong vaddr;hwaddr paddr;target_ulong page_size;
target-unicore32/cpu.c +3 -1
@@ -170,7 +170,9 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data) cc->mmu_index = uc32_cpu_mmu_index; cc->set_pc = uc32_cpu_set_pc; cc->get_tb_cpu_state = uc32_cpu_get_tb_cpu_state; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = uc32_cpu_handle_mmu_fault; +#else cc->get_phys_page_debug = uc32_cpu_get_phys_page_debug;#endif dc->vmsd = &vmstate_uc32_cpu;
target-unicore32/cpu.h +2 -3
@@ -125,13 +125,10 @@ void cpu_asr_write(CPUUniCore32State *env1, target_ulong val, target_ulong mask)#define cpu_init uc32_cpu_init#define cpu_exec uc32_cpu_exec#define cpu_signal_handler uc32_cpu_signal_handler -#define cpu_handle_mmu_fault uc32_cpu_handle_mmu_faultCPUUniCore32State *uc32_cpu_init (const char *cpu_model);int uc32_cpu_exec (CPUUniCore32State *s);int uc32_cpu_signal_handler (int host_signum,void *pinfo,void *puc); -int uc32_cpu_handle_mmu_fault (CPUUniCore32State *env,target_ulong address,int rw, -int mmu_idx);/* MMU modes definitions */ #define MMU_MODE0_SUFFIX _kernel
@@ -142,6 +139,8 @@ int uc32_cpu_handle_mmu_fault(CPUUniCore32State *env, target_ulong address, int#include "cpu-qom.h" #include "exec/exec-all.h" +int uc32_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw, +int mmu_idx);void uc32_translate_init (void );void switch_mode (CPUUniCore32State *,int );
target-unicore32/helper.c +4 -1
@@ -250,9 +250,12 @@ void uc32_cpu_do_interrupt(CPUState *cs)cpu_abort (env,"NO interrupt in user mode\n" ); } -int uc32_cpu_handle_mmu_fault (CPUUniCore32State *env,target_ulong address, +int uc32_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int access_type,int mmu_idx) { +UniCore32CPU *cpu =UNICORE32_CPU (cs); +CPUUniCore32State *env = &cpu->env; +cpu_abort (env,"NO mmu fault in user mode\n" );return 1 ; }
target-unicore32/op_helper.c +2 -1
@@ -258,9 +258,10 @@ uint32_t HELPER(ror_cc)(CPUUniCore32State *env, uint32_t x, uint32_t i)void tlb_fill (CPUUniCore32State *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +UniCore32CPU *cpu =uc32_env_get_cpu (env);int ret; - ret =uc32_cpu_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =uc32_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (unlikely (ret)) {if (retaddr) {/* now we have a real cpu fault */
target-unicore32/softmmu.c +4 -2
@@ -208,9 +208,11 @@ do_fault:return code; } -int uc32_cpu_handle_mmu_fault (CPUUniCore32State *env,target_ulong address, +int uc32_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int access_type,int mmu_idx) { +UniCore32CPU *cpu =UNICORE32_CPU (cs); +CPUUniCore32State *env = &cpu->env;uint32_t phys_addr;target_ulong page_size;int prot;
@@ -230,7 +232,7 @@ int uc32_cpu_handle_mmu_fault(CPUUniCore32State *env, target_ulong address, ret =get_phys_addr_ucv2 (env, address, access_type, is_user, &phys_addr, &prot, &page_size);if (is_user) { -DPRINTF ("user space access: ret %x, address %x, " +DPRINTF ("user space access: ret %x, address %" VADDR_PRIx", " "access_type %x, phys_addr %x, prot %x\n" , ret, address, access_type, phys_addr, prot); }
user-exec.c +7 -2
@@ -82,6 +82,8 @@ static inline int handle_cpu_signal(uintptr_t pc, unsigned long address, int is_write, sigset_t *old_set, void *puc) { + CPUState *cpu; +CPUClass *cc;CPUArchState *env;int ret;
@@ -99,9 +101,12 @@ static inline int handle_cpu_signal(uintptr_t pc, unsigned long address,are still valid segv ones */ address =h2g_nocheck (address); - env = current_cpu->env_ptr; + cpu = current_cpu; + cc =CPU_GET_CLASS (cpu); + env = cpu->env_ptr;/* see if it is an MMU fault */ - ret =cpu_handle_mmu_fault (env, address, is_write,MMU_USER_IDX ); +g_assert (cc->handle_mmu_fault); + ret = cc->handle_mmu_fault (cpu, address, is_write,MMU_USER_IDX );if (ret <0 ) {return 0 ;/* not an MMU fault */ }
Signature · 1 line
1.8.1.4
Re: [Qemu-devel] [RFC qom-cpu 04/41] cpu: Turn cpu_handle_mmu_fault() into a CPUClass hook
Quoted 1,394 lines · Andreas Färber
Signed-off-by Andreas Färber <[email protected]>--- include/qom/cpu.h | 3 +++ target-alpha/cpu.c | 4 +++- target-alpha/cpu.h | 5 ++--- target-alpha/helper.c | 12 ++++++++---- target-alpha/mem_helper.c | 3 ++- target-arm/cpu.c | 4 +++- target-arm/cpu.h | 5 ++--- target-arm/helper.c | 13 +++++++++---- target-arm/op_helper.c | 3 ++- target-cris/cpu.c | 4 +++- target-cris/cpu.h | 3 +-- target-cris/helper.c | 24 +++++++++++++----------- target-cris/op_helper.c | 3 ++- target-i386/cpu.c | 4 +++- target-i386/cpu.h | 3 +-- target-i386/helper.c | 19 ++++++++++++------- target-i386/mem_helper.c | 3 ++- target-lm32/cpu.c | 4 +++- target-lm32/cpu.h | 3 +-- target-lm32/helper.c | 4 +++- target-lm32/op_helper.c | 3 ++- target-m68k/cpu.c | 4 +++- target-m68k/cpu.h | 3 +-- target-m68k/helper.c | 17 ++++++++++------- target-m68k/op_helper.c | 3 ++- target-microblaze/cpu.c | 4 +++- target-microblaze/cpu.h | 3 +-- target-microblaze/helper.c | 14 ++++++++------ target-microblaze/op_helper.c | 3 ++- target-mips/cpu.c | 4 +++- target-mips/cpu.h | 5 ++--- target-mips/helper.c | 15 +++++++++------ target-mips/op_helper.c | 3 ++- target-moxie/cpu.c | 4 +++- target-moxie/cpu.h | 2 +- target-moxie/helper.c | 19 +++++++++++-------- target-openrisc/cpu.c | 4 +++- target-openrisc/cpu.h | 4 +--- target-openrisc/mmu.c | 14 +++++++------- target-openrisc/mmu_helper.c | 3 ++- target-ppc/cpu.h | 4 ++-- target-ppc/translate_init.c | 4 +++- target-ppc/user_only_helper.c | 6 ++++-- target-s390x/cpu.c | 4 +++- target-s390x/cpu.h | 5 ++--- target-s390x/helper.c | 20 ++++++++++++-------- target-s390x/mem_helper.c | 3 ++- target-sh4/cpu.c | 4 +++- target-sh4/cpu.h | 5 ++--- target-sh4/helper.c | 13 +++++++++---- target-sh4/op_helper.c | 3 ++- target-sparc/cpu.c | 4 +++- target-sparc/cpu.h | 3 +-- target-sparc/ldst_helper.c | 3 ++- target-sparc/mmu_helper.c | 18 ++++++++++++------ target-unicore32/cpu.c | 4 +++- target-unicore32/cpu.h | 5 ++--- target-unicore32/helper.c | 5 ++++- target-unicore32/op_helper.c | 3 ++- target-unicore32/softmmu.c | 6 ++++-- user-exec.c | 9 +++++++-- 61 files changed, 238 insertions(+), 150 deletions(-)include/qom/cpu.h +3
-0@@ -84,6 +84,7 @@ struct TranslationBlock;* #TranslationBlock. * @synchronize_from_tb: Callback for synchronizing state from a TCG * #TranslationBlock. +* @handle_mmu_fault: Callback for handling an MMU fault. * @get_phys_page_debug: Callback for obtaining a physical address. * @gdb_read_register: Callback for letting GDB read a register. * @gdb_write_register: Callback for letting GDB write a register. @@ -120,6 +121,8 @@ typedef struct CPUClass {void (*get_tb_cpu_state)(const CPUState *cpu,vaddr *pc,vaddr *cs_base,int *flags);void (*synchronize_from_tb)(CPUState *cpu,struct TranslationBlock *tb); +int (*handle_mmu_fault)(CPUState *cpu,vaddr address,int rw, +int mmu_index);hwaddr (*get_phys_page_debug)(CPUState *cpu,vaddr addr);int (*gdb_read_register)(CPUState *cpu,uint8_t *buf,int reg);int (*gdb_write_register)(CPUState *cpu,uint8_t *buf,int reg);target-alpha/cpu.c +3
-1@@ -330,7 +330,9 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) cc->get_tb_cpu_state = alpha_cpu_get_tb_cpu_state; cc->gdb_read_register = alpha_cpu_gdb_read_register; cc->gdb_write_register = alpha_cpu_gdb_write_register; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = alpha_cpu_handle_mmu_fault; +#else cc->do_unassigned_access = alpha_cpu_unassigned_access; cc->get_phys_page_debug = alpha_cpu_get_phys_page_debug; dc->vmsd = &vmstate_alpha_cpu;target-alpha/cpu.h +2
-3@@ -435,9 +435,8 @@ int cpu_alpha_exec(CPUAlphaState *s);is returned if the signal was handled by the virtual CPU. */ int cpu_alpha_signal_handler (int host_signum,void *pinfo,void *puc); -int cpu_alpha_handle_mmu_fault (CPUAlphaState *env,uint64_t address,int rw, -int mmu_idx); -#define cpu_handle_mmu_fault cpu_alpha_handle_mmu_fault +int alpha_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw, +int mmu_idx);void do_restore_state (CPUAlphaState *,uintptr_t retaddr); void QEMU_NORETURN dynamic_excp(CPUAlphaState *, uintptr_t, int, int); void QEMU_NORETURN arith_excp(CPUAlphaState *, uintptr_t, int, uint64_t);target-alpha/helper.c +8
-4@@ -168,11 +168,13 @@ void helper_store_fpcr(CPUAlphaState *env, uint64_t val) }#if defined(CONFIG_USER_ONLY ) -int cpu_alpha_handle_mmu_fault (CPUAlphaState *env,target_ulong address, +int alpha_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw,int mmu_idx) { - env->exception_index =EXCP_MMFAULT ; - env->trap_arg0 = address; +AlphaCPU *cpu =ALPHA_CPU (cs); + + cpu->env.exception_index =EXCP_MMFAULT ; + cpu->env.trap_arg0 = address;return 1 ; }#else @@ -325,9 +327,11 @@ hwaddr alpha_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)return (fail >=0 ?-1 : phys); } -int cpu_alpha_handle_mmu_fault (CPUAlphaState *env,target_ulong addr,int rw, +int alpha_cpu_handle_mmu_fault (CPUState *cs,vaddr addr,int rw,int mmu_idx) { +AlphaCPU *cpu =ALPHA_CPU (cs); +CPUAlphaState *env = &cpu->env;target_ulong phys;int prot, fail;target-alpha/mem_helper.c +2
-1@@ -145,9 +145,10 @@ void alpha_cpu_unassigned_access(CPUState *cs, hwaddr addr,void tlb_fill (CPUAlphaState *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +AlphaCPU *cpu =alpha_env_get_cpu (env);int ret; - ret =cpu_alpha_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =alpha_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (unlikely (ret !=0 )) {if (retaddr) {cpu_restore_state (env, retaddr);target-arm/cpu.c +3
-1@@ -938,7 +938,9 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->get_tb_cpu_state = arm_cpu_get_tb_cpu_state; cc->gdb_read_register = arm_cpu_gdb_read_register; cc->gdb_write_register = arm_cpu_gdb_write_register; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = arm_cpu_handle_mmu_fault; +#else cc->get_phys_page_debug = arm_cpu_get_phys_page_debug; cc->vmsd = &vmstate_arm_cpu;#endif target-arm/cpu.h +2
-3@@ -266,9 +266,8 @@ uint32_t do_arm_semihosting(CPUARMState *env);is returned if the signal was handled by the virtual CPU. */ int cpu_arm_signal_handler (int host_signum,void *pinfo,void *puc); -int cpu_arm_handle_mmu_fault (CPUARMState *env,target_ulong address,int rw, -int mmu_idx); -#define cpu_handle_mmu_fault cpu_arm_handle_mmu_fault +int arm_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw, +int mmu_idx);#define CPSR_M (0x1f)#define CPSR_T (1 << 5)target-arm/helper.c +9
-4@@ -2078,9 +2078,12 @@ void arm_cpu_do_interrupt(CPUState *cs) env->exception_index =-1 ; } -int cpu_arm_handle_mmu_fault (CPUARMState *env,target_ulong address,int rw, -int mmu_idx) +int arm_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw, +int mmu_idx) { +ARMCPU *cpu =ARM_CPU (cs); +CPUARMState *env = &cpu->env; +if (rw ==2 ) { env->exception_index =EXCP_PREFETCH_ABORT ; env->cp15.c6_insn = address;@@ -3026,9 +3029,11 @@ static inline int get_phys_addr(CPUARMState *env, uint32_t address, } } -int cpu_arm_handle_mmu_fault (CPUARMState *env,target_ulong address, -int access_type,int mmu_idx) +int arm_cpu_handle_mmu_fault (CPUState *cs,vaddr address, +int access_type,int mmu_idx) { +ARMCPU *cpu =ARM_CPU (cs); +CPUARMState *env = &cpu->env;hwaddr phys_addr;target_ulong page_size;int prot;target-arm/op_helper.c +2
-1@@ -74,9 +74,10 @@ uint32_t HELPER(neon_tbl)(CPUARMState *env, uint32_t ireg, uint32_t def,void tlb_fill (CPUARMState *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +ARMCPU *cpu =arm_env_get_cpu (env);int ret; - ret =cpu_arm_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =arm_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (unlikely (ret)) {if (retaddr) {/* now we have a real cpu fault */ target-cris/cpu.c +3
-1@@ -290,7 +290,9 @@ static void cris_cpu_class_init(ObjectClass *oc, void *data) cc->get_tb_cpu_state = cris_cpu_get_tb_cpu_state; cc->gdb_read_register = cris_cpu_gdb_read_register; cc->gdb_write_register = cris_cpu_gdb_write_register; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = cris_cpu_handle_mmu_fault; +#else cc->get_phys_page_debug = cris_cpu_get_phys_page_debug;#endif target-cris/cpu.h +1
-2@@ -239,9 +239,8 @@ static inline CPUCRISState *cpu_init(const char *cpu_model)#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 -int cpu_cris_handle_mmu_fault (CPUCRISState *env,target_ulong address,int rw, +int cris_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw,int mmu_idx); -#define cpu_handle_mmu_fault cpu_cris_handle_mmu_fault/* Support function regs. */ #define SFR_RW_GC_CFG 0][0target-cris/helper.c +13
-11@@ -50,14 +50,14 @@ void crisv10_cpu_do_interrupt(CPUState *cs)cris_cpu_do_interrupt (cs); } -int cpu_cris_handle_mmu_fault (CPUCRISState * env,target_ulong address,int rw, +int cris_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw,int mmu_idx) { -CRISCPU *cpu =cris_env_get_cpu (env); +CRISCPU *cpu =CRIS_CPU (cs); - env->exception_index =0xaa ; - env->pregs[PR_EDA ] = address; -cpu_dump_state (CPU (cpu), stderr, fprintf,0 ); + cpu->env.exception_index =0xaa ; + cpu->env.pregs[PR_EDA ] = address; +cpu_dump_state (cs, stderr, fprintf,0 );return 1 ; }@@ -73,23 +73,25 @@ static void cris_shift_ccs(CPUCRISState *env) env->pregs[PR_CCS ] = ccs; } -int cpu_cris_handle_mmu_fault (CPUCRISState *env,target_ulong address,int rw, +int cris_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw,int mmu_idx) { -D (CPUState *cpu =CPU (cris_env_get_cpu (env))); +CRISCPU *cpu =CRIS_CPU (cs); +CPUCRISState *env = &cpu->env;struct cris_mmu_result res;int prot, miss;int r =-1 ;target_ulong phy; -D (printf ("%s addr=%x pc=%x rw=%x\n" , __func__, address, env->pc, rw)); +D (printf ("%s addr=%" VADDR_PRIx" pc=%x rw=%x\n" , + __func__, address, env->pc, rw)); miss =cris_mmu_translate (&res, env, address &TARGET_PAGE_MASK , rw, mmu_idx,0 );if (miss) {if (env->exception_index ==EXCP_BUSFAULT ) {cpu_abort (env,"CRIS: Illegal recursive bus fault." -"addr=%x rw=%d\n" , +"addr=%" VADDR_PRIx" rw=%d\n" , address, rw); }@@ -109,8 +111,8 @@ int cpu_cris_handle_mmu_fault(CPUCRISState *env, target_ulong address, int rw, r =0 ; }if (r >0 ) { -D_LOG ("%s returns %d irqreq=%x addr=%x phy=%x vec=%x pc=%x\n" , - __func__, r, cpu->interrupt_request, address, res.phy, +D_LOG ("%s returns %d irqreq=%x addr=%" VADDR_PRIx" phy=%x vec=%x" +" pc=%x\n" , __func__, r, cs->interrupt_request, address, res.phy, res.bf_vec, env->pc); }return r;target-cris/op_helper.c +2
-1@@ -57,11 +57,12 @@void tlb_fill (CPUCRISState *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +CRISCPU *cpu =cris_env_get_cpu (env);int ret;D_LOG ("%s pc=%x tpc=%x ra=%p\n" , __func__, env->pc, env->pregs[PR_EDA ], (void *)retaddr); - ret =cpu_cris_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =cris_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (unlikely (ret)) {if (retaddr) {/* now we have a real cpu fault */ target-i386/cpu.c +3
-1@@ -2743,7 +2743,9 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) 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 +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = x86_cpu_handle_mmu_fault; +#else cc->get_memory_mapping = x86_cpu_get_memory_mapping; cc->get_phys_page_debug = x86_cpu_get_phys_page_debug; cc->write_elf64_note = x86_cpu_write_elf64_note;target-i386/cpu.h +1
-2@@ -1042,9 +1042,8 @@ void host_cpuid(uint32_t function, uint32_t count, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx);/* helper.c */ -int cpu_x86_handle_mmu_fault (CPUX86State *env,target_ulong addr, +int x86_cpu_handle_mmu_fault (CPUState *cpu,vaddr addr,int is_write,int mmu_idx); -#define cpu_handle_mmu_fault cpu_x86_handle_mmu_faultvoid x86_cpu_set_a20 (X86CPU *cpu,int a20_state);static inline bool hw_local_breakpoint_enabled (unsigned long dr7,int index)target-i386/helper.c +12
-7@@ -485,9 +485,12 @@ void cpu_x86_update_cr4(CPUX86State *env, uint32_t new_cr4)#if defined(CONFIG_USER_ONLY ) -int cpu_x86_handle_mmu_fault (CPUX86State *env,target_ulong addr, +int x86_cpu_handle_mmu_fault (CPUState *cs,vaddr addr,int is_write,int mmu_idx) { +X86CPU *cpu =X86_CPU (cs); +CPUX86State *env = &cpu->env; +/* user mode only emulation */ is_write &=1 ; env->cr[2 ] = addr;@@ -508,13 +511,15 @@ int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr,# endif /* return value: --1 = cannot handle fault -0 = nothing more to do -1 = generate PF fault -*/ -int cpu_x86_handle_mmu_fault (CPUX86State *env,target_ulong addr, +* -1 = cannot handle fault +* 0 = nothing more to do +* 1 = generate PF fault +*/ +int x86_cpu_handle_mmu_fault (CPUState *cs,vaddr addr,int is_write1,int mmu_idx) { +X86CPU *cpu =X86_CPU (cs); +CPUX86State *env = &cpu->env;uint64_t ptep, pte;target_ulong pde_addr, pte_addr;int error_code, is_dirty, prot, page_size, is_write, is_user;@@ -524,7 +529,7 @@ int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr, is_user = mmu_idx ==MMU_USER_IDX ;#if defined(DEBUG_MMU ) -printf ("MMU fault: addr=" TARGET_FMT_lx" w=%d u=%d eip=" TARGET_FMT_lx"\n" , +printf ("MMU fault: addr=%" VADDR_PRIx" w=%d u=%d eip=" TARGET_FMT_lx"\n" , addr, is_write1, is_user, env->eip);#endif is_write = is_write1 &1 ;target-i386/mem_helper.c +2
-1@@ -135,9 +135,10 @@ void helper_boundl(CPUX86State *env, target_ulong a0, int v)void tlb_fill (CPUX86State *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +X86CPU *cpu =x86_env_get_cpu (env);int ret; - ret =cpu_x86_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =x86_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (ret) {if (retaddr) {/* now we have a real cpu fault */ target-lm32/cpu.c +3
-1@@ -108,7 +108,9 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data) cc->get_tb_cpu_state = lm32_cpu_get_tb_cpu_state; cc->gdb_read_register = lm32_cpu_gdb_read_register; cc->gdb_write_register = lm32_cpu_gdb_write_register; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = lm32_cpu_handle_mmu_fault; +#else cc->get_phys_page_debug = lm32_cpu_get_phys_page_debug; cc->vmsd = &vmstate_lm32_cpu;#endif target-lm32/cpu.h +1
-2@@ -207,9 +207,8 @@ static inline CPULM32State *cpu_init(const char *cpu_model)#define cpu_gen_code cpu_lm32_gen_code#define cpu_signal_handler cpu_lm32_signal_handler -int cpu_lm32_handle_mmu_fault (CPULM32State *env,target_ulong address,int rw, +int lm32_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw,int mmu_idx); -#define cpu_handle_mmu_fault cpu_lm32_handle_mmu_fault#include "exec/cpu-all.h" #include "exec/exec-all.h" target-lm32/helper.c +3
-1@@ -20,9 +20,11 @@#include "cpu.h" #include "qemu/host-utils.h" -int cpu_lm32_handle_mmu_fault (CPULM32State *env,target_ulong address,int rw, +int lm32_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw,int mmu_idx) { +LM32CPU *cpu =LM32_CPU (cs); +CPULM32State *env = &cpu->env;int prot; address &=TARGET_PAGE_MASK ;target-lm32/op_helper.c +2
-1@@ -80,9 +80,10 @@ uint32_t HELPER(rcsr_jrx)(CPULM32State *env)void tlb_fill (CPULM32State *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +LM32CPU *cpu =lm32_env_get_cpu (env);int ret; - ret =cpu_lm32_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =lm32_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (unlikely (ret)) {if (retaddr) {/* now we have a real cpu fault */ target-m68k/cpu.c +3
-1@@ -222,7 +222,9 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) cc->get_tb_cpu_state = m68k_cpu_get_tb_cpu_state; cc->gdb_read_register = m68k_cpu_gdb_read_register; cc->gdb_write_register = m68k_cpu_gdb_write_register; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = m68k_cpu_handle_mmu_fault; +#else cc->get_phys_page_debug = m68k_cpu_get_phys_page_debug;#endif dc->vmsd = &vmstate_m68k_cpu;target-m68k/cpu.h +1
-2@@ -233,9 +233,8 @@ static inline CPUM68KState *cpu_init(const char *cpu_model)#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 -int cpu_m68k_handle_mmu_fault (CPUM68KState *env,target_ulong address,int rw, +int m68k_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw,int mmu_idx); -#define cpu_handle_mmu_fault cpu_m68k_handle_mmu_fault#include "exec/cpu-all.h" #include "exec/exec-all.h" target-m68k/helper.c +10
-7@@ -278,11 +278,13 @@ void m68k_switch_sp(CPUM68KState *env)#if defined(CONFIG_USER_ONLY ) -int cpu_m68k_handle_mmu_fault (CPUM68KState *env,target_ulong address,int rw, -int mmu_idx) +int m68k_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw, +int mmu_idx) { - env->exception_index =EXCP_ACCESS ; - env->mmu.ar = address; +M68kCPU *cpu =M68K_CPU (cs); + + cpu->env.exception_index =EXCP_ACCESS ; + cpu->env.mmu.ar = address;return 1 ; }@@ -296,14 +298,15 @@ hwaddr m68k_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)return addr; } -int cpu_m68k_handle_mmu_fault (CPUM68KState *env,target_ulong address,int rw, -int mmu_idx) +int m68k_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw, +int mmu_idx) { +M68kCPU *cpu =M68K_CPU (cs);int prot; address &=TARGET_PAGE_MASK ; prot =PAGE_READ |PAGE_WRITE |PAGE_EXEC ; -tlb_set_page (env, address, address, prot, mmu_idx,TARGET_PAGE_SIZE ); +tlb_set_page (&cpu->env, address, address, prot, mmu_idx,TARGET_PAGE_SIZE );return 0 ; }target-m68k/op_helper.c +2
-1@@ -59,9 +59,10 @@ extern int semihosting_enabled;void tlb_fill (CPUM68KState *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +M68kCPU *cpu =m68k_env_get_cpu (env);int ret; - ret =cpu_m68k_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =m68k_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (unlikely (ret)) {if (retaddr) {/* now we have a real cpu fault */ target-microblaze/cpu.c +3
-1@@ -178,7 +178,9 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data) cc->get_tb_cpu_state = mb_cpu_get_tb_cpu_state; cc->gdb_read_register = mb_cpu_gdb_read_register; cc->gdb_write_register = mb_cpu_gdb_write_register; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = mb_cpu_handle_mmu_fault; +#else cc->do_unassigned_access = mb_cpu_unassigned_access; cc->get_phys_page_debug = mb_cpu_get_phys_page_debug;#endif target-microblaze/cpu.h +1
-2@@ -316,9 +316,8 @@ static inline CPUMBState *cpu_init(const char *cpu_model)#define MMU_USER_IDX 2/* See NB_MMU_MODES further up the file. */ -int cpu_mb_handle_mmu_fault (CPUMBState *env,target_ulong address,int rw, +int mb_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw,int mmu_idx); -#define cpu_handle_mmu_fault cpu_mb_handle_mmu_faultstatic inline int cpu_interrupts_enabled (CPUMBState *env) {target-microblaze/helper.c +8
-6@@ -36,21 +36,23 @@ void mb_cpu_do_interrupt(CPUState *cs) env->regs[14] = env->sregs[SR_PC]; } -int cpu_mb_handle_mmu_fault (CPUMBState * env,target_ulong address,int rw, +int mb_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw,int mmu_idx) { -MicroBlazeCPU *cpu =mb_env_get_cpu (env); +MicroBlazeCPU *cpu =MICROBLAZE_CPU (cs); - env->exception_index =0xaa ; -cpu_dump_state (CPU (cpu), stderr, fprintf,0 ); + cpu->env.exception_index =0xaa ; +cpu_dump_state (cs, stderr, fprintf,0 );return 1 ; }#else /* !CONFIG_USER_ONLY */ -int cpu_mb_handle_mmu_fault (CPUMBState *env,target_ulong address,int rw, -int mmu_idx) +int mb_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw, +int mmu_idx) { +MicroBlazeCPU *cpu =MICROBLAZE_CPU (cs); +CPUMBState *env = &cpu->env;unsigned int hit;unsigned int mmu_available;int r =1 ;target-microblaze/op_helper.c +2
-1@@ -44,9 +44,10 @@void tlb_fill (CPUMBState *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +MicroBlazeCPU *cpu =mb_env_get_cpu (env);int ret; - ret =cpu_mb_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =mb_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (unlikely (ret)) {if (retaddr) {/* now we have a real cpu fault */ target-mips/cpu.c +3
-1@@ -153,7 +153,9 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) 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 +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = mips_cpu_handle_mmu_fault; +#else cc->do_unassigned_access = mips_cpu_unassigned_access; cc->get_phys_page_debug = mips_cpu_get_phys_page_debug;#endif target-mips/cpu.h +2
-3@@ -649,9 +649,8 @@ void cpu_mips_stop_count(CPUMIPSState *env);void cpu_mips_soft_irq (CPUMIPSState *env,int irq,int level);/* helper.c */ -int cpu_mips_handle_mmu_fault (CPUMIPSState *env,target_ulong address,int rw, -int mmu_idx); -#define cpu_handle_mmu_fault cpu_mips_handle_mmu_fault +int mips_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw, +int mmu_idx);#if !defined(CONFIG_USER_ONLY )void r4k_invalidate_tlb (CPUMIPSState *env,int idx,int use_extra); hwaddr cpu_mips_translate_address (CPUMIPSState *env, target_ulong address,target-mips/helper.c +9
-6@@ -268,9 +268,11 @@ hwaddr mips_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) }#endif -int cpu_mips_handle_mmu_fault (CPUMIPSState *env,target_ulong address,int rw, -int mmu_idx) +int mips_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw, +int mmu_idx) { +MIPSCPU *cpu =MIPS_CPU (cs); +CPUMIPSState *env = &cpu->env;#if !defined(CONFIG_USER_ONLY )hwaddr physical;int prot;@@ -279,9 +281,9 @@ int cpu_mips_handle_mmu_fault (CPUMIPSState *env, target_ulong address, int rw,int ret =0 ;#if 0 -log_cpu_state (CPU (mips_env_get_cpu (env)),0 ); +log_cpu_state (cs,0 );#endif -qemu_log ("%s pc " TARGET_FMT_lx" ad " TARGET_FMT_lx" rw %d mmu_idx %d\n" , +qemu_log ("%s pc " TARGET_FMT_lx" ad %" VADDR_PRIx" rw %d mmu_idx %d\n" , __func__, env->active_tc.PC, address, rw, mmu_idx); rw &=1 ;@@ -293,8 +295,9 @@ int cpu_mips_handle_mmu_fault (CPUMIPSState *env, target_ulong address, int rw, access_type =ACCESS_INT ; ret =get_physical_address (env, &physical, &prot, address, rw, access_type); -qemu_log ("%s address=" TARGET_FMT_lx" ret %d physical " TARGET_FMT_plx" prot %d\n" , - __func__, address, ret, physical, prot); +qemu_log ("%s address=%" VADDR_PRIx" ret %d physical " TARGET_FMT_plx +" prot %d\n" , + __func__, address, ret, physical, prot);if (ret ==TLBRET_MATCH ) { tlb_set_page(env, address & TARGET_PAGE_MASK, physical & TARGET_PAGE_MASK, prot | PAGE_EXEC,target-mips/op_helper.c +2
-1@@ -2134,9 +2134,10 @@ static void do_unaligned_access(CPUMIPSState *env, target_ulong addr,void tlb_fill (CPUMIPSState *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +MIPSCPU *cpu =mips_env_get_cpu (env);int ret; - ret =cpu_mips_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =mips_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (ret) {do_raise_exception_err (env, env->exception_index, env->error_code, retaddr);target-moxie/cpu.c +3
-1@@ -119,7 +119,9 @@ static void moxie_cpu_class_init(ObjectClass *oc, void *data) cc->dump_state = moxie_cpu_dump_state; cc->set_pc = moxie_cpu_set_pc; cc->get_tb_cpu_state = moxie_cpu_get_tb_cpu_state; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = moxie_cpu_handle_mmu_fault; +#else cc->get_phys_page_debug = moxie_cpu_get_phys_page_debug; cc->vmsd = &vmstate_moxie_cpu;#endif target-moxie/cpu.h +1
-1@@ -139,7 +139,7 @@ static inline CPUMoxieState *cpu_init(const char *cpu_model)#include "exec/cpu-all.h" #include "exec/exec-all.h" -int cpu_moxie_handle_mmu_fault (CPUMoxieState *env,target_ulong address, +int moxie_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw,int mmu_idx);#endif /* _CPU_MOXIE_H */ target-moxie/helper.c +11
-8@@ -49,9 +49,10 @@void tlb_fill (CPUMoxieState *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +MoxieCPU *cpu =moxie_env_get_cpu (env);int ret; - ret =cpu_moxie_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =moxie_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (unlikely (ret)) {if (retaddr) {cpu_restore_state (env, retaddr);@@ -103,27 +104,29 @@ void helper_debug(CPUMoxieState *env)#if defined(CONFIG_USER_ONLY ) -void moxie_cpu_do_interrupt (CPUState *env) +void moxie_cpu_do_interrupt (CPUState *cs) { env->exception_index =-1 ; } -int cpu_moxie_handle_mmu_fault (CPUMoxieState *env,target_ulong address, +int moxie_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw,int mmu_idx) { -MoxieCPU *cpu =moxie_env_get_cpu (env); +MoxieCPU *cpu =MOXIE_CPU (cs); - env->exception_index =0xaa ; - env->debug1 = address; -cpu_dump_state (CPU (cpu), stderr, fprintf,0 ); + cpu->env.exception_index =0xaa ; + cpu->env.debug1 = address; +cpu_dump_state (cs, stderr, fprintf,0 );return 1 ; }#else /* !CONFIG_USER_ONLY */ -int cpu_moxie_handle_mmu_fault (CPUMoxieState *env,target_ulong address, +int moxie_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw,int mmu_idx) { +MoxieCPU *cpu =MOXIE_CPU (cs); +CPUMoxieState *env = &cpu->env;MoxieMMUResult res;int prot, miss;target_ulong phy;target-openrisc/cpu.c +3
-1@@ -188,7 +188,9 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data) cc->get_tb_cpu_state = openrisc_cpu_get_tb_cpu_state; cc->gdb_read_register = openrisc_cpu_gdb_read_register; cc->gdb_write_register = openrisc_cpu_gdb_write_register; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = openrisc_cpu_handle_mmu_fault; +#else cc->get_phys_page_debug = openrisc_cpu_get_phys_page_debug; dc->vmsd = &vmstate_openrisc_cpu;#endif target-openrisc/cpu.h +1
-3@@ -353,15 +353,13 @@ hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);int openrisc_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int openrisc_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);void openrisc_translate_init (void ); -int cpu_openrisc_handle_mmu_fault (CPUOpenRISCState *env, -target_ulong address, +int openrisc_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw,int mmu_idx);int cpu_openrisc_signal_handler (int host_signum,void *pinfo,void *puc);#define cpu_list cpu_openrisc_list#define cpu_exec cpu_openrisc_exec#define cpu_gen_code cpu_openrisc_gen_code -#define cpu_handle_mmu_fault cpu_openrisc_handle_mmu_fault#define cpu_signal_handler cpu_openrisc_signal_handler#ifndef CONFIG_USER_ONLY target-openrisc/mmu.c +7
-7@@ -181,19 +181,19 @@ static void cpu_openrisc_raise_mmu_exception(OpenRISCCPU *cpu, }#ifndef CONFIG_USER_ONLY -int cpu_openrisc_handle_mmu_fault (CPUOpenRISCState *env, -target_ulong address,int rw,int mmu_idx) +int openrisc_cpu_handle_mmu_fault (CPUState *cs, +vaddr address,int rw,int mmu_idx) { +OpenRISCCPU *cpu =OPENRISC_CPU (cs);int ret =0 ;hwaddr physical =0 ;int prot =0 ; -OpenRISCCPU *cpu =openrisc_env_get_cpu (env); ret =cpu_openrisc_get_phys_addr (cpu, &physical, &prot, address, rw);if (ret ==TLBRET_MATCH ) { -tlb_set_page (env, address &TARGET_PAGE_MASK , +tlb_set_page (&cpu->env, address &TARGET_PAGE_MASK , physical &TARGET_PAGE_MASK , prot |PAGE_EXEC , mmu_idx,TARGET_PAGE_SIZE ); ret =0 ;@@ -205,11 +205,11 @@ int cpu_openrisc_handle_mmu_fault(CPUOpenRISCState *env, return ret; }#else -int cpu_openrisc_handle_mmu_fault (CPUOpenRISCState *env, -target_ulong address,int rw,int mmu_idx) +int openrisc_cpu_handle_mmu_fault (CPUState *cs, +vaddr address,int rw,int mmu_idx) { +OpenRISCCPU *cpu =OPENRISC_CPU (cs);int ret =0 ; -OpenRISCCPU *cpu =openrisc_env_get_cpu (env);cpu_openrisc_raise_mmu_exception (cpu, address, rw, ret); ret =1 ;target-openrisc/mmu_helper.c +2
-1@@ -39,9 +39,10 @@void tlb_fill (CPUOpenRISCState *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +OpenRISCCPU *cpu =openrisc_env_get_cpu (env);int ret; - ret =cpu_openrisc_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =openrisc_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (ret) {if (retaddr) {target-ppc/cpu.h +2
-2@@ -1098,8 +1098,8 @@ int cpu_ppc_signal_handler (int host_signum, void *pinfo, void *puc);void ppc_hw_interrupt (CPUPPCState *env);#if defined(CONFIG_USER_ONLY ) -int cpu_handle_mmu_fault (CPUPPCState *env,target_ulong address,int rw, -int mmu_idx); +int ppc_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw, +int mmu_idx);#endif #if !defined(CONFIG_USER_ONLY )target-ppc/translate_init.c +3
-1@@ -8595,7 +8595,9 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->get_tb_cpu_state = ppc_cpu_get_tb_cpu_state; cc->gdb_read_register = ppc_cpu_gdb_read_register; cc->gdb_write_register = ppc_cpu_gdb_write_register; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = ppc_cpu_handle_mmu_fault; +#else cc->get_phys_page_debug = ppc_cpu_get_phys_page_debug; cc->vmsd = &vmstate_ppc_cpu;#endif target-ppc/user_only_helper.c +4
-2@@ -20,9 +20,11 @@#include "cpu.h" -int cpu_handle_mmu_fault (CPUPPCState *env,target_ulong address,int rw, -int mmu_idx) +int ppc_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw, +int mmu_idx) { +PowerPCCPU *cpu =POWERPC_CPU (cs); +CPUPPCState *env = &cpu->env;int exception, error_code;if (rw ==2 ) {target-s390x/cpu.c +3
-1@@ -257,7 +257,9 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->get_tb_cpu_state = s390_cpu_get_tb_cpu_state; cc->gdb_read_register = s390_cpu_gdb_read_register; cc->gdb_write_register = s390_cpu_gdb_write_register; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = s390_cpu_handle_mmu_fault; +#else cc->get_phys_page_debug = s390_cpu_get_phys_page_debug; cc->write_elf64_note = s390_cpu_write_elf64_note; cc->write_elf64_qemunote = s390_cpu_write_elf64_qemunote;target-s390x/cpu.h +2
-3@@ -308,9 +308,8 @@ int cpu_s390x_exec(CPUS390XState *s);is returned if the signal was handled by the virtual CPU. */ int cpu_s390x_signal_handler (int host_signum,void *pinfo,void *puc); -int cpu_s390x_handle_mmu_fault (CPUS390XState *env,target_ulong address,int rw, -int mmu_idx); -#define cpu_handle_mmu_fault cpu_s390x_handle_mmu_fault +int s390_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw, +int mmu_idx);#include "ioinst.h" target-s390x/helper.c +12
-8@@ -94,14 +94,16 @@ void s390_cpu_do_interrupt(CPUState *cs) env->exception_index =-1 ; } -int cpu_s390x_handle_mmu_fault (CPUS390XState *env,target_ulong address, -int rw,int mmu_idx) +int s390_cpu_handle_mmu_fault (CPUState *cs,vaddr address, +int rw,int mmu_idx) { - env->exception_index =EXCP_PGM ; - env->int_pgm_code =PGM_ADDRESSING ; +S390CPU *cpu =S390_CPU (cs); + + cpu->env.exception_index =EXCP_PGM ; + cpu->env.int_pgm_code =PGM_ADDRESSING ;/* On real machines this value is dropped into LowMem. Since this is userland, simply put this someplace that cpu_loop can find it. */ - env->__excp_addr = address; + cpu->env.__excp_addr = address;return 1 ; }@@ -377,14 +379,16 @@ int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc,return r; } -int cpu_s390x_handle_mmu_fault (CPUS390XState *env,target_ulong orig_vaddr, -int rw,int mmu_idx) +int s390_cpu_handle_mmu_fault (CPUState *cs,vaddr orig_vaddr, +int rw,int mmu_idx) { +S390CPU *cpu =S390_CPU (cs); +CPUS390XState *env = &cpu->env;uint64_t asc = env->psw.mask &PSW_MASK_ASC ;target_ulong vaddr, raddr;int prot; -DPRINTF ("%s: address 0x%" PRIx64" rw %d mmu_idx %d\n" , +DPRINTF ("%s: address 0x%" VADDR_PRIx" rw %d mmu_idx %d\n" , __func__, orig_vaddr, rw, mmu_idx); orig_vaddr &=TARGET_PAGE_MASK ;target-s390x/mem_helper.c +2
-1@@ -47,9 +47,10 @@void tlb_fill (CPUS390XState *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +S390CPU *cpu =s390_env_get_cpu (env);int ret; - ret =cpu_s390x_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =s390_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (unlikely (ret !=0 )) {if (likely (retaddr)) {/* now we have a real cpu fault */ target-sh4/cpu.c +3
-1@@ -320,7 +320,9 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) cc->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; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = superh_cpu_handle_mmu_fault; +#else cc->get_phys_page_debug = superh_cpu_get_phys_page_debug;#endif dc->vmsd = &vmstate_sh_cpu;target-sh4/cpu.h +2
-3@@ -193,9 +193,8 @@ SuperHCPU *cpu_sh4_init(const char *cpu_model);int cpu_sh4_exec (CPUSH4State * s);int cpu_sh4_signal_handler (int host_signum,void *pinfo,void *puc); -int cpu_sh4_handle_mmu_fault (CPUSH4State * env,target_ulong address,int rw, -int mmu_idx); -#define cpu_handle_mmu_fault cpu_sh4_handle_mmu_fault +int superh_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw, +int mmu_idx);void sh4_cpu_list (FILE *f,fprintf_function cpu_fprintf);#if !defined(CONFIG_USER_ONLY )target-sh4/helper.c +9
-4@@ -39,9 +39,12 @@ void superh_cpu_do_interrupt(CPUState *cs) env->exception_index =-1 ; } -int cpu_sh4_handle_mmu_fault (CPUSH4State * env,target_ulong address,int rw, -int mmu_idx) +int superh_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw, +int mmu_idx) { +SuperHCPU *cpu =SUPERH_CPU (cs); +CPUSH4State *env = &cpu->env; + env->tea = address; env->exception_index =-1 ;switch (rw) {@@ -447,9 +450,11 @@ static int get_physical_address(CPUSH4State * env, target_ulong * physical,return get_mmu_address (env, physical, prot, address, rw, access_type); } -int cpu_sh4_handle_mmu_fault (CPUSH4State * env,target_ulong address,int rw, -int mmu_idx) +int superh_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw, +int mmu_idx) { +SuperHCPU *cpu =SUPERH_CPU (cs); +CPUSH4State *env = &cpu->env;target_ulong physical;int prot, ret, access_type;target-sh4/op_helper.c +2
-1@@ -41,9 +41,10 @@void tlb_fill (CPUSH4State *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +SuperHCPU *cpu =sh_env_get_cpu (env);int ret; - ret =cpu_sh4_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =superh_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (ret) {/* now we have a real cpu fault */ if (retaddr) {target-sparc/cpu.c +3
-1@@ -857,7 +857,9 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data) cc->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; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = sparc_cpu_handle_mmu_fault; +#else cc->do_unassigned_access = sparc_cpu_unassigned_access; cc->get_phys_page_debug = sparc_cpu_get_phys_page_debug;#endif target-sparc/cpu.h +1
-2@@ -519,9 +519,8 @@ SPARCCPU *cpu_sparc_init(const char *cpu_model);void cpu_sparc_set_id (CPUSPARCState *env,unsigned int cpu);void sparc_cpu_list (FILE *f,fprintf_function cpu_fprintf);/* mmu_helper.c */ -int cpu_sparc_handle_mmu_fault (CPUSPARCState *env1,target_ulong address,int rw, +int sparc_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw,int mmu_idx); -#define cpu_handle_mmu_fault cpu_sparc_handle_mmu_faulttarget_ulong mmu_probe (CPUSPARCState *env,target_ulong address,int mmulev);void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUSPARCState *env);target-sparc/ldst_helper.c +2
-1@@ -2432,9 +2432,10 @@ static void QEMU_NORETURN do_unaligned_access(CPUSPARCState *env,void tlb_fill (CPUSPARCState *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +SPARCCPU *cpu =sparc_env_get_cpu (env);int ret; - ret =cpu_sparc_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =sparc_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (ret) {if (retaddr) {cpu_restore_state (env, retaddr);target-sparc/mmu_helper.c +12
-6@@ -25,13 +25,15 @@#if defined(CONFIG_USER_ONLY ) -int cpu_sparc_handle_mmu_fault (CPUSPARCState *env1,target_ulong address,int rw, +int sparc_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw,int mmu_idx) { +SPARCCPU *cpu =SPARC_CPU (cs); +if (rw &2 ) { - env1->exception_index =TT_TFAULT ; + cpu->env.exception_index =TT_TFAULT ; }else { - env1->exception_index =TT_DFAULT ; + cpu->env.exception_index =TT_DFAULT ; }return 1 ; }@@ -197,9 +199,11 @@ static int get_physical_address(CPUSPARCState *env, hwaddr *physical, }/* Perform address translation */ -int cpu_sparc_handle_mmu_fault (CPUSPARCState *env,target_ulong address,int rw, +int sparc_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw,int mmu_idx) { +SPARCCPU *cpu =SPARC_CPU (cs); +CPUSPARCState *env = &cpu->env;hwaddr paddr;target_ulong vaddr;target_ulong page_size;@@ -211,7 +215,7 @@ int cpu_sparc_handle_mmu_fault(CPUSPARCState *env, target_ulong address, int rw, vaddr = address;if (error_code ==0 ) {#ifdef DEBUG_MMU -printf ("Translate at " TARGET_FMT_lx" -> " TARGET_FMT_plx", vaddr " +printf ("Translate at %" VADDR_PRIx" -> " TARGET_FMT_plx", vaddr " TARGET_FMT_lx"\n" , address, paddr, vaddr);#endif tlb_set_page (env, vaddr, paddr, prot, mmu_idx, page_size);@@ -703,9 +707,11 @@ static int get_physical_address(CPUSPARCState *env, hwaddr *physical, }/* Perform address translation */ -int cpu_sparc_handle_mmu_fault (CPUSPARCState *env,target_ulong address,int rw, +int sparc_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw,int mmu_idx) { +SPARCCPU *cpu =SPARC_CPU (cs); +CPUSPARCState *env = &cpu->env;target_ulong vaddr;hwaddr paddr;target_ulong page_size;target-unicore32/cpu.c +3
-1@@ -170,7 +170,9 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data) cc->mmu_index = uc32_cpu_mmu_index; cc->set_pc = uc32_cpu_set_pc; cc->get_tb_cpu_state = uc32_cpu_get_tb_cpu_state; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + cc->handle_mmu_fault = uc32_cpu_handle_mmu_fault; +#else cc->get_phys_page_debug = uc32_cpu_get_phys_page_debug;#endif dc->vmsd = &vmstate_uc32_cpu;target-unicore32/cpu.h +2
-3@@ -125,13 +125,10 @@ void cpu_asr_write(CPUUniCore32State *env1, target_ulong val, target_ulong mask)#define cpu_init uc32_cpu_init#define cpu_exec uc32_cpu_exec#define cpu_signal_handler uc32_cpu_signal_handler -#define cpu_handle_mmu_fault uc32_cpu_handle_mmu_faultCPUUniCore32State *uc32_cpu_init (const char *cpu_model);int uc32_cpu_exec (CPUUniCore32State *s);int uc32_cpu_signal_handler (int host_signum,void *pinfo,void *puc); -int uc32_cpu_handle_mmu_fault (CPUUniCore32State *env,target_ulong address,int rw, -int mmu_idx);/* MMU modes definitions */ #define MMU_MODE0_SUFFIX _kernel@@ -142,6 +139,8 @@ int uc32_cpu_handle_mmu_fault(CPUUniCore32State *env, target_ulong address, int#include "cpu-qom.h" #include "exec/exec-all.h" +int uc32_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw, +int mmu_idx);void uc32_translate_init (void );void switch_mode (CPUUniCore32State *,int );target-unicore32/helper.c +4
-1@@ -250,9 +250,12 @@ void uc32_cpu_do_interrupt(CPUState *cs)cpu_abort (env,"NO interrupt in user mode\n" ); } -int uc32_cpu_handle_mmu_fault (CPUUniCore32State *env,target_ulong address, +int uc32_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int access_type,int mmu_idx) { +UniCore32CPU *cpu =UNICORE32_CPU (cs); +CPUUniCore32State *env = &cpu->env; +cpu_abort (env,"NO mmu fault in user mode\n" );return 1 ; }target-unicore32/op_helper.c +2
-1@@ -258,9 +258,10 @@ uint32_t HELPER(ror_cc)(CPUUniCore32State *env, uint32_t x, uint32_t i)void tlb_fill (CPUUniCore32State *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { +UniCore32CPU *cpu =uc32_env_get_cpu (env);int ret; - ret =uc32_cpu_handle_mmu_fault (env, addr, is_write, mmu_idx); + ret =uc32_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx);if (unlikely (ret)) {if (retaddr) {/* now we have a real cpu fault */ target-unicore32/softmmu.c +4
-2@@ -208,9 +208,11 @@ do_fault:return code; } -int uc32_cpu_handle_mmu_fault (CPUUniCore32State *env,target_ulong address, +int uc32_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int access_type,int mmu_idx) { +UniCore32CPU *cpu =UNICORE32_CPU (cs); +CPUUniCore32State *env = &cpu->env;uint32_t phys_addr;target_ulong page_size;int prot;@@ -230,7 +232,7 @@ int uc32_cpu_handle_mmu_fault(CPUUniCore32State *env, target_ulong address, ret =get_phys_addr_ucv2 (env, address, access_type, is_user, &phys_addr, &prot, &page_size);if (is_user) { -DPRINTF ("user space access: ret %x, address %x, " +DPRINTF ("user space access: ret %x, address %" VADDR_PRIx", " "access_type %x, phys_addr %x, prot %x\n" , ret, address, access_type, phys_addr, prot); }user-exec.c +2
-1@@ -82,6 +82,8 @@ static inline int handle_cpu_signal(uintptr_t pc, unsigned long address, int is_write, sigset_t *old_set, void *puc) { + CPUState *cpu; +CPUClass *cc;CPUArchState *env;int ret;@@ -99,9 +101,12 @@ static inline int handle_cpu_signal(uintptr_t pc, unsigned long address,are still valid segv ones */ address =h2g_nocheck (address); - env = current_cpu->env_ptr;
user-exec.c static inline int handle_cpu_signal(uintptr_t pc, unsigned long address, · line 112
Quoted 10 lines
user-exec.c +5
-1+ cpu = current_cpu; + cc =CPU_GET_CLASS (cpu); + env = cpu->env_ptr;/* see if it is an MMU fault */ - ret =cpu_handle_mmu_fault (env, address, is_write,MMU_USER_IDX ); +g_assert (cc->handle_mmu_fault); + ret = cc->handle_mmu_fault (cpu, address, is_write,MMU_USER_IDX );if (ret <0 ) {return 0 ;/* not an MMU fault */ }
target-openrisc: Tested-by: Jia Liu <[email protected]>
Quoted 3 lines
--
1.8.1.4
RFC 5/41 cpu: Move mem_io_{pc, vaddr} fields from CPU_COMMON to CPUState
In reply to Andreas FärberReset them.
--- exec.c | 4 ++-- hw/i386/kvmvapic.c | 2 +- include/exec/cpu-defs.h | 7 ------- include/exec/softmmu_template.h | 10 ++++++---- include/qom/cpu.h | 8 ++++++++ qom/cpu.c | 2 ++ target-i386/helper.c | 7 +++++-- translate-all.c | 15 ++++++++------- 8 files changed, 32 insertions(+), 23 deletions(-)
exec.c +2 -2
@@ -1459,7 +1459,7 @@ static void notdirty_mem_write(void *opaque, hwaddr ram_addr,flushed */ if (dirty_flags ==0xff ) {CPUArchState *env = current_cpu->env_ptr; -tlb_set_dirty (env, env->mem_io_vaddr); +tlb_set_dirty (env, current_cpu->mem_io_vaddr); } }
@@ -1493,7 +1493,7 @@ static void check_watchpoint(int offset, int len_mask, int flags)cpu_interrupt (cpu,CPU_INTERRUPT_DEBUG );return ; } - vaddr = (env->mem_io_vaddr &TARGET_PAGE_MASK ) + offset; + vaddr = (cpu->mem_io_vaddr &TARGET_PAGE_MASK ) + offset; QTAILQ_FOREACH(wp, &env->watchpoints, entry) {if ((vaddr == (wp->vaddr & len_mask) || (vaddr & wp->len_mask) == wp->vaddr) && (wp->flags & flags)) {
hw/i386/kvmvapic.c +1 -1
@@ -408,7 +408,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)if (!kvm_enabled ()) {CPUClass *cc =CPU_GET_CLASS (cs); -cpu_restore_state (env, env->mem_io_pc); +cpu_restore_state (env, cs->mem_io_pc); cc->get_tb_cpu_state (cs, ¤t_pc, ¤t_cs_base, ¤t_flags); }
include/exec/cpu-defs.h +0 -7
@@ -145,13 +145,6 @@ typedef struct CPUWatchpoint {#define CPU_TEMP_BUF_NLONGS 128#define CPU_COMMON \/* soft mmu support */ \ -/* in order to avoid passing too many arguments to the MMIO \ -helpers, we store some rarely used information in the CPU \ -context) */ \ - uintptr_t mem_io_pc;/* host pc at which the memory was \ -accessed */ \ -target_ulong mem_io_vaddr;/* target virtual addr at which the \ -memory was accessed */ \ CPU_COMMON_TLB \ struct TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE]; \ \
include/exec/softmmu_template.h +6 -4
@@ -75,16 +75,17 @@ static inline DATA_TYPE glue(io_read, SUFFIX)(CPUArchState *env, target_ulong addr, uintptr_t retaddr) { +CPUState *cpu =ENV_GET_CPU (env);uint64_t val;MemoryRegion *mr =iotlb_to_region (physaddr); physaddr = (physaddr &TARGET_PAGE_MASK ) + addr; - env->mem_io_pc = retaddr; + cpu->mem_io_pc = retaddr;if (mr != &io_mem_rom && mr != &io_mem_notdirty && !can_do_io (env)) {cpu_io_recompile (env, retaddr); } - env->mem_io_vaddr = addr; + cpu->mem_io_vaddr = addr;io_mem_read (mr, physaddr, &val,1 <<SHIFT );return val; }
@@ -196,6 +197,7 @@ static inline void glue(io_write, SUFFIX)(CPUArchState *env, target_ulong addr, uintptr_t retaddr) { +CPUState *cpu =ENV_GET_CPU (env);MemoryRegion *mr =iotlb_to_region (physaddr); physaddr = (physaddr &TARGET_PAGE_MASK ) + addr;
@@ -203,8 +205,8 @@ static inline void glue(io_write, SUFFIX)(CPUArchState *env,cpu_io_recompile (env, retaddr); } - env->mem_io_vaddr = addr; - env->mem_io_pc = retaddr; + cpu->mem_io_vaddr = addr; + cpu->mem_io_pc = retaddr;io_mem_write (mr, physaddr, val,1 <<SHIFT ); }
include/qom/cpu.h +8 -0
@@ -166,6 +166,8 @@ struct kvm_run;* @gdb_num_regs: Number of total registers accessible to GDB. * @gdb_num_g_regs: Number of registers in GDB 'g' packets. * @next_cpu: Next CPU sharing TB cache. +* @mem_io_pc: Host Program Counter at which the memory was accessed. +* @mem_io_vaddr: Target virtual address at which the memory was accessed. * @kvm_fd: vCPU file descriptor for KVM. * * State of one CPU core or thread.
@@ -204,6 +206,12 @@ struct CPUState {int gdb_num_g_regs;QTAILQ_ENTRY (CPUState) node; +/* In order to avoid passing too many arguments to the MMIO helpers, +* we store some rarely used information in the CPU context. +*/ +uintptr_t mem_io_pc; +vaddr mem_io_vaddr; +int kvm_fd;bool kvm_vcpu_dirty;struct KVMState *kvm_state;
qom/cpu.c +2 -0
@@ -198,6 +198,8 @@ static void cpu_common_reset(CPUState *cpu) cpu->interrupt_request =0 ; cpu->current_tb =NULL ; cpu->halted =0 ; + cpu->mem_io_pc =0 ; + cpu->mem_io_vaddr =0 ; }static int cpu_common_mmu_index (const CPUState *cs)
target-i386/helper.c +5 -2
@@ -1248,12 +1248,15 @@ void cpu_x86_inject_mce(Monitor *mon, X86CPU *cpu, int bank,void cpu_report_tpr_access (CPUX86State *env,TPRAccess access) { +X86CPU *cpu =x86_env_get_cpu (env); +CPUState *cs =CPU (cpu); +if (kvm_enabled ()) { env->tpr_access_type = access; -cpu_interrupt (CPU (x86_env_get_cpu (env)),CPU_INTERRUPT_TPR ); +cpu_interrupt (cs,CPU_INTERRUPT_TPR ); }else { -cpu_restore_state (env, env->mem_io_pc); +cpu_restore_state (env, cs->mem_io_pc);apic_handle_tpr_access_report (env->apic_state, env->eip, access); }
translate-all.c +8 -7
@@ -1062,9 +1062,9 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end,if (current_tb_not_found) { current_tb_not_found =0 ; current_tb =NULL ; -if (env->mem_io_pc) { +if (cpu->mem_io_pc) {/* now we have a real cpu fault */ - current_tb =tb_find_pc (env->mem_io_pc); + current_tb =tb_find_pc (cpu->mem_io_pc); } } if (current_tb == tb &&
@@ -1076,7 +1076,7 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end,restore the CPU state */ current_tb_modified =1 ; -cpu_restore_state_from_tb (current_tb, env, env->mem_io_pc); +cpu_restore_state_from_tb (current_tb, env, cpu->mem_io_pc); cc->get_tb_cpu_state (cpu, ¤t_pc, ¤t_cs_base, ¤t_flags); }
@@ -1103,7 +1103,7 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end,if (!p->first_tb) {invalidate_page_bitmap (p);if (is_cpu_write_access) { -tlb_unprotect_code_phys (env, start, env->mem_io_vaddr); +tlb_unprotect_code_phys (env, start, cpu->mem_io_vaddr); } }#endif
@@ -1389,14 +1389,15 @@ void tb_invalidate_phys_addr(hwaddr addr)void tb_check_watchpoint (CPUArchState *env) { +CPUState *cpu =ENV_GET_CPU (env);TranslationBlock *tb; - tb =tb_find_pc (env->mem_io_pc); + tb =tb_find_pc (cpu->mem_io_pc);if (!tb) {cpu_abort (env,"check_watchpoint: could not find TB for pc=%p" , - (void *)env->mem_io_pc); + (void *)cpu->mem_io_pc); } -cpu_restore_state_from_tb (tb, env, env->mem_io_pc); +cpu_restore_state_from_tb (tb, env, cpu->mem_io_pc);tb_phys_invalidate (tb,-1 ); }
Signature · 1 line
1.8.1.4
RFC 6/41 cpu: Move can_do_io field from CPU_COMMON to CPUState
In reply to Andreas FärberRename can_do_io() to cpu_can_do_io() and change argument to CPUState.
--- cpus.c | 2 +- include/exec/cpu-defs.h | 1 - include/exec/exec-all.h | 21 +++++++++++++-------- include/exec/gen-icount.h | 4 ++-- include/exec/softmmu_template.h | 4 ++-- include/qom/cpu.h | 2 ++ qom/cpu.c | 1 + translate-all.c | 5 +++-- 8 files changed, 24 insertions(+), 16 deletions(-)
cpus.c +1 -1
@@ -128,7 +128,7 @@ int64_t cpu_get_icount(void) icount = qemu_icount;if (cpu) {CPUArchState *env = cpu->env_ptr; -if (!can_do_io (env)) { +if (!cpu_can_do_io (cpu)) {fprintf (stderr,"Bad clock read\n" ); } icount -= (env->icount_decr.u16.low + env->icount_extra);
include/exec/cpu-defs.h +0 -1
@@ -156,7 +156,6 @@ typedef struct CPUWatchpoint {uint32_t u32; \icount_decr_u16 u16; \ } icount_decr; \ -uint32_t can_do_io;/* nonzero if memory mapped IO is safe. */ \ \/* from this point: preserved by CPU reset */ \/* ice debug support */ \
include/exec/exec-all.h +13 -8
@@ -422,20 +422,25 @@ extern int singlestep;/* cpu-exec.c */ extern volatile sig_atomic_t exit_request; -/* Deterministic execution requires that IO only be performed on the last -instruction of a TB so that interrupts take effect immediately. */ -static inline int can_do_io (CPUArchState *env) +/** +* cpu_can_do_io: +* @cpu: The CPU for which to check IO. +* +* Deterministic execution requires that IO only be performed on the last +* instruction of a TB so that interrupts take effect immediately. +* +* Returns: %true if memory-mapped IO is safe, %false otherwise. +*/ +static inline bool cpu_can_do_io (CPUState *cpu) { -CPUState *cpu =ENV_GET_CPU (env); -if (!use_icount) { -return 1 ; +return true; }/* If not executing code then assume we are ok. */ if (cpu->current_tb ==NULL ) { -return 1 ; +return true; } -return env->can_do_io !=0 ; +return cpu->can_do_io !=0 ; }#endif
include/exec/gen-icount.h +2 -2
@@ -51,14 +51,14 @@ static void gen_tb_end(TranslationBlock *tb, int num_insns)static inline void gen_io_start (void ) {TCGv_i32 tmp =tcg_const_i32 (1 ); -tcg_gen_st_i32 (tmp, cpu_env, offsetof(CPUArchState , can_do_io)); +tcg_gen_st_i32 (tmp, cpu_env, -ENV_OFFSET + offsetof(CPUState , can_do_io));tcg_temp_free_i32 (tmp); }static inline void gen_io_end (void ) {TCGv_i32 tmp =tcg_const_i32 (0 ); -tcg_gen_st_i32 (tmp, cpu_env, offsetof(CPUArchState , can_do_io)); +tcg_gen_st_i32 (tmp, cpu_env, -ENV_OFFSET + offsetof(CPUState , can_do_io));tcg_temp_free_i32 (tmp); }
include/exec/softmmu_template.h +2 -2
@@ -81,7 +81,7 @@ static inline DATA_TYPE glue(io_read, SUFFIX)(CPUArchState *env, physaddr = (physaddr &TARGET_PAGE_MASK ) + addr; cpu->mem_io_pc = retaddr; -if (mr != &io_mem_rom && mr != &io_mem_notdirty && !can_do_io (env)) { +if (mr != &io_mem_rom && mr != &io_mem_notdirty && !cpu_can_do_io (cpu)) {cpu_io_recompile (env, retaddr); }
@@ -201,7 +201,7 @@ static inline void glue(io_write, SUFFIX)(CPUArchState *env,MemoryRegion *mr =iotlb_to_region (physaddr); physaddr = (physaddr &TARGET_PAGE_MASK ) + addr; -if (mr != &io_mem_rom && mr != &io_mem_notdirty && !can_do_io (env)) { +if (mr != &io_mem_rom && mr != &io_mem_notdirty && !cpu_can_do_io (cpu)) {cpu_io_recompile (env, retaddr); }
include/qom/cpu.h +2 -0
@@ -160,6 +160,7 @@ struct kvm_run;* @tcg_exit_req: Set to force TCG to stop executing linked TBs for this * CPU and return to its top level loop. * @singlestep_enabled: Flags for single-stepping. +* @can_do_io: Nonzero if memory-mapped IO is safe. * @env_ptr: Pointer to subclass-specific CPUArchState field. * @current_tb: Currently executing TB. * @gdb_regs: Additional GDB registers.
@@ -220,6 +221,7 @@ struct CPUState {/* TODO Move common fields from CPUArchState here. */ int cpu_index;/* used by alpha TCG */ uint32_t halted;/* used by alpha, cris, ppc TCG */ +uint32_t can_do_io; };QTAILQ_HEAD (CPUTailQ, CPUState);
qom/cpu.c +1 -0
@@ -200,6 +200,7 @@ static void cpu_common_reset(CPUState *cpu) cpu->halted =0 ; cpu->mem_io_pc =0 ; cpu->mem_io_vaddr =0 ; + cpu->can_do_io =0 ; }static int cpu_common_mmu_index (const CPUState *cs)
translate-all.c +3 -2
@@ -196,6 +196,7 @@ int cpu_gen_code(CPUArchState *env, TranslationBlock *tb, int *gen_code_size_ptrstatic int cpu_restore_state_from_tb (TranslationBlock *tb,CPUArchState *env,uintptr_t searched_pc) { +CPUState *cpu =ENV_GET_CPU (env);TCGContext *s = &tcg_ctx;int j;uintptr_t tc_ptr;
@@ -214,7 +215,7 @@ static int cpu_restore_state_from_tb(TranslationBlock *tb, CPUArchState *env,/* Reset the cycle counter to the start of the block. */ env->icount_decr.u16.low += tb->icount;/* Clear the IO flag. */ - env->can_do_io =0 ; + cpu->can_do_io =0 ; }/* find opc index corresponding to search_pc */
@@ -1422,7 +1423,7 @@ static void tcg_handle_interrupt(CPUState *cpu, int mask)if (use_icount) { env->icount_decr.u16.high =0xffff ; -if (!can_do_io (env) +if (!cpu_can_do_io (cpu) && (mask & ~old_mask) !=0 ) {cpu_abort (env,"Raised interrupt while not in I/O function" ); }
Signature · 1 line
1.8.1.4
RFC 7/41 cpu: Move icount_extra field from CPU_COMMON to CPUState
In reply to Andreas FärberReset it.
--- cpu-exec.c | 10 +++++----- cpus.c | 14 +++++++------- include/exec/cpu-defs.h | 1 - include/qom/cpu.h | 2 ++ qom/cpu.c | 1 + 5 files changed, 15 insertions(+), 13 deletions(-)
cpu-exec.c +5 -5
@@ -644,15 +644,15 @@ int cpu_exec(CPUArchState *env)int insns_left; tb = (TranslationBlock *)(next_tb & ~TB_EXIT_MASK ); insns_left = env->icount_decr.u32; -if (env->icount_extra && insns_left >=0 ) { +if (cpu->icount_extra && insns_left >=0 ) {/* Refill decrementer and continue execution. */ - env->icount_extra += insns_left; -if (env->icount_extra >0xffff ) { + cpu->icount_extra += insns_left; +if (cpu->icount_extra >0xffff ) { insns_left =0xffff ; }else { - insns_left = env->icount_extra; + insns_left = cpu->icount_extra; } - env->icount_extra -= insns_left; + cpu->icount_extra -= insns_left; env->icount_decr.u16.low = insns_left; }else {if (insns_left >0 ) {
cpus.c +7 -7
@@ -131,7 +131,7 @@ int64_t cpu_get_icount(void)if (!cpu_can_do_io (cpu)) {fprintf (stderr,"Bad clock read\n" ); } - icount -= (env->icount_decr.u16.low + env->icount_extra); + icount -= (env->icount_decr.u16.low + cpu->icount_extra); }return qemu_icount_bias + (icount << icount_time_shift); }
@@ -1147,6 +1147,7 @@ int vm_stop_force_state(RunState state)static int tcg_cpu_exec (CPUArchState *env) { +CPUState *cpu =ENV_GET_CPU (env);int ret;#ifdef CONFIG_PROFILER int64_t ti;
@@ -1159,9 +1160,9 @@ static int tcg_cpu_exec(CPUArchState *env)int64_t count;int64_t deadline;int decr; - qemu_icount -= (env->icount_decr.u16.low + env->icount_extra); + qemu_icount -= (env->icount_decr.u16.low + cpu->icount_extra); env->icount_decr.u16.low =0 ; - env->icount_extra =0 ; + cpu->icount_extra =0 ; deadline =qemu_clock_deadline_ns_all (QEMU_CLOCK_VIRTUAL );/* Maintain prior (possibly buggy) behaviour where if no deadline
@@ -1178,7 +1179,7 @@ static int tcg_cpu_exec(CPUArchState *env) decr = (count >0xffff ) ?0xffff : count; count -= decr; env->icount_decr.u16.low = decr; - env->icount_extra = count; + cpu->icount_extra = count; } ret =cpu_exec (env);#ifdef CONFIG_PROFILER
@@ -1187,10 +1188,9 @@ static int tcg_cpu_exec(CPUArchState *env)if (use_icount) {/* Fold pending instructions back into the instruction counter, and clear the interrupt flag. */ - qemu_icount -= (env->icount_decr.u16.low - + env->icount_extra); + qemu_icount -= (env->icount_decr.u16.low + cpu->icount_extra); env->icount_decr.u32 =0 ; - env->icount_extra =0 ; + cpu->icount_extra =0 ; }return ret; }
include/exec/cpu-defs.h +0 -1
@@ -148,7 +148,6 @@ typedef struct CPUWatchpoint {CPU_COMMON_TLB \ struct TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE]; \ \ -int64_t icount_extra;/* Instructions until next timer event. */ \/* Number of cycles left, with interrupt flag in high bit. \ This allows a single read-compare-cbranch-write sequence to test \ for both decrementer underflow and exceptions. */ \
include/qom/cpu.h +2 -0
@@ -160,6 +160,7 @@ struct kvm_run;* @tcg_exit_req: Set to force TCG to stop executing linked TBs for this * CPU and return to its top level loop. * @singlestep_enabled: Flags for single-stepping. +* @icount_extra: Instructions until next timer event. * @can_do_io: Nonzero if memory-mapped IO is safe. * @env_ptr: Pointer to subclass-specific CPUArchState field. * @current_tb: Currently executing TB.
@@ -199,6 +200,7 @@ struct CPUState {volatile sig_atomic_t tcg_exit_req;uint32_t interrupt_request;int singlestep_enabled; +int64_t icount_extra;void *env_ptr;/* CPUArchState */ struct TranslationBlock *current_tb;
qom/cpu.c +1 -0
@@ -200,6 +200,7 @@ static void cpu_common_reset(CPUState *cpu) cpu->halted =0 ; cpu->mem_io_pc =0 ; cpu->mem_io_vaddr =0 ; + cpu->icount_extra =0 ; cpu->can_do_io =0 ; }
Signature · 1 line
1.8.1.4
RFC 8/41 cpu: Move icount_decr field from CPU_COMMON to CPUState
In reply to Andreas Färber--- cpu-exec.c | 4 ++-- cpus.c | 13 ++++++------- include/exec/cpu-defs.h | 20 -------------------- include/exec/gen-icount.h | 6 ++++-- include/qom/cpu.h | 19 +++++++++++++++++++ qom/cpu.c | 1 + translate-all.c | 15 ++++++++------- 7 files changed, 40 insertions(+), 38 deletions(-)
cpu-exec.c +2 -2
@@ -643,7 +643,7 @@ int cpu_exec(CPUArchState *env)/* Instruction counter expired. */ int insns_left; tb = (TranslationBlock *)(next_tb & ~TB_EXIT_MASK ); - insns_left = env->icount_decr.u32; + insns_left = cpu->icount_decr.u32;if (cpu->icount_extra && insns_left >=0 ) {/* Refill decrementer and continue execution. */ cpu->icount_extra += insns_left;
@@ -653,7 +653,7 @@ int cpu_exec(CPUArchState *env) insns_left = cpu->icount_extra; } cpu->icount_extra -= insns_left; - env->icount_decr.u16.low = insns_left; + cpu->icount_decr.u16.low = insns_left; }else {if (insns_left >0 ) {/* Execute remaining instructions. */
cpus.c +6 -7
@@ -127,11 +127,10 @@ int64_t cpu_get_icount(void) icount = qemu_icount;if (cpu) { -CPUArchState *env = cpu->env_ptr;if (!cpu_can_do_io (cpu)) {fprintf (stderr,"Bad clock read\n" ); } - icount -= (env->icount_decr.u16.low + cpu->icount_extra); + icount -= (cpu->icount_decr.u16.low + cpu->icount_extra); }return qemu_icount_bias + (icount << icount_time_shift); }
@@ -1160,8 +1159,8 @@ static int tcg_cpu_exec(CPUArchState *env)int64_t count;int64_t deadline;int decr; - qemu_icount -= (env->icount_decr.u16.low + cpu->icount_extra); - env->icount_decr.u16.low =0 ; + qemu_icount -= (cpu->icount_decr.u16.low + cpu->icount_extra); + cpu->icount_decr.u16.low =0 ; cpu->icount_extra =0 ; deadline =qemu_clock_deadline_ns_all (QEMU_CLOCK_VIRTUAL );
@@ -1178,7 +1177,7 @@ static int tcg_cpu_exec(CPUArchState *env) qemu_icount += count; decr = (count >0xffff ) ?0xffff : count; count -= decr; - env->icount_decr.u16.low = decr; + cpu->icount_decr.u16.low = decr; cpu->icount_extra = count; } ret =cpu_exec (env);
@@ -1188,8 +1187,8 @@ static int tcg_cpu_exec(CPUArchState *env)if (use_icount) {/* Fold pending instructions back into the instruction counter, and clear the interrupt flag. */ - qemu_icount -= (env->icount_decr.u16.low + cpu->icount_extra); - env->icount_decr.u32 =0 ; + qemu_icount -= (cpu->icount_decr.u16.low + cpu->icount_extra); + cpu->icount_decr.u32 =0 ; cpu->icount_extra =0 ; }return ret;
include/exec/cpu-defs.h +0 -20
@@ -117,18 +117,6 @@ QEMU_BUILD_BUG_ON(sizeof(CPUTLBEntry) != (1 << CPU_TLB_ENTRY_BITS));#endif -#ifdef HOST_WORDS_BIGENDIAN -typedef struct icount_decr_u16 { -uint16_t high; -uint16_t low; -}icount_decr_u16 ; -#else -typedef struct icount_decr_u16 { -uint16_t low; -uint16_t high; -}icount_decr_u16 ; -#endif - typedef struct CPUBreakpoint { target_ulong pc; int flags; /* BP_* */
@@ -148,14 +136,6 @@ typedef struct CPUWatchpoint {CPU_COMMON_TLB \ struct TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE]; \ \ -/* Number of cycles left, with interrupt flag in high bit. \ -This allows a single read-compare-cbranch-write sequence to test \ -for both decrementer underflow and exceptions. */ \ -union { \ -uint32_t u32; \ -icount_decr_u16 u16; \ - } icount_decr; \ - \/* from this point: preserved by CPU reset */ \/* ice debug support */ \ QTAILQ_HEAD(breakpoints_head, CPUBreakpoint) breakpoints; \
include/exec/gen-icount.h +4 -2
@@ -26,13 +26,15 @@ static inline void gen_tb_start(void) icount_label =gen_new_label (); count =tcg_temp_local_new_i32 (); - tcg_gen_ld_i32(count, cpu_env, offsetof(CPUArchState, icount_decr.u32)); +tcg_gen_ld_i32 (count, cpu_env, + -ENV_OFFSET + offsetof(CPUState, icount_decr.u32));/* This is a horrid hack to allow fixing up the value later. */ icount_arg = tcg_ctx.gen_opparam_ptr +1 ;tcg_gen_subi_i32 (count, count,0xdeadbeef );tcg_gen_brcondi_i32 (TCG_COND_LT , count,0 , icount_label); - tcg_gen_st16_i32(count, cpu_env, offsetof(CPUArchState, icount_decr.u16.low)); +tcg_gen_st16_i32 (count, cpu_env, + -ENV_OFFSET + offsetof(CPUState, icount_decr.u16.low));tcg_temp_free_i32 (count); }
include/qom/cpu.h +19 -0
@@ -141,6 +141,18 @@ typedef struct CPUClass {const char *gdb_core_xml_file; } CPUClass; +#ifdef HOST_WORDS_BIGENDIAN +typedef struct icount_decr_u16 { +uint16_t high; +uint16_t low; +}icount_decr_u16 ; +#else +typedef struct icount_decr_u16 { +uint16_t low; +uint16_t high; +}icount_decr_u16 ; +#endif +struct KVMState ;struct kvm_run ;
@@ -161,6 +173,9 @@ struct kvm_run;* CPU and return to its top level loop. * @singlestep_enabled: Flags for single-stepping. * @icount_extra: Instructions until next timer event. +* @icount_decr: Number of cycles left, with interrupt flag in high bit. +* This allows a single read-compare-cbranch-write sequence to test +* for both decrementer underflow and exceptions. * @can_do_io: Nonzero if memory-mapped IO is safe. * @env_ptr: Pointer to subclass-specific CPUArchState field. * @current_tb: Currently executing TB.
@@ -223,6 +238,10 @@ struct CPUState {/* TODO Move common fields from CPUArchState here. */ int cpu_index;/* used by alpha TCG */ uint32_t halted;/* used by alpha, cris, ppc TCG */ +union { +uint32_t u32; +icount_decr_u16 u16; + } icount_decr;uint32_t can_do_io; };
qom/cpu.c +1 -0
@@ -201,6 +201,7 @@ static void cpu_common_reset(CPUState *cpu) cpu->mem_io_pc =0 ; cpu->mem_io_vaddr =0 ; cpu->icount_extra =0 ; + cpu->icount_decr.u32 =0 ; cpu->can_do_io =0 ; }
translate-all.c +8 -7
@@ -213,7 +213,7 @@ static int cpu_restore_state_from_tb(TranslationBlock *tb, CPUArchState *env,if (use_icount) {/* Reset the cycle counter to the start of the block. */ - env->icount_decr.u16.low += tb->icount; + cpu->icount_decr.u16.low += tb->icount;/* Clear the IO flag. */ cpu->can_do_io =0 ; }
@@ -238,7 +238,7 @@ static int cpu_restore_state_from_tb(TranslationBlock *tb, CPUArchState *env,while (s->gen_opc_instr_start[j] ==0 ) { j--; } - env->icount_decr.u16.low -= s->gen_opc_icount[j]; + cpu->icount_decr.u16.low -= s->gen_opc_icount[j];restore_state_to_opc (env, tb, j);
@@ -1422,7 +1422,7 @@ static void tcg_handle_interrupt(CPUState *cpu, int mask) }if (use_icount) { - env->icount_decr.u16.high =0xffff ; + cpu->icount_decr.u16.high =0xffff ;if (!cpu_can_do_io (cpu) && (mask & ~old_mask) !=0 ) {cpu_abort (env,"Raised interrupt while not in I/O function" );
@@ -1438,6 +1438,7 @@ CPUInterruptHandler cpu_interrupt_handler = tcg_handle_interrupt;must be at the end of the TB */ void cpu_io_recompile (CPUArchState *env,uintptr_t retaddr) { +CPUState *cpu =ENV_GET_CPU (env);TranslationBlock *tb;uint32_t n, cflags;target_ulong pc, cs_base;
@@ -1448,11 +1449,11 @@ void cpu_io_recompile(CPUArchState *env, uintptr_t retaddr)cpu_abort (env,"cpu_io_recompile: could not find TB for pc=%p" , (void *)retaddr); } - n = env->icount_decr.u16.low + tb->icount; + n = cpu->icount_decr.u16.low + tb->icount;cpu_restore_state_from_tb (tb, env, retaddr);/* Calculate how many instructions had been executed before the fault occurred. */ - n = n - env->icount_decr.u16.low; + n = n - cpu->icount_decr.u16.low;/* Generate a new TB ending on the I/O insn. */ n++;/* On MIPS and SH, delay slot instructions can only be restarted if
@@ -1462,14 +1463,14 @@ void cpu_io_recompile(CPUArchState *env, uintptr_t retaddr)#if defined(TARGET_MIPS )if ((env->hflags &MIPS_HFLAG_BMASK ) !=0 && n >1 ) { env->active_tc.PC -=4 ; - env->icount_decr.u16.low++; + cpu->icount_decr.u16.low++; env->hflags &= ~MIPS_HFLAG_BMASK ; }#elif defined(TARGET_SH4 )if ((env->flags & ((DELAY_SLOT |DELAY_SLOT_CONDITIONAL ))) !=0 && n >1 ) { env->pc -=2 ; - env->icount_decr.u16.low++; + cpu->icount_decr.u16.low++; env->flags &= ~(DELAY_SLOT |DELAY_SLOT_CONDITIONAL ); }#endif
Signature · 1 line
1.8.1.4
RFC 9/41 cpu: Move tb_jmp_cache field from CPU_COMMON to CPUState
In reply to Andreas FärberClear it on reset.
--- cpu-exec.c | 5 +++-- cputlb.c | 2 +- include/exec/cpu-defs.h | 4 ---- include/qom/cpu.h | 4 ++++ qom/cpu.c | 1 + translate-all.c | 15 ++++++--------- 6 files changed, 15 insertions(+), 16 deletions(-)
cpu-exec.c +3 -2
@@ -100,6 +100,7 @@ static TranslationBlock *tb_find_slow(CPUArchState *env, target_ulong cs_base, uint64_t flags) { +CPUState *cpu =ENV_GET_CPU (env);TranslationBlock *tb, **ptb1;unsigned int h;tb_page_addr_t phys_pc, phys_page1;
@@ -147,7 +148,7 @@ static TranslationBlock *tb_find_slow(CPUArchState *env, tcg_ctx.tb_ctx.tb_phys_hash[h] = tb; }/* we add the TB in the virtual pc hash table */ - env->tb_jmp_cache[tb_jmp_cache_hash_func (pc)] = tb; + cpu->tb_jmp_cache[tb_jmp_cache_hash_func (pc)] = tb;return tb; }
@@ -163,7 +164,7 @@ static inline TranslationBlock *tb_find_fast(CPUArchState *env)always be the same before a given translated block is executed. */ cc->get_tb_cpu_state (cpu, &pc, &cs_base, &flags); - tb = env->tb_jmp_cache[tb_jmp_cache_hash_func (pc)]; + tb = cpu->tb_jmp_cache[tb_jmp_cache_hash_func (pc)];if (unlikely (!tb || tb->pc != pc || tb->cs_base != cs_base || tb->flags != flags)) { tb =tb_find_slow (env, pc, cs_base, flags);
cputlb.c +1 -1
@@ -72,7 +72,7 @@ void tlb_flush(CPUArchState *env, int flush_global) } } -memset (env->tb_jmp_cache,0 ,TB_JMP_CACHE_SIZE *sizeof (void *)); +memset (cpu->tb_jmp_cache,0 ,TB_JMP_CACHE_SIZE *sizeof (void *)); env->tlb_flush_addr =-1 ; env->tlb_flush_mask =0 ;
include/exec/cpu-defs.h +0 -4
@@ -60,9 +60,6 @@ typedef uint64_t target_ulong;#define EXCP_DEBUG 0x10002/* cpu stopped after a breakpoint or singlestep */ #define EXCP_HALTED 0x10003/* cpu is halted (waiting for external event) */ -#define TB_JMP_CACHE_BITS 12 -#define TB_JMP_CACHE_SIZE (1 << TB_JMP_CACHE_BITS) -/* Only the bottom TB_JMP_PAGE_BITS of the jump cache hash bits vary for addresses on the same page. The top bits are the same. This allows TLB invalidation to quickly clear a subset of the hash table. */
@@ -134,7 +131,6 @@ typedef struct CPUWatchpoint {#define CPU_COMMON \/* soft mmu support */ \ CPU_COMMON_TLB \ - struct TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE]; \ \/* from this point: preserved by CPU reset */ \/* ice debug support */ \
include/qom/cpu.h +4 -0
@@ -156,6 +156,9 @@ typedef struct icount_decr_u16 {struct KVMState ;struct kvm_run ; +#define TB_JMP_CACHE_BITS 12 +#define TB_JMP_CACHE_SIZE (1 << TB_JMP_CACHE_BITS) +/** * CPUState: * @cpu_index: CPU index (informative).
@@ -219,6 +222,7 @@ struct CPUState {void *env_ptr;/* CPUArchState */ struct TranslationBlock *current_tb; +struct TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE ];struct GDBRegisterState *gdb_regs;int gdb_num_regs;int gdb_num_g_regs;
qom/cpu.c +1 -0
@@ -203,6 +203,7 @@ static void cpu_common_reset(CPUState *cpu) cpu->icount_extra =0 ; cpu->icount_decr.u32 =0 ; cpu->can_do_io =0 ; +memset (cpu->tb_jmp_cache,0 ,TB_JMP_CACHE_SIZE *sizeof (void *)); }static int cpu_common_mmu_index (const CPUState *cs)
translate-all.c +6 -9
@@ -698,9 +698,7 @@ void tb_flush(CPUArchState *env1) tcg_ctx.tb_ctx.nb_tbs =0 ;CPU_FOREACH (cpu) { -CPUArchState *env = cpu->env_ptr; - -memset (env->tb_jmp_cache,0 ,TB_JMP_CACHE_SIZE *sizeof (void *)); +memset (cpu->tb_jmp_cache,0 ,TB_JMP_CACHE_SIZE *sizeof (void *)); } memset(tcg_ctx.tb_ctx.tb_phys_hash, 0,
@@ -852,10 +850,8 @@ void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr)/* remove the TB from the hash list */ h =tb_jmp_cache_hash_func (tb->pc);CPU_FOREACH (cpu) { -CPUArchState *env = cpu->env_ptr; - -if (env->tb_jmp_cache[h] == tb) { - env->tb_jmp_cache[h] =NULL ; +if (cpu->tb_jmp_cache[h] == tb) { + cpu->tb_jmp_cache[h] =NULL ; } }
@@ -1497,16 +1493,17 @@ void cpu_io_recompile(CPUArchState *env, uintptr_t retaddr)void tb_flush_jmp_cache (CPUArchState *env,target_ulong addr) { +CPUState *cpu =ENV_GET_CPU (env);unsigned int i;/* Discard jump cache entries for any tb which might potentially overlap the flushed page. */ i =tb_jmp_cache_hash_page (addr -TARGET_PAGE_SIZE ); -memset (&env->tb_jmp_cache[i],0 , +memset (&cpu->tb_jmp_cache[i],0 ,TB_JMP_PAGE_SIZE *sizeof (TranslationBlock *)); i =tb_jmp_cache_hash_page (addr); -memset (&env->tb_jmp_cache[i],0 , +memset (&cpu->tb_jmp_cache[i],0 ,TB_JMP_PAGE_SIZE *sizeof (TranslationBlock *)); }
Signature · 1 line
1.8.1.4
RFC 10/41 cpu: Move jmp_env field from CPU_COMMON to CPUState
In reply to Andreas Färber--- cpu-exec.c | 8 +++++--- include/exec/cpu-defs.h | 2 -- include/qom/cpu.h | 2 ++ user-exec.c | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-)
cpu-exec.c +5 -3
@@ -28,7 +28,7 @@ void cpu_loop_exit(CPUArchState *env)CPUState *cpu =ENV_GET_CPU (env); cpu->current_tb =NULL ; -siglongjmp (env->jmp_env,1 ); +siglongjmp (cpu->jmp_env,1 ); }/* exit the current TB from a signal handler. The host registers are
@@ -37,10 +37,12 @@ void cpu_loop_exit(CPUArchState *env)#if defined(CONFIG_SOFTMMU )void cpu_resume_from_signal (CPUArchState *env,void *puc) { +CPUState *cpu =ENV_GET_CPU (env); +/* XXX: restore cpu registers saved in host registers */ env->exception_index =-1 ; -siglongjmp (env->jmp_env,1 ); +siglongjmp (cpu->jmp_env,1 ); }#endif
@@ -264,7 +266,7 @@ int cpu_exec(CPUArchState *env)/* prepare setjmp context for exception handling */ for (;;) { -if (sigsetjmp (env->jmp_env,0 ) ==0 ) { +if (sigsetjmp (cpu->jmp_env,0 ) ==0 ) {/* if an exception is pending, we execute it here */ if (env->exception_index >=0 ) {if (env->exception_index >=EXCP_INTERRUPT ) {
include/exec/cpu-defs.h +0 -2
@@ -24,7 +24,6 @@#endif #include "config.h" -#include <setjmp.h> #include <inttypes.h> #include "qemu/osdep.h" #include "qemu/queue.h"
@@ -140,7 +139,6 @@ typedef struct CPUWatchpoint {CPUWatchpoint *watchpoint_hit; \ \/* Core interrupt code */ \ -sigjmp_buf jmp_env; \int exception_index; \ \/* user data */ \
include/qom/cpu.h +2 -0
@@ -21,6 +21,7 @@#define QEMU_CPU_H #include <signal.h> +#include <setjmp.h> #include "hw/qdev-core.h" #include "exec/hwaddr.h" #include "qemu/queue.h"
@@ -219,6 +220,7 @@ struct CPUState {uint32_t interrupt_request;int singlestep_enabled;int64_t icount_extra; +sigjmp_buf jmp_env;void *env_ptr;/* CPUArchState */ struct TranslationBlock *current_tb;
user-exec.c +2 -1
@@ -52,6 +52,7 @@ static void exception_action(CPUArchState *env1)*/ void cpu_resume_from_signal (CPUArchState *env1,void *puc) { +CPUState *cpu =ENV_GET_CPU (env1);#ifdef __linux__struct ucontext *uc = puc;#elif defined(__OpenBSD__)
@@ -71,7 +72,7 @@ void cpu_resume_from_signal(CPUArchState *env1, void *puc)#endif } env1->exception_index =-1 ; -siglongjmp (env1->jmp_env,1 ); +siglongjmp (cpu->jmp_env,1 ); }/* 'pc' is the host PC at which the exception was raised. 'address' is
Signature · 1 line
1.8.1.4
RFC 11/41 cpu: Move exception_index field from CPU_COMMON to CPUState
In reply to Andreas Färber--- cpu-exec.c | 50 +++++++++++++++++++++--------------------- exec.c | 2 +- hw/ppc/e500.c | 3 +-- hw/ppc/ppce500_spin.c | 2 +- hw/ppc/spapr_hcall.c | 2 +- hw/s390x/s390-virtio.c | 8 +++---- include/exec/cpu-defs.h | 3 --- include/qom/cpu.h | 1 + linux-user/signal.c | 7 +++--- target-alpha/helper.c | 18 ++++++++++----- target-alpha/mem_helper.c | 4 +++- target-arm/helper.c | 25 ++++++++++----------- target-arm/op_helper.c | 16 +++++++++----- target-cris/helper.c | 18 +++++++-------- target-cris/op_helper.c | 6 +++-- target-i386/excp_helper.c | 4 +++- target-i386/helper.c | 6 ++--- target-i386/mem_helper.c | 5 +++-- target-i386/misc_helper.c | 6 +++-- target-i386/seg_helper.c | 8 ++++--- target-i386/svm_helper.c | 13 ++++++----- target-lm32/helper.c | 12 +++++----- target-lm32/op_helper.c | 6 +++-- target-m68k/helper.c | 2 +- target-m68k/op_helper.c | 22 +++++++++---------- target-m68k/qregs.def | 1 - target-m68k/translate.c | 5 +++++ target-microblaze/helper.c | 16 ++++++-------- target-microblaze/op_helper.c | 4 +++- target-mips/helper.c | 31 ++++++++++++++------------ target-mips/op_helper.c | 9 +++++--- target-mips/translate.c | 4 +--- target-moxie/helper.c | 21 ++++++++++-------- target-openrisc/cpu.c | 2 +- target-openrisc/exception.c | 4 +++- target-openrisc/interrupt.c | 27 ++++++++++++----------- target-openrisc/mmu.c | 3 ++- target-ppc/excp_helper.c | 19 +++++++++------- target-ppc/fpu_helper.c | 26 +++++++++++++++------- target-ppc/mmu-hash32.c | 24 ++++++++++---------- target-ppc/mmu-hash64.c | 15 +++++++------ target-ppc/mmu_helper.c | 43 ++++++++++++++++++------------------ target-ppc/translate_init.c | 2 +- target-ppc/user_only_helper.c | 2 +- target-s390x/helper.c | 39 ++++++++++++++++----------------- target-s390x/mem_helper.c | 9 ++++---- target-s390x/misc_helper.c | 15 +++++++++---- target-sh4/helper.c | 51 +++++++++++++++++++++---------------------- target-sh4/op_helper.c | 4 +++- target-sparc/helper.c | 10 ++++++--- target-sparc/int32_helper.c | 8 +++---- target-sparc/int64_helper.c | 6 ++--- target-sparc/ldst_helper.c | 3 ++- target-sparc/mmu_helper.c | 22 +++++++++---------- target-unicore32/op_helper.c | 4 +++- target-unicore32/softmmu.c | 8 +++---- target-xtensa/helper.c | 20 +++++++++-------- target-xtensa/op_helper.c | 4 +++- user-exec.c | 6 +++-- 59 files changed, 393 insertions(+), 323 deletions(-)
cpu-exec.c +25 -25
@@ -41,7 +41,7 @@ void cpu_resume_from_signal(CPUArchState *env, void *puc)/* XXX: restore cpu registers saved in host registers */ - env->exception_index =-1 ; + cpu->exception_index =-1 ; siglongjmp(cpu->jmp_env, 1); }#endif
@@ -262,16 +262,16 @@ int cpu_exec(CPUArchState *env)#else #error unsupported target CPU#endif - env->exception_index =-1 ; + cpu->exception_index =-1 ;/* prepare setjmp context for exception handling */ for (;;) {if (sigsetjmp (cpu->jmp_env,0 ) ==0 ) {/* if an exception is pending, we execute it here */ -if (env->exception_index >=0 ) { -if (env->exception_index >=EXCP_INTERRUPT ) { +if (cpu->exception_index >=0 ) { +if (cpu->exception_index >=EXCP_INTERRUPT ) {/* exit request from the cpu execution loop */ - ret = env->exception_index; + ret = cpu->exception_index;if (ret ==EXCP_DEBUG ) {cpu_handle_debug_exception (env); }
@@ -284,11 +284,11 @@ int cpu_exec(CPUArchState *env)#if defined(TARGET_I386 ) cc->do_interrupt (cpu);#endif - ret = env->exception_index; + ret = cpu->exception_index;break ;#else cc->do_interrupt (cpu); - env->exception_index =-1 ; + cpu->exception_index =-1 ;#endif } }
@@ -303,7 +303,7 @@ int cpu_exec(CPUArchState *env) }if (interrupt_request &CPU_INTERRUPT_DEBUG ) { cpu->interrupt_request &= ~CPU_INTERRUPT_DEBUG ; - env->exception_index =EXCP_DEBUG ; + cpu->exception_index =EXCP_DEBUG ;cpu_loop_exit (env); } #if defined(TARGET_ARM) || defined(TARGET_SPARC) || defined(TARGET_MIPS) || \
@@ -312,7 +312,7 @@ int cpu_exec(CPUArchState *env)if (interrupt_request &CPU_INTERRUPT_HALT ) { cpu->interrupt_request &= ~CPU_INTERRUPT_HALT ; cpu->halted =1 ; - env->exception_index =EXCP_HLT ; + cpu->exception_index =EXCP_HLT ;cpu_loop_exit (env); }#endif
@@ -327,7 +327,7 @@ int cpu_exec(CPUArchState *env)cpu_svm_check_intercept_param (env,SVM_EXIT_INIT ,0 );do_cpu_init (x86_env_get_cpu (env)); - env->exception_index =EXCP_HALTED ; + cpu->exception_index =EXCP_HALTED ;cpu_loop_exit (env); }else if (interrupt_request &CPU_INTERRUPT_SIPI ) {do_cpu_sipi (x86_env_get_cpu (env));
@@ -396,7 +396,7 @@ int cpu_exec(CPUArchState *env)#elif defined(TARGET_LM32 )if ((interrupt_request &CPU_INTERRUPT_HARD ) && (env->ie &IE_IE )) { - env->exception_index =EXCP_IRQ ; + cpu->exception_index =EXCP_IRQ ; cc->do_interrupt (cpu); next_tb =0 ; }
@@ -405,7 +405,7 @@ int cpu_exec(CPUArchState *env) && (env->sregs[SR_MSR ] &MSR_IE ) && !(env->sregs[SR_MSR ] & (MSR_EIP |MSR_BIP )) && !(env->iflags & (D_FLAG | IMM_FLAG))) { - env->exception_index = EXCP_IRQ; + cpu->exception_index = EXCP_IRQ; cc->do_interrupt (cpu); next_tb =0 ; }
@@ -413,7 +413,7 @@ int cpu_exec(CPUArchState *env)if ((interrupt_request &CPU_INTERRUPT_HARD ) &&cpu_mips_hw_interrupts_pending (env)) {/* Raise it */ - env->exception_index =EXCP_EXT_INTERRUPT ; + cpu->exception_index =EXCP_EXT_INTERRUPT ; env->error_code =0 ; cc->do_interrupt (cpu); next_tb =0 ;
@@ -430,7 +430,7 @@ int cpu_exec(CPUArchState *env) idx =EXCP_TICK ; }if (idx >=0 ) { - env->exception_index = idx; + cpu->exception_index = idx; cc->do_interrupt (cpu); next_tb =0 ; }
@@ -445,7 +445,7 @@ int cpu_exec(CPUArchState *env)if (((type ==TT_EXTINT ) &&cpu_pil_allowed (env, pil)) || type !=TT_EXTINT ) { - env->exception_index = env->interrupt_index; + cpu->exception_index = env->interrupt_index; cc->do_interrupt (cpu); next_tb =0 ; }
@@ -454,7 +454,7 @@ int cpu_exec(CPUArchState *env)#elif defined(TARGET_ARM )if (interrupt_request &CPU_INTERRUPT_FIQ && !(env->uncached_cpsr &CPSR_F )) { - env->exception_index =EXCP_FIQ ; + cpu->exception_index =EXCP_FIQ ; cc->do_interrupt (cpu); next_tb =0 ; }
@@ -470,14 +470,14 @@ int cpu_exec(CPUArchState *env)if (interrupt_request &CPU_INTERRUPT_HARD && ((IS_M (env) && env->regs[15 ] <0xfffffff0 ) || !(env->uncached_cpsr &CPSR_I ))) { - env->exception_index =EXCP_IRQ ; + cpu->exception_index =EXCP_IRQ ; cc->do_interrupt (cpu); next_tb =0 ; }#elif defined(TARGET_UNICORE32 )if (interrupt_request &CPU_INTERRUPT_HARD && !(env->uncached_asr &ASR_I )) { - env->exception_index =UC32_EXCP_INTR ; + cpu->exception_index =UC32_EXCP_INTR ; cc->do_interrupt (cpu); next_tb =0 ; }
@@ -512,7 +512,7 @@ int cpu_exec(CPUArchState *env) } }if (idx >=0 ) { - env->exception_index = idx; + cpu->exception_index = idx; env->error_code =0 ; cc->do_interrupt (cpu); next_tb =0 ;
@@ -522,7 +522,7 @@ int cpu_exec(CPUArchState *env)if (interrupt_request &CPU_INTERRUPT_HARD && (env->pregs[PR_CCS ] &I_FLAG ) && !env->locked_irq) { - env->exception_index =EXCP_IRQ ; + cpu->exception_index =EXCP_IRQ ; cc->do_interrupt (cpu); next_tb =0 ; }
@@ -534,7 +534,7 @@ int cpu_exec(CPUArchState *env) m_flag_archval =M_FLAG_V32 ; }if ((env->pregs[PR_CCS ] & m_flag_archval)) { - env->exception_index =EXCP_NMI ; + cpu->exception_index =EXCP_NMI ; cc->do_interrupt (cpu); next_tb =0 ; }
@@ -548,7 +548,7 @@ int cpu_exec(CPUArchState *env)hardware doesn't rely on this, so we provide/save the vector when the interrupt is first signalled. */ - env->exception_index = env->pending_vector; + cpu->exception_index = env->pending_vector;do_interrupt_m68k_hardirq (env); next_tb =0 ; }
@@ -560,7 +560,7 @@ int cpu_exec(CPUArchState *env) }#elif defined(TARGET_XTENSA)if (interrupt_request &CPU_INTERRUPT_HARD ) { - env->exception_index =EXC_IRQ ; + cpu->exception_index =EXC_IRQ ; cc->do_interrupt (cpu); next_tb =0 ; }
@@ -576,7 +576,7 @@ int cpu_exec(CPUArchState *env) }if (unlikely (cpu->exit_request)) { cpu->exit_request =0 ; - env->exception_index =EXCP_INTERRUPT ; + cpu->exception_index =EXCP_INTERRUPT ;cpu_loop_exit (env); }#if defined(DEBUG_DISAS )
@@ -662,7 +662,7 @@ int cpu_exec(CPUArchState *env)/* Execute remaining instructions. */ cpu_exec_nocache (env, insns_left, tb); } - env->exception_index =EXCP_INTERRUPT ; + cpu->exception_index =EXCP_INTERRUPT ; next_tb =0 ;cpu_loop_exit (env); }
exec.c +1 -1
@@ -1502,7 +1502,7 @@ static void check_watchpoint(int offset, int len_mask, int flags) env->watchpoint_hit = wp;tb_check_watchpoint (env);if (wp->flags &BP_STOP_BEFORE_ACCESS ) { - env->exception_index =EXCP_DEBUG ; + cpu->exception_index =EXCP_DEBUG ;cpu_loop_exit (env); }else { cc->get_tb_cpu_state (cpu, &pc, &cs_base, &cpu_flags);
hw/ppc/e500.c +1 -2
@@ -468,14 +468,13 @@ static void ppce500_cpu_reset_sec(void *opaque) {PowerPCCPU *cpu = opaque;CPUState *cs =CPU (cpu); -CPUPPCState *env = &cpu->env;cpu_reset (cs);/* Secondary CPU starts in halted state for now. Needs to change when implementing non-kernel boot. */ cs->halted =1 ; - env->exception_index =EXCP_HLT ; + cs->exception_index =EXCP_HLT ; }static void ppce500_cpu_reset (void *opaque)
hw/ppc/ppce500_spin.c +1 -1
@@ -117,7 +117,7 @@ static void spin_kick(void *data)mmubooke_create_initial_mapping (env,0 , map_start, map_size); cpu->halted =0 ; - env->exception_index =-1 ; + cpu->exception_index =-1 ; cpu->stopped = false;qemu_cpu_kick (cpu); }
hw/ppc/spapr_hcall.c +1 -1
@@ -511,7 +511,7 @@ static target_ulong h_cede(PowerPCCPU *cpu, sPAPREnvironment *spapr,hreg_compute_hflags (env);if (!cpu_has_work (cs)) { cs->halted =1 ; - env->exception_index =EXCP_HLT ; + cs->exception_index =EXCP_HLT ; cs->exit_request =1 ; }return H_SUCCESS ;
hw/s390x/s390-virtio.c +3 -5
@@ -134,25 +134,23 @@ static unsigned s390_running_cpus;void s390_add_running_cpu (S390CPU *cpu) {CPUState *cs =CPU (cpu); -CPUS390XState *env = &cpu->env;if (cs->halted) { s390_running_cpus++; cs->halted =0 ; - env->exception_index =-1 ; + cs->exception_index =-1 ; } }unsigned s390_del_running_cpu (S390CPU *cpu) {CPUState *cs =CPU (cpu); -CPUS390XState *env = &cpu->env;if (cs->halted ==0 ) {assert (s390_running_cpus >=1 ); s390_running_cpus--; cs->halted =1 ; - env->exception_index =EXCP_HLT ; + cs->exception_index =EXCP_HLT ; }return s390_running_cpus; }
@@ -195,7 +193,7 @@ void s390_init_cpus(const char *cpu_model, uint8_t *storage_keys) ipi_states[i] = cpu; cs->halted =1 ; - cpu->env.exception_index =EXCP_HLT ; + cs->exception_index =EXCP_HLT ; cpu->env.storage_keys = storage_keys; } }
include/exec/cpu-defs.h +0 -3
@@ -138,9 +138,6 @@ typedef struct CPUWatchpoint { QTAILQ_HEAD(watchpoints_head, CPUWatchpoint) watchpoints; \CPUWatchpoint *watchpoint_hit; \ \ -/* Core interrupt code */ \ -int exception_index; \ - \/* user data */ \void *opaque; \ \
include/qom/cpu.h +1 -0
@@ -249,6 +249,7 @@ struct CPUState {icount_decr_u16 u16; } icount_decr;uint32_t can_do_io; +int32_t exception_index;/* used by m68k TCG */ };QTAILQ_HEAD (CPUTailQ, CPUState);
linux-user/signal.c +4 -3
@@ -773,8 +773,9 @@ static int setup_sigcontext(struct target_sigcontext *sc, struct target_fpstate *fpstate, CPUX86State *env, abi_ulong mask, abi_ulong fpstate_addr) { - int err = 0; -uint16_t magic; + CPUState *cs = CPU(x86_env_get_cpu(env)); +int err =0 ; +uint16_t magic;/* already locked in setup_frame() */ err |=__put_user (env->segs[R_GS ].selector, (unsigned int *)&sc->gs);
@@ -789,7 +790,7 @@ setup_sigcontext(struct target_sigcontext *sc, struct target_fpstate *fpstate, err |=__put_user (env->regs[R_EDX ], &sc->edx); err |=__put_user (env->regs[R_ECX ], &sc->ecx); err |=__put_user (env->regs[R_EAX ], &sc->eax); - err |=__put_user (env->exception_index, &sc->trapno); + err |=__put_user (cs->exception_index, &sc->trapno); err |=__put_user (env->error_code, &sc->err); err |=__put_user (env->eip, &sc->eip); err |=__put_user (env->segs[R_CS ].selector, (unsigned int *)&sc->cs);
target-alpha/helper.c +12 -6
@@ -173,7 +173,7 @@ int alpha_cpu_handle_mmu_fault(CPUState *cs, vaddr address, {AlphaCPU *cpu =ALPHA_CPU (cs); - cpu->env.exception_index =EXCP_MMFAULT ; + cs->exception_index =EXCP_MMFAULT ; cpu->env.trap_arg0 = address;return 1 ; }
@@ -337,7 +337,7 @@ int alpha_cpu_handle_mmu_fault(CPUState *cs, vaddr addr, int rw, fail =get_physical_address (env, addr,1 << rw, mmu_idx, &phys, &prot);if (unlikely (fail >=0 )) { - env->exception_index =EXCP_MMFAULT ; + cs->exception_index =EXCP_MMFAULT ; env->trap_arg0 = addr; env->trap_arg1 = fail; env->trap_arg2 = (rw ==2 ?-1 : rw);
@@ -354,7 +354,7 @@ void alpha_cpu_do_interrupt(CPUState *cs) {AlphaCPU *cpu =ALPHA_CPU (cs);CPUAlphaState *env = &cpu->env; -int i = env->exception_index; +int i = cs->exception_index;if (qemu_loglevel_mask (CPU_LOG_INT )) {static int count;
@@ -405,7 +405,7 @@ void alpha_cpu_do_interrupt(CPUState *cs) ++count, name, env->error_code, env->pc, env->ir[IR_SP]); } - env->exception_index =-1 ; + cs->exception_index =-1 ;#if !defined(CONFIG_USER_ONLY )switch (i) {
@@ -507,7 +507,10 @@ void alpha_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,We expect that ENV->PC has already been updated. */ void QEMU_NORETURN helper_excp(CPUAlphaState *env, int excp, int error) { - env->exception_index = excp; +AlphaCPU *cpu =alpha_env_get_cpu (env); +CPUState *cs =CPU (cpu); + + cs->exception_index = excp; env->error_code = error;cpu_loop_exit (env); }
@@ -516,7 +519,10 @@ void QEMU_NORETURN helper_excp(CPUAlphaState *env, int excp, int error) void QEMU_NORETURN dynamic_excp(CPUAlphaState *env, uintptr_t retaddr,int excp,int error) { - env->exception_index = excp; +AlphaCPU *cpu =alpha_env_get_cpu (env); +CPUState *cs =CPU (cpu); + + cs->exception_index = excp; env->error_code = error;if (retaddr) {cpu_restore_state (env, retaddr);
target-alpha/mem_helper.c +3 -1
@@ -91,6 +91,8 @@ uint64_t helper_stq_c_phys(CPUAlphaState *env, uint64_t p, uint64_t v)static void do_unaligned_access (CPUAlphaState *env,target_ulong addr,int is_write,int is_user,uintptr_t retaddr) { +AlphaCPU *cpu =alpha_env_get_cpu (env); +CPUState *cs =CPU (cpu);uint64_t pc;uint32_t insn;
@@ -104,7 +106,7 @@ static void do_unaligned_access(CPUAlphaState *env, target_ulong addr, env->trap_arg0 = addr; env->trap_arg1 = insn >>26 ;/* opcode */ env->trap_arg2 = (insn >>21 ) &31 ;/* dest regno */ - env->exception_index =EXCP_UNALIGN ; + cs->exception_index =EXCP_UNALIGN ; env->error_code =0 ;cpu_loop_exit (env); }
target-arm/helper.c +11 -14
@@ -2072,10 +2072,7 @@ uint32_t HELPER(rbit)(uint32_t x)void arm_cpu_do_interrupt (CPUState *cs) { -ARMCPU *cpu =ARM_CPU (cs); -CPUARMState *env = &cpu->env; - - env->exception_index =-1 ; + cs->exception_index =-1 ; } int arm_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int rw,
@@ -2085,10 +2082,10 @@ int arm_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int rw,CPUARMState *env = &cpu->env;if (rw ==2 ) { - env->exception_index =EXCP_PREFETCH_ABORT ; + cs->exception_index =EXCP_PREFETCH_ABORT ; env->cp15.c6_insn = address; }else { - env->exception_index =EXCP_DATA_ABORT ; + cs->exception_index =EXCP_DATA_ABORT ; env->cp15.c6_data = address; }return 1 ;
@@ -2270,7 +2267,7 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)uint32_t lr;uint32_t addr; -arm_log_exception (env->exception_index); +arm_log_exception (cs->exception_index); lr =0xfffffff1 ;if (env->v7m.current_sp)
@@ -2282,7 +2279,7 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)handle it. */ /* TODO: Need to escalate if the current priority is higher than the one we're raising. */ -switch (env->exception_index) { +switch (cs->exception_index) {case EXCP_UDEF :armv7m_nvic_set_pending (env->nvic,ARMV7M_EXCP_USAGE );return ;
@@ -2314,7 +2311,7 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)do_v7m_exception_exit (env);return ;default : -cpu_abort (env,"Unhandled exception 0x%x\n" , env->exception_index); +cpu_abort (env,"Unhandled exception 0x%x\n" , cs->exception_index);return ;/* Never happens. Keep compiler happy. */ }
@@ -2355,10 +2352,10 @@ void arm_cpu_do_interrupt(CPUState *cs)assert (!IS_M (env)); -arm_log_exception (env->exception_index); +arm_log_exception (cs->exception_index);/* TODO: Vectored interrupt controller. */ -switch (env->exception_index) { +switch (cs->exception_index) {case EXCP_UDEF : new_mode =ARM_CPU_MODE_UND ; addr =0x04 ;
@@ -2439,7 +2436,7 @@ void arm_cpu_do_interrupt(CPUState *cs) offset =4 ;break ;default : -cpu_abort (env,"Unhandled exception 0x%x\n" , env->exception_index); +cpu_abort (env,"Unhandled exception 0x%x\n" , cs->exception_index);return ;/* Never happens. Keep compiler happy. */ }/* High vectors. */
@@ -3053,13 +3050,13 @@ int arm_cpu_handle_mmu_fault(CPUState *cs, vaddr address,if (access_type ==2 ) { env->cp15.c5_insn = ret; env->cp15.c6_insn = address; - env->exception_index =EXCP_PREFETCH_ABORT ; + cs->exception_index =EXCP_PREFETCH_ABORT ; }else { env->cp15.c5_data = ret;if (access_type ==1 &&arm_feature (env,ARM_FEATURE_V6 )) env->cp15.c5_data |= (1 <<11 ); env->cp15.c6_data = address; - env->exception_index =EXCP_DATA_ABORT ; + cs->exception_index =EXCP_DATA_ABORT ; }return 1 ; }
target-arm/op_helper.c +11 -5
@@ -24,7 +24,10 @@static void raise_exception (CPUARMState *env,int tt) { - env->exception_index = tt; +ARMCPU *cpu =arm_env_get_cpu (env); +CPUState *cs =CPU (cpu); + + cs->exception_index = tt;cpu_loop_exit (env); }
@@ -75,15 +78,16 @@ void tlb_fill(CPUARMState *env, target_ulong addr, int is_write, int mmu_idx, uintptr_t retaddr) {ARMCPU *cpu =arm_env_get_cpu (env); +CPUState *cs =CPU (cpu);int ret; - ret =arm_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx); + ret =arm_cpu_handle_mmu_fault (cs, addr, is_write, mmu_idx);if (unlikely (ret)) {if (retaddr) {/* now we have a real cpu fault */ cpu_restore_state (env, retaddr); } -raise_exception (env, env->exception_index); +raise_exception (env, cs->exception_index); } }#endif
@@ -221,14 +225,16 @@ void HELPER(wfi)(CPUARMState *env) {CPUState *cs =CPU (arm_env_get_cpu (env)); - env->exception_index =EXCP_HLT ; + cs->exception_index =EXCP_HLT ; cs->halted =1 ;cpu_loop_exit (env); }void HELPER (exception )(CPUARMState *env,uint32_t excp) { - env->exception_index = excp; +CPUState *cs =CPU (arm_env_get_cpu (env)); + + cs->exception_index = excp;cpu_loop_exit (env); }
target-cris/helper.c +9 -9
@@ -41,7 +41,7 @@ void cris_cpu_do_interrupt(CPUState *cs)CRISCPU *cpu =CRIS_CPU (cs);CPUCRISState *env = &cpu->env; - env->exception_index =-1 ; + cs->exception_index =-1 ; env->pregs[PR_ERP ] = env->pc; }
@@ -55,7 +55,7 @@ int cris_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int rw, {CRISCPU *cpu =CRIS_CPU (cs); - cpu->env.exception_index =0xaa ; + cs->exception_index =0xaa ; cpu->env.pregs[PR_EDA ] = address;cpu_dump_state (cs, stderr, fprintf,0 );return 1 ;
@@ -88,7 +88,7 @@ int cris_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int rw, miss =cris_mmu_translate (&res, env, address &TARGET_PAGE_MASK , rw, mmu_idx,0 );if (miss) { -if (env->exception_index ==EXCP_BUSFAULT ) { +if (cs->exception_index ==EXCP_BUSFAULT ) { cpu_abort(env, "CRIS: Illegal recursive bus fault." "addr=%" VADDR_PRIx " rw=%d\n",
@@ -96,7 +96,7 @@ int cris_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int rw, } env->pregs[PR_EDA ] = address; - env->exception_index =EXCP_BUSFAULT ; + cs->exception_index =EXCP_BUSFAULT ; env->fault_vector = res.bf_vec; r =1 ; }else {
@@ -125,11 +125,11 @@ void crisv10_cpu_do_interrupt(CPUState *cs)int ex_vec =-1 ;D_LOG ("exception index=%d interrupt_req=%d\n" , - env->exception_index, + cs->exception_index, cs->interrupt_request);assert (!(env->pregs[PR_CCS ] &PFIX_FLAG )); -switch (env->exception_index) { +switch (cs->exception_index) {case EXCP_BREAK :/* These exceptions are genereated by the core itself. ERP should point to the insn following the brk. */
@@ -182,10 +182,10 @@ void cris_cpu_do_interrupt(CPUState *cs)int ex_vec =-1 ;D_LOG ("exception index=%d interrupt_req=%d\n" , - env->exception_index, + cs->exception_index, cs->interrupt_request); -switch (env->exception_index) { +switch (cs->exception_index) {case EXCP_BREAK :/* These exceptions are genereated by the core itself. ERP should point to the insn following the brk. */
@@ -248,7 +248,7 @@ void cris_cpu_do_interrupt(CPUState *cs)/* Clear the excption_index to avoid spurios hw_aborts for recursive bus faults. */ - env->exception_index =-1 ; + cs->exception_index =-1 ; D_LOG("%s isr=%x vec=%x ccs=%x pid=%d erp=%x\n", __func__, env->pc, ex_vec,
target-cris/op_helper.c +4 -2
@@ -79,8 +79,10 @@ void tlb_fill(CPUCRISState *env, target_ulong addr, int is_write, int mmu_idx,void helper_raise_exception (CPUCRISState *env,uint32_t index) { - env->exception_index = index; -cpu_loop_exit (env); +CPUState *cs =CPU (cris_env_get_cpu (env)); + + cs->exception_index = index; +cpu_loop_exit (env); }void helper_tlb_flush_pid (CPUCRISState *env,uint32_t pid)
target-i386/excp_helper.c +3 -1
@@ -94,6 +94,8 @@ static void QEMU_NORETURN raise_interrupt2(CPUX86State *env, int intno, int is_int, int error_code, int next_eip_addend) { + CPUState *cs = CPU(x86_env_get_cpu(env)); +if (!is_int) {cpu_svm_check_intercept_param (env,SVM_EXIT_EXCP_BASE + intno, error_code);
@@ -102,7 +104,7 @@ static void QEMU_NORETURN raise_interrupt2(CPUX86State *env, int intno,cpu_svm_check_intercept_param (env,SVM_EXIT_SWINT ,0 ); } - env->exception_index = intno; + cs->exception_index = intno; env->error_code = error_code; env->exception_is_int = is_int; env->exception_next_eip = env->eip + next_eip_addend;
target-i386/helper.c +3 -3
@@ -496,7 +496,7 @@ int x86_cpu_handle_mmu_fault(CPUState *cs, vaddr addr, env->cr[2 ] = addr; env->error_code = (is_write <<PG_ERROR_W_BIT ); env->error_code |=PG_ERROR_U_MASK ; - env->exception_index =EXCP0E_PAGE ; + cs->exception_index =EXCP0E_PAGE ;return 1 ; }
@@ -555,7 +555,7 @@ int x86_cpu_handle_mmu_fault(CPUState *cs, vaddr addr, sext = (int64_t )addr >>47 ;if (sext !=0 && sext !=-1 ) { env->error_code =0 ; - env->exception_index =EXCP0D_GPF ; + cs->exception_index =EXCP0D_GPF ;return 1 ; }
@@ -885,7 +885,7 @@ int x86_cpu_handle_mmu_fault(CPUState *cs, vaddr addr, env->cr[2 ] = addr; } env->error_code = error_code; - env->exception_index =EXCP0E_PAGE ; + cs->exception_index =EXCP0E_PAGE ;return 1 ; }
target-i386/mem_helper.c +3 -2
@@ -136,15 +136,16 @@ void tlb_fill(CPUX86State *env, target_ulong addr, int is_write, int mmu_idx, uintptr_t retaddr) {X86CPU *cpu =x86_env_get_cpu (env); +CPUState *cs =CPU (cpu);int ret; - ret =x86_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx); + ret =x86_cpu_handle_mmu_fault (cs, addr, is_write, mmu_idx);if (ret) {if (retaddr) {/* now we have a real cpu fault */ cpu_restore_state (env, retaddr); } -raise_exception_err (env, env->exception_index, env->error_code); +raise_exception_err (env, cs->exception_index, env->error_code); } }#endif
target-i386/misc_helper.c +4 -2
@@ -573,7 +573,7 @@ static void do_hlt(X86CPU *cpu) env->hflags &= ~HF_INHIBIT_IRQ_MASK ;/* needed if sti is just before */ cs->halted =1 ; - env->exception_index =EXCP_HLT ; + cs->exception_index =EXCP_HLT ;cpu_loop_exit (env); }
@@ -620,6 +620,8 @@ void helper_mwait(CPUX86State *env, int next_eip_addend)void helper_debug (CPUX86State *env) { - env->exception_index =EXCP_DEBUG ; +CPUState *cs =CPU (x86_env_get_cpu (env)); + + cs->exception_index =EXCP_DEBUG ;cpu_loop_exit (env); }
target-i386/seg_helper.c +5 -3
@@ -935,7 +935,9 @@ static void do_interrupt64(CPUX86State *env, int intno, int is_int,#if defined(CONFIG_USER_ONLY )void helper_syscall (CPUX86State *env,int next_eip_addend) { - env->exception_index =EXCP_SYSCALL ; +CPUState *cs =CPU (x86_env_get_cpu (env)); + + cs->exception_index =EXCP_SYSCALL ; env->exception_next_eip = env->eip + next_eip_addend;cpu_loop_exit (env); }
@@ -1244,7 +1246,7 @@ void x86_cpu_do_interrupt(CPUState *cs)/* if user mode only, we simulate a fake exception which will be handled outside the cpu execution loop */ -do_interrupt_user (env, env->exception_index, +do_interrupt_user (env, cs->exception_index, env->exception_is_int, env->error_code, env->exception_next_eip);
@@ -1254,7 +1256,7 @@ void x86_cpu_do_interrupt(CPUState *cs)/* simulate a real cpu exception. On i386, it can trigger new exceptions, but we do not handle double or triple faults yet. */ -do_interrupt_all (cpu, env->exception_index, +do_interrupt_all (cpu, cs->exception_index, env->exception_is_int, env->error_code, env->exception_next_eip,0 );
target-i386/svm_helper.c +7 -6
@@ -122,6 +122,7 @@ static inline void svm_load_seg_cache(CPUX86State *env, hwaddr addr,void helper_vmrun (CPUX86State *env,int aflag,int next_eip_addend) { +CPUState *cs =CPU (x86_env_get_cpu (env));target_ulong addr;uint32_t event_inj;uint32_t int_ctl;
@@ -290,7 +291,7 @@ void helper_vmrun(CPUX86State *env, int aflag, int next_eip_addend)/* FIXME: need to implement valid_err */ switch (event_inj &SVM_EVTINJ_TYPE_MASK ) {case SVM_EVTINJ_TYPE_INTR : - env->exception_index = vector; + cs->exception_index = vector; env->error_code = event_inj_err; env->exception_is_int =0 ; env->exception_next_eip =-1 ;
@@ -299,7 +300,7 @@ void helper_vmrun(CPUX86State *env, int aflag, int next_eip_addend)do_interrupt_x86_hardirq (env, vector,1 );break ;case SVM_EVTINJ_TYPE_NMI : - env->exception_index =EXCP02_NMI ; + cs->exception_index =EXCP02_NMI ; env->error_code = event_inj_err; env->exception_is_int =0 ; env->exception_next_eip = env->eip;
@@ -307,7 +308,7 @@ void helper_vmrun(CPUX86State *env, int aflag, int next_eip_addend)cpu_loop_exit (env);break ;case SVM_EVTINJ_TYPE_EXEPT : - env->exception_index = vector; + cs->exception_index = vector; env->error_code = event_inj_err; env->exception_is_int =0 ; env->exception_next_eip =-1 ;
@@ -315,7 +316,7 @@ void helper_vmrun(CPUX86State *env, int aflag, int next_eip_addend)cpu_loop_exit (env);break ;case SVM_EVTINJ_TYPE_SOFT : - env->exception_index = vector; + cs->exception_index = vector; env->error_code = event_inj_err; env->exception_is_int =1 ; env->exception_next_eip = env->eip;
@@ -323,7 +324,7 @@ void helper_vmrun(CPUX86State *env, int aflag, int next_eip_addend)cpu_loop_exit (env);break ; } -qemu_log_mask (CPU_LOG_TB_IN_ASM ," %#x %#x\n" , env->exception_index, +qemu_log_mask (CPU_LOG_TB_IN_ASM ," %#x %#x\n" , cs->exception_index, env->error_code); } }
@@ -705,7 +706,7 @@ void helper_vmexit(CPUX86State *env, uint32_t exit_code, uint64_t exit_info_1)#GP fault is delivered inside the host. */ /* remove any pending exception */ - env->exception_index =-1 ; + cs->exception_index =-1 ; env->error_code =0 ; env->old_exception =-1 ;
target-lm32/helper.c +6 -6
@@ -57,9 +57,9 @@ void lm32_cpu_do_interrupt(CPUState *cs)CPULM32State *env = &cpu->env;qemu_log_mask (CPU_LOG_INT , -"exception at pc=%x type=%x\n" , env->pc, env->exception_index); +"exception at pc=%x type=%x\n" , env->pc, cs->exception_index); -switch (env->exception_index) { +switch (cs->exception_index) {case EXCP_INSN_BUS_ERROR :case EXCP_DATA_BUS_ERROR :case EXCP_DIVIDE_BY_ZERO :
@@ -70,9 +70,9 @@ void lm32_cpu_do_interrupt(CPUState *cs) env->ie |= (env->ie &IE_IE ) ?IE_EIE :0 ; env->ie &= ~IE_IE ;if (env->dc &DC_RE ) { - env->pc = env->deba + (env->exception_index *32 ); + env->pc = env->deba + (cs->exception_index *32 ); }else { - env->pc = env->eba + (env->exception_index *32 ); + env->pc = env->eba + (cs->exception_index *32 ); }log_cpu_state_mask (CPU_LOG_INT , cs,0 );break ;
@@ -82,12 +82,12 @@ void lm32_cpu_do_interrupt(CPUState *cs) env->regs[R_BA ] = env->pc; env->ie |= (env->ie &IE_IE ) ?IE_BIE :0 ; env->ie &= ~IE_IE ; - env->pc = env->deba + (env->exception_index *32 ); + env->pc = env->deba + (cs->exception_index *32 );log_cpu_state_mask (CPU_LOG_INT , cs,0 );break ;default :cpu_abort (env,"unhandled exception type=%d\n" , - env->exception_index); + cs->exception_index);break ; } }
target-lm32/op_helper.c +4 -2
@@ -21,7 +21,9 @@void HELPER (raise_exception )(CPULM32State *env,uint32_t index) { - env->exception_index = index; +CPUState *cs =CPU (lm32_env_get_cpu (env)); + + cs->exception_index = index;cpu_loop_exit (env); }
@@ -30,7 +32,7 @@ void HELPER(hlt)(CPULM32State *env)CPUState *cs =CPU (lm32_env_get_cpu (env)); cs->halted =1 ; - env->exception_index =EXCP_HLT ; + cs->exception_index =EXCP_HLT ;cpu_loop_exit (env); }
target-m68k/helper.c +1 -1
@@ -283,7 +283,7 @@ int m68k_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int rw, {M68kCPU *cpu =M68K_CPU (cs); - cpu->env.exception_index =EXCP_ACCESS ; + cs->exception_index =EXCP_ACCESS ; cpu->env.mmu.ar = address;return 1 ; }
target-m68k/op_helper.c +10 -12
@@ -23,10 +23,7 @@void m68k_cpu_do_interrupt (CPUState *cs) { -M68kCPU *cpu =M68K_CPU (cs); -CPUM68KState *env = &cpu->env; - - env->exception_index =-1 ; + cs->exception_index =-1 ; }void do_interrupt_m68k_hardirq (CPUM68KState *env)
@@ -88,7 +85,7 @@ static void do_rte(CPUM68KState *env)static void do_interrupt_all (CPUM68KState *env,int is_hw) { -CPUState *cs; +CPUState *cs =CPU (m68k_env_get_cpu (env));uint32_t sp;uint32_t fmt;uint32_t retaddr;
@@ -98,7 +95,7 @@ static void do_interrupt_all(CPUM68KState *env, int is_hw) retaddr = env->pc;if (!is_hw) { -switch (env->exception_index) { +switch (cs->exception_index) {case EXCP_RTE :/* Return from an exception. */ do_rte (env);
@@ -113,20 +110,19 @@ static void do_interrupt_all(CPUM68KState *env, int is_hw)do_m68k_semihosting (env, env->dregs[0 ]);return ; } - cs =CPU (m68k_env_get_cpu (env)); cs->halted =1 ; - env->exception_index =EXCP_HLT ; + cs->exception_index =EXCP_HLT ;cpu_loop_exit (env);return ; } -if (env->exception_index >=EXCP_TRAP0 - && env->exception_index <=EXCP_TRAP15 ) { +if (cs->exception_index >=EXCP_TRAP0 + && cs->exception_index <=EXCP_TRAP15 ) {/* Move the PC after the trap instruction. */ retaddr +=2 ; } } - vector = env->exception_index <<2 ; + vector = cs->exception_index <<2 ; sp = env->aregs[7 ];
@@ -169,7 +165,9 @@ void do_interrupt_m68k_hardirq(CPUM68KState *env)static void raise_exception (CPUM68KState *env,int tt) { - env->exception_index = tt; +CPUState *cs =CPU (m68k_env_get_cpu (env)); + + cs->exception_index = tt;cpu_loop_exit (env); }
target-m68k/qregs.def +0 -1
@@ -7,6 +7,5 @@ DEFO32(CC_SRC, cc_src) DEFO32(CC_X, cc_x) DEFO32(DIV1, div1) DEFO32(DIV2, div2) -DEFO32(EXCEPTION, exception_index) DEFO32(MACSR, macsr) DEFO32(MAC_MASK, mac_mask)
target-m68k/translate.c +5 -0
@@ -43,6 +43,7 @@#undef DEFF64static TCGv_i32 cpu_halted; +static TCGv_i32 cpu_exception_index;static TCGv_ptr cpu_env;
@@ -81,6 +82,10 @@ void m68k_tcg_init(void) cpu_halted =tcg_global_mem_new_i32 (TCG_AREG0 , -offsetof(M68kCPU , env) + offsetof(CPUState , halted),"HALTED" ); + cpu_exception_index =tcg_global_mem_new_i32 (TCG_AREG0 , + -offsetof(M68kCPU , env) + + offsetof(CPUState , exception_index), +"EXCEPTION" ); cpu_env =tcg_global_reg_new_ptr (TCG_AREG0 ,"env" );
target-microblaze/helper.c +7 -9
@@ -31,7 +31,7 @@ void mb_cpu_do_interrupt(CPUState *cs)MicroBlazeCPU *cpu =MICROBLAZE_CPU (cs);CPUMBState *env = &cpu->env; - env->exception_index =-1 ; + cs->exception_index =-1 ; env->res_addr =RES_ADDR_NONE ; env->regs[14 ] = env->sregs[SR_PC ]; }
@@ -39,9 +39,7 @@ void mb_cpu_do_interrupt(CPUState *cs)int mb_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw,int mmu_idx) { -MicroBlazeCPU *cpu =MICROBLAZE_CPU (cs); - - cpu->env.exception_index =0xaa ; + cs->exception_index =0xaa ;cpu_dump_state (cs, stderr, fprintf,0 );return 1 ; }
@@ -99,12 +97,12 @@ int mb_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int rw,break ; } -if (env->exception_index ==EXCP_MMU ) { +if (cs->exception_index ==EXCP_MMU ) {cpu_abort (env,"recursive faults\n" ); }/* TLB miss. */ - env->exception_index =EXCP_MMU ; + cs->exception_index =EXCP_MMU ; } }else {/* MMU disabled or not available. */
@@ -127,7 +125,7 @@ void mb_cpu_do_interrupt(CPUState *cs)assert (!(env->iflags & (DRTI_FLAG |DRTE_FLAG |DRTB_FLAG )));/* assert(env->sregs[SR_MSR] & (MSR_EE)); Only for HW exceptions. */ env->res_addr =RES_ADDR_NONE ; -switch (env->exception_index) { +switch (cs->exception_index) {case EXCP_HW_EXCP :if (!(env->pvr.regs[0 ] &PVR0_USE_EXC_MASK )) {qemu_log ("Exception raised on system without exceptions!\n" );
@@ -253,7 +251,7 @@ void mb_cpu_do_interrupt(CPUState *cs) env->sregs[SR_MSR ] &= ~(MSR_VMS |MSR_UMS |MSR_VM |MSR_UM ); env->sregs[SR_MSR ] |= t; env->sregs[SR_MSR ] |=MSR_BIP ; -if (env->exception_index ==EXCP_HW_BREAK ) { +if (cs->exception_index ==EXCP_HW_BREAK ) { env->regs[16 ] = env->sregs[SR_PC ]; env->sregs[SR_MSR ] |=MSR_BIP ; env->sregs[SR_PC ] = cpu->base_vectors +0x18 ;
@@ -262,7 +260,7 @@ void mb_cpu_do_interrupt(CPUState *cs)break ;default :cpu_abort (env,"unhandled exception type=%d\n" , - env->exception_index); + cs->exception_index);break ; } }
target-microblaze/op_helper.c +3 -1
@@ -95,7 +95,9 @@ uint32_t helper_get(uint32_t id, uint32_t ctrl)void helper_raise_exception (CPUMBState *env,uint32_t index) { - env->exception_index = index; +CPUState *cs =CPU (mb_env_get_cpu (env)); + + cs->exception_index = index;cpu_loop_exit (env); }
target-mips/helper.c +17 -14
@@ -204,6 +204,7 @@ static int get_physical_address (CPUMIPSState *env, hwaddr *physical,static void raise_mmu_exception (CPUMIPSState *env,target_ulong address,int rw,int tlb_error) { +CPUState *cs =CPU (mips_env_get_cpu (env));int exception =0 , error_code =0 ;switch (tlb_error) {
@@ -249,7 +250,7 @@ static void raise_mmu_exception(CPUMIPSState *env, target_ulong address, ((address &0xC00000000000ULL ) >> (55 - env->SEGBITS)) | ((address & ((1ULL << env->SEGBITS) -1 ) &0xFFFFFFFFFFFFE000ULL ) >>9 );#endif - env->exception_index = exception; + cs->exception_index = exception; env->error_code = error_code; }
@@ -404,27 +405,29 @@ static void set_hflags_for_handler (CPUMIPSState *env)void mips_cpu_do_interrupt (CPUState *cs) { +#if !defined(CONFIG_USER_ONLY )MIPSCPU *cpu =MIPS_CPU (cs);CPUMIPSState *env = &cpu->env; -#if !defined(CONFIG_USER_ONLY )target_ulong offset;int cause =-1 ;const char *name; -if (qemu_log_enabled () && env->exception_index !=EXCP_EXT_INTERRUPT ) { -if (env->exception_index <0 || env->exception_index >EXCP_LAST ) +if (qemu_log_enabled () && cs->exception_index !=EXCP_EXT_INTERRUPT ) { +if (cs->exception_index <0 || cs->exception_index >EXCP_LAST ) { name ="unknown" ; -else - name = excp_names[env->exception_index]; + }else { + name = excp_names[cs->exception_index]; + }qemu_log ("%s enter: PC " TARGET_FMT_lx" EPC " TARGET_FMT_lx" %s exception\n" , __func__, env->active_tc.PC, env->CP0_EPC, name); } -if (env->exception_index ==EXCP_EXT_INTERRUPT && - (env->hflags &MIPS_HFLAG_DM )) - env->exception_index =EXCP_DINT ; +if (cs->exception_index ==EXCP_EXT_INTERRUPT && + (env->hflags &MIPS_HFLAG_DM )) { + cs->exception_index =EXCP_DINT ; + } offset =0x180 ; -switch (env->exception_index) { +switch (cs->exception_index) {case EXCP_DSS : env->CP0_Debug |=1 <<CP0DB_DSS ;/* Debug single step cannot be raised inside a delay slot and
@@ -632,11 +635,11 @@ void mips_cpu_do_interrupt(CPUState *cs) env->CP0_Cause = (env->CP0_Cause & ~(0x1f << CP0Ca_EC)) | (cause << CP0Ca_EC);break ;default : -qemu_log ("Invalid MIPS exception %d. Exiting\n" , env->exception_index); -printf ("Invalid MIPS exception %d. Exiting\n" , env->exception_index); +qemu_log ("Invalid MIPS exception %d. Exiting\n" , cs->exception_index); +printf ("Invalid MIPS exception %d. Exiting\n" , cs->exception_index);exit (1 ); } -if (qemu_log_enabled () && env->exception_index !=EXCP_EXT_INTERRUPT ) { +if (qemu_log_enabled () && cs->exception_index !=EXCP_EXT_INTERRUPT ) { qemu_log("%s: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " cause %d\n" " S %08x C %08x A " TARGET_FMT_lx " D " TARGET_FMT_lx "\n", __func__, env->active_tc.PC, env->CP0_EPC, cause,
@@ -644,7 +647,7 @@ void mips_cpu_do_interrupt(CPUState *cs) env->CP0_DEPC); }#endif - env->exception_index =EXCP_NONE ; + cs->exception_index =EXCP_NONE ; }#if !defined(CONFIG_USER_ONLY )
target-mips/op_helper.c +6 -3
@@ -38,10 +38,12 @@ static inline void QEMU_NORETURN do_raise_exception_err(CPUMIPSState *env, int error_code, uintptr_t pc) { +CPUState *cs =CPU (mips_env_get_cpu (env)); +if (exception <EXCP_SC ) {qemu_log ("%s: %d %d\n" , __func__, exception, error_code); } - env->exception_index = exception; + cs->exception_index = exception; env->error_code = error_code;if (pc) {
@@ -2135,11 +2137,12 @@ void tlb_fill(CPUMIPSState *env, target_ulong addr, int is_write, int mmu_idx, uintptr_t retaddr) {MIPSCPU *cpu =mips_env_get_cpu (env); +CPUState *cs =CPU (cpu);int ret; - ret =mips_cpu_handle_mmu_fault (CPU (cpu), addr, is_write, mmu_idx); + ret =mips_cpu_handle_mmu_fault (cs, addr, is_write, mmu_idx);if (ret) { -do_raise_exception_err (env, env->exception_index, +do_raise_exception_err (env, cs->exception_index, env->error_code, retaddr); } }
target-mips/translate.c +1 -3
@@ -15922,10 +15922,8 @@ MIPSCPU *cpu_mips_init(const char *cpu_model)void cpu_state_reset (CPUMIPSState *env) { -#ifndef CONFIG_USER_ONLY MIPSCPU *cpu =mips_env_get_cpu (env);CPUState *cs =CPU (cpu); -#endif /* Reset registers to their default values */ env->CP0_PRid = env->cpu_model->CP0_PRid;
@@ -16049,7 +16047,7 @@ void cpu_state_reset(CPUMIPSState *env) }#endif compute_hflags (env); - env->exception_index =EXCP_NONE ; + cs->exception_index =EXCP_NONE ; }void restore_state_to_opc (CPUMIPSState *env,TranslationBlock *tb,int pc_pos)
target-moxie/helper.c +12 -9
@@ -63,7 +63,9 @@ void tlb_fill(CPUMoxieState *env, target_ulong addr, int is_write, int mmu_idx,void helper_raise_exception (CPUMoxieState *env,int ex) { - env->exception_index = ex; +CPUState *cs =CPU (moxie_env_get_cpu (env)); + + cs->exception_index = ex;/* Stash the exception type. */ env->sregs[2 ] = ex;/* Stash the address where the exception occurred. */
@@ -98,7 +100,9 @@ uint32_t helper_udiv(CPUMoxieState *env, uint32_t a, uint32_t b)void helper_debug (CPUMoxieState *env) { - env->exception_index =EXCP_DEBUG ; +CPUState *cs =CPU (moxie_env_get_cpu (env)); + + cs->exception_index =EXCP_DEBUG ;cpu_loop_exit (env); }
@@ -106,7 +110,9 @@ void helper_debug(CPUMoxieState *env)void moxie_cpu_do_interrupt (CPUState *cs) { - env->exception_index =-1 ; +CPUState *cs =CPU (moxie_env_get_cpu (env)); + + cs->exception_index =-1 ; } int moxie_cpu_handle_mmu_fault(CPUState *cs, vaddr address,
@@ -114,7 +120,7 @@ int moxie_cpu_handle_mmu_fault(CPUState *cs, vaddr address, {MoxieCPU *cpu =MOXIE_CPU (cs); - cpu->env.exception_index =0xaa ; + cs->exception_index =0xaa ; cpu->env.debug1 = address;cpu_dump_state (cs, stderr, fprintf,0 );return 1 ;
@@ -138,7 +144,7 @@ int moxie_cpu_handle_mmu_fault(CPUState *cs, vaddr address,if (miss) {/* handle the miss. */ phy =0 ; - env->exception_index =MOXIE_EX_MMU_MISS ; + cs->exception_index =MOXIE_EX_MMU_MISS ; }else { phy = res.phy; r =0 ;
@@ -150,10 +156,7 @@ int moxie_cpu_handle_mmu_fault(CPUState *cs, vaddr address,void moxie_cpu_do_interrupt (CPUState *cs) { -MoxieCPU *cpu =MOXIE_CPU (cs); -CPUMoxieState *env = &cpu->env; - -switch (env->exception_index) { +switch (cs->exception_index) {case MOXIE_EX_BREAK :break ;default :
target-openrisc/cpu.c +1 -1
@@ -69,7 +69,7 @@ static void openrisc_cpu_reset(CPUState *s) cpu->env.pc =0x100 ; cpu->env.sr =SR_FO |SR_SM ; - cpu->env.exception_index =-1 ; + s->exception_index =-1 ; cpu->env.upr =UPR_UP |UPR_DMP |UPR_IMP |UPR_PICP |UPR_TTP ; cpu->env.cpucfgr =CPUCFGR_OB32S |CPUCFGR_OF32S ;
target-openrisc/exception.c +3 -1
@@ -22,6 +22,8 @@ void QEMU_NORETURN raise_exception(OpenRISCCPU *cpu, uint32_t excp) { - cpu->env.exception_index = excp; +CPUState *cs =CPU (cpu); + + cs->exception_index = excp;cpu_loop_exit (&cpu->env); }
target-openrisc/interrupt.c +14 -13
@@ -27,25 +27,26 @@void openrisc_cpu_do_interrupt (CPUState *cs) { +#ifndef CONFIG_USER_ONLY OpenRISCCPU *cpu =OPENRISC_CPU (cs);CPUOpenRISCState *env = &cpu->env; -#ifndef CONFIG_USER_ONLY +if (env->flags &D_FLAG ) {/* Delay Slot insn */ env->flags &= ~D_FLAG ; env->sr |=SR_DSX ; -if (env->exception_index ==EXCP_TICK || - env->exception_index ==EXCP_INT || - env->exception_index ==EXCP_SYSCALL || - env->exception_index ==EXCP_FPE ) { +if (cs->exception_index ==EXCP_TICK || + cs->exception_index ==EXCP_INT || + cs->exception_index ==EXCP_SYSCALL || + cs->exception_index ==EXCP_FPE ) { env->epcr = env->jmp_pc; }else { env->epcr = env->pc -4 ; } }else { -if (env->exception_index ==EXCP_TICK || - env->exception_index ==EXCP_INT || - env->exception_index ==EXCP_SYSCALL || - env->exception_index ==EXCP_FPE ) { +if (cs->exception_index ==EXCP_TICK || + cs->exception_index ==EXCP_INT || + cs->exception_index ==EXCP_SYSCALL || + cs->exception_index ==EXCP_FPE ) { env->epcr = env->npc; }else { env->epcr = env->pc;
@@ -65,12 +66,12 @@ void openrisc_cpu_do_interrupt(CPUState *cs) env->tlb->cpu_openrisc_map_address_data = &cpu_openrisc_get_phys_nommu; env->tlb->cpu_openrisc_map_address_code = &cpu_openrisc_get_phys_nommu; -if (env->exception_index >0 && env->exception_index <EXCP_NR ) { - env->pc = (env->exception_index <<8 ); +if (cs->exception_index >0 && cs->exception_index <EXCP_NR ) { + env->pc = (cs->exception_index <<8 ); }else { -cpu_abort (env,"Unhandled exception 0x%x\n" , env->exception_index); +cpu_abort (env,"Unhandled exception 0x%x\n" , cs->exception_index); }#endif - env->exception_index =-1 ; + cs->exception_index =-1 ; }
target-openrisc/mmu.c +2 -1
@@ -146,6 +146,7 @@ static void cpu_openrisc_raise_mmu_exception(OpenRISCCPU *cpu,target_ulong address, int rw, int tlb_error) { + CPUState *cs = CPU(cpu);int exception =0 ;switch (tlb_error) {
@@ -176,7 +177,7 @@ static void cpu_openrisc_raise_mmu_exception(OpenRISCCPU *cpu,#endif } - cpu->env.exception_index = exception; + cs->exception_index = exception; cpu->env.eear = address; }
target-ppc/excp_helper.c +11 -8
@@ -43,13 +43,15 @@ void ppc_cpu_do_interrupt(CPUState *cs)PowerPCCPU *cpu =POWERPC_CPU (cs);CPUPPCState *env = &cpu->env; - env->exception_index =POWERPC_EXCP_NONE ; + cs->exception_index =POWERPC_EXCP_NONE ; env->error_code = 0; }void ppc_hw_interrupt (CPUPPCState *env) { - env->exception_index =POWERPC_EXCP_NONE ; +CPUState *cs =CPU (ppc_env_get_cpu (env)); + + cs->exception_index =POWERPC_EXCP_NONE ; env->error_code =0 ; }#else /* defined(CONFIG_USER_ONLY) */
@@ -68,8 +70,8 @@ static inline void dump_syscall(CPUPPCState *env)*/ static inline void powerpc_excp (PowerPCCPU *cpu,int excp_model,int excp) { +CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env; -CPUState *cs;target_ulong msr, new_msr, vector;int srr0, srr1, asrr0, asrr1;int lpes0, lpes1, lev;
@@ -135,7 +137,6 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)fprintf (stderr,"Machine check while not allowed. " "Entering checkstop state\n" ); } - cs =CPU (cpu); cs->halted =1 ; cs->interrupt_request |=CPU_INTERRUPT_EXITTB ; }
@@ -202,7 +203,7 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)case POWERPC_EXCP_FP :if ((msr_fe0 ==0 && msr_fe1 ==0 ) || msr_fp ==0 ) {LOG_EXCP ("Ignore floating point exception\n" ); - env->exception_index =POWERPC_EXCP_NONE ; + cs->exception_index =POWERPC_EXCP_NONE ; env->error_code =0 ;return ; }
@@ -655,7 +656,7 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)hreg_compute_hflags (env); env->nip = vector;/* Reset exception state */ - env->exception_index =POWERPC_EXCP_NONE ; + cs->exception_index =POWERPC_EXCP_NONE ; env->error_code =0 ; if ((env->mmu_model == POWERPC_MMU_BOOKE) ||
@@ -672,7 +673,7 @@ void ppc_cpu_do_interrupt(CPUState *cs)PowerPCCPU *cpu =POWERPC_CPU (cs);CPUPPCState *env = &cpu->env; -powerpc_excp (cpu, env->excp_model, env->exception_index); +powerpc_excp (cpu, env->excp_model, cs->exception_index); }void ppc_hw_interrupt (CPUPPCState *env)
@@ -808,10 +809,12 @@ static void cpu_dump_rfi(target_ulong RA, target_ulong msr)void helper_raise_exception_err (CPUPPCState *env,uint32_t exception,uint32_t error_code) { +CPUState *cs =CPU (ppc_env_get_cpu (env)); +#if 0 printf ("Raise exception %3x code : %d\n" , exception, error_code);#endif - env->exception_index = exception; + cs->exception_index = exception; env->error_code = error_code;cpu_loop_exit (env); }
target-ppc/fpu_helper.c +18 -8
@@ -108,6 +108,7 @@ uint32_t helper_compute_fprf(CPUPPCState *env, uint64_t arg, uint32_t set_fprf)/* Floating-point invalid operations exception */ static inline uint64_t fload_invalid_op_excp (CPUPPCState *env,int op) { +CPUState *cs =CPU (ppc_env_get_cpu (env));uint64_t ret =0 ;int ve;
@@ -142,7 +143,7 @@ static inline uint64_t fload_invalid_op_excp(CPUPPCState *env, int op) env->fpscr |=0x11 <<FPSCR_FPCC ;/* We must update the target FPR before raising the exception */ if (ve !=0 ) { - env->exception_index =POWERPC_EXCP_PROGRAM ; + cs->exception_index =POWERPC_EXCP_PROGRAM ; env->error_code =POWERPC_EXCP_FP |POWERPC_EXCP_FP_VXVC ;/* Update the floating-point enabled exception summary */ env->fpscr |=1 <<FPSCR_FEX ;
@@ -207,6 +208,8 @@ static inline void float_zero_divide_excp(CPUPPCState *env)static inline void float_overflow_excp (CPUPPCState *env) { +CPUState *cs =CPU (ppc_env_get_cpu (env)); + env->fpscr |=1 <<FPSCR_OX ;/* Update the floating-point exception summary */ env->fpscr |=1 <<FPSCR_FX ;
@@ -215,7 +218,7 @@ static inline void float_overflow_excp(CPUPPCState *env)/* Update the floating-point enabled exception summary */ env->fpscr |=1 <<FPSCR_FEX ;/* We must update the target FPR before raising the exception */ - env->exception_index =POWERPC_EXCP_PROGRAM ; + cs->exception_index =POWERPC_EXCP_PROGRAM ; env->error_code =POWERPC_EXCP_FP |POWERPC_EXCP_FP_OX ; }else { env->fpscr |=1 <<FPSCR_XX ;
@@ -225,6 +228,8 @@ static inline void float_overflow_excp(CPUPPCState *env)static inline void float_underflow_excp (CPUPPCState *env) { +CPUState *cs =CPU (ppc_env_get_cpu (env)); + env->fpscr |=1 <<FPSCR_UX ;/* Update the floating-point exception summary */ env->fpscr |=1 <<FPSCR_FX ;
@@ -233,13 +238,15 @@ static inline void float_underflow_excp(CPUPPCState *env)/* Update the floating-point enabled exception summary */ env->fpscr |=1 <<FPSCR_FEX ;/* We must update the target FPR before raising the exception */ - env->exception_index =POWERPC_EXCP_PROGRAM ; + cs->exception_index =POWERPC_EXCP_PROGRAM ; env->error_code =POWERPC_EXCP_FP |POWERPC_EXCP_FP_UX ; } }static inline void float_inexact_excp (CPUPPCState *env) { +CPUState *cs =CPU (ppc_env_get_cpu (env)); + env->fpscr |=1 <<FPSCR_XX ;/* Update the floating-point exception summary */ env->fpscr |=1 <<FPSCR_FX ;
@@ -247,7 +254,7 @@ static inline void float_inexact_excp(CPUPPCState *env)/* Update the floating-point enabled exception summary */ env->fpscr |=1 <<FPSCR_FEX ;/* We must update the target FPR before raising the exception */ - env->exception_index =POWERPC_EXCP_PROGRAM ; + cs->exception_index =POWERPC_EXCP_PROGRAM ; env->error_code =POWERPC_EXCP_FP |POWERPC_EXCP_FP_XX ; } }
@@ -299,6 +306,7 @@ void helper_fpscr_clrbit(CPUPPCState *env, uint32_t bit)void helper_fpscr_setbit (CPUPPCState *env,uint32_t bit) { +CPUState *cs =CPU (ppc_env_get_cpu (env));int prev; prev = (env->fpscr >> bit) &1 ;
@@ -422,7 +430,7 @@ void helper_fpscr_setbit(CPUPPCState *env, uint32_t bit)/* Update the floating-point enabled exception summary */ env->fpscr |=1 <<FPSCR_FEX ;/* We have to update Rc1 before raising the exception */ - env->exception_index =POWERPC_EXCP_PROGRAM ; + cs->exception_index =POWERPC_EXCP_PROGRAM ;break ; } }
@@ -430,6 +438,7 @@ void helper_fpscr_setbit(CPUPPCState *env, uint32_t bit)void helper_store_fpscr (CPUPPCState *env,uint64_t arg,uint32_t mask) { +CPUState *cs =CPU (ppc_env_get_cpu (env));target_ulong prev, new;int i;
@@ -451,7 +460,7 @@ void helper_store_fpscr(CPUPPCState *env, uint64_t arg, uint32_t mask) }if ((fpscr_ex & fpscr_eex) !=0 ) { env->fpscr |=1 <<FPSCR_FEX ; - env->exception_index =POWERPC_EXCP_PROGRAM ; + cs->exception_index =POWERPC_EXCP_PROGRAM ;/* XXX: we should compute it properly */ env->error_code =POWERPC_EXCP_FP ; }else {
@@ -467,6 +476,7 @@ void store_fpscr(CPUPPCState *env, uint64_t arg, uint32_t mask)void helper_float_check_status (CPUPPCState *env) { +CPUState *cs =CPU (ppc_env_get_cpu (env));int status =get_float_exception_flags (&env->fp_status);if (status & float_flag_divbyzero) {
@@ -479,11 +489,11 @@ void helper_float_check_status(CPUPPCState *env)float_inexact_excp (env); } -if (env->exception_index ==POWERPC_EXCP_PROGRAM && +if (cs->exception_index ==POWERPC_EXCP_PROGRAM && (env->error_code &POWERPC_EXCP_FP )) {/* Differred floating-point exception after target FPR update */ if (msr_fe0 !=0 || msr_fe1 !=0 ) { -helper_raise_exception_err (env, env->exception_index, +helper_raise_exception_err (env, cs->exception_index, env->error_code); } }
target-ppc/mmu-hash32.c +13 -11
@@ -222,6 +222,7 @@ static int ppc_hash32_direct_store(CPUPPCState *env, target_ulong sr, target_ulong eaddr, int rwx, hwaddr *raddr, int *prot) { + CPUState *cs = CPU(ppc_env_get_cpu(env));int key = !!(msr_pr ? (sr &SR32_KP ) : (sr &SR32_KS ));LOG_MMU ("direct store...\n" );
@@ -238,7 +239,7 @@ static int ppc_hash32_direct_store(CPUPPCState *env, target_ulong sr,if (rwx ==2 ) {/* No code fetch is allowed in direct-store areas */ - env->exception_index =POWERPC_EXCP_ISI ; + cs->exception_index =POWERPC_EXCP_ISI ; env->error_code =0x10000000 ;return 1 ; }
@@ -249,7 +250,7 @@ static int ppc_hash32_direct_store(CPUPPCState *env, target_ulong sr,break ;case ACCESS_FLOAT :/* Floating point load/store */ - env->exception_index =POWERPC_EXCP_ALIGN ; + cs->exception_index =POWERPC_EXCP_ALIGN ; env->error_code =POWERPC_EXCP_ALIGN_FP ; env->spr[SPR_DAR ] = eaddr;return 1 ;
@@ -272,7 +273,7 @@ static int ppc_hash32_direct_store(CPUPPCState *env, target_ulong sr,return 0 ;case ACCESS_EXT :/* eciwx or ecowx */ - env->exception_index =POWERPC_EXCP_DSI ; + cs->exception_index =POWERPC_EXCP_DSI ; env->error_code =0 ; env->spr[SPR_DAR ] = eaddr;if (rwx ==1 ) {
@@ -290,7 +291,7 @@ static int ppc_hash32_direct_store(CPUPPCState *env, target_ulong sr, *raddr = eaddr;return 0 ; }else { - env->exception_index =POWERPC_EXCP_DSI ; + cs->exception_index =POWERPC_EXCP_DSI ; env->error_code =0 ; env->spr[SPR_DAR ] = eaddr;if (rwx ==1 ) {
@@ -383,6 +384,7 @@ static hwaddr ppc_hash32_pte_raddr(target_ulong sr, ppc_hash_pte32_t pte,int ppc_hash32_handle_mmu_fault (CPUPPCState *env,target_ulong eaddr,int rwx,int mmu_idx) { +CPUState *cs =CPU (ppc_env_get_cpu (env));target_ulong sr;hwaddr pte_offset;ppc_hash_pte32_t pte;
@@ -409,10 +411,10 @@ int ppc_hash32_handle_mmu_fault(CPUPPCState *env, target_ulong eaddr, int rwx,if (raddr !=-1 ) {if (need_prot[rwx] & ~prot) {if (rwx ==2 ) { - env->exception_index =POWERPC_EXCP_ISI ; + cs->exception_index =POWERPC_EXCP_ISI ; env->error_code =0x08000000 ; }else { - env->exception_index =POWERPC_EXCP_DSI ; + cs->exception_index =POWERPC_EXCP_DSI ; env->error_code =0 ; env->spr[SPR_DAR ] = eaddr;if (rwx ==1 ) {
@@ -449,7 +451,7 @@ int ppc_hash32_handle_mmu_fault(CPUPPCState *env, target_ulong eaddr, int rwx,/* 5. Check for segment level no-execute violation */ if ((rwx ==2 ) && (sr &SR32_NX )) { - env->exception_index =POWERPC_EXCP_ISI ; + cs->exception_index =POWERPC_EXCP_ISI ; env->error_code =0x10000000 ;return 1 ; }
@@ -458,10 +460,10 @@ int ppc_hash32_handle_mmu_fault(CPUPPCState *env, target_ulong eaddr, int rwx, pte_offset =ppc_hash32_htab_lookup (env, sr, eaddr, &pte);if (pte_offset ==-1 ) {if (rwx ==2 ) { - env->exception_index =POWERPC_EXCP_ISI ; + cs->exception_index =POWERPC_EXCP_ISI ; env->error_code =0x40000000 ; }else { - env->exception_index =POWERPC_EXCP_DSI ; + cs->exception_index =POWERPC_EXCP_DSI ; env->error_code =0 ; env->spr[SPR_DAR ] = eaddr;if (rwx ==1 ) {
@@ -483,10 +485,10 @@ int ppc_hash32_handle_mmu_fault(CPUPPCState *env, target_ulong eaddr, int rwx,/* Access right violation */ LOG_MMU ("PTE access rejected\n" );if (rwx ==2 ) { - env->exception_index =POWERPC_EXCP_ISI ; + cs->exception_index =POWERPC_EXCP_ISI ; env->error_code =0x08000000 ; }else { - env->exception_index =POWERPC_EXCP_DSI ; + cs->exception_index =POWERPC_EXCP_DSI ; env->error_code =0 ; env->spr[SPR_DAR ] = eaddr;if (rwx ==1 ) {
target-ppc/mmu-hash64.c +8 -7
@@ -399,6 +399,7 @@ static hwaddr ppc_hash64_pte_raddr(ppc_slb_t *slb, ppc_hash_pte64_t pte,int ppc_hash64_handle_mmu_fault (CPUPPCState *env,target_ulong eaddr,int rwx,int mmu_idx) { +CPUState *cs =CPU (ppc_env_get_cpu (env));ppc_slb_t *slb;hwaddr pte_offset;ppc_hash_pte64_t pte;
@@ -425,10 +426,10 @@ int ppc_hash64_handle_mmu_fault(CPUPPCState *env, target_ulong eaddr,if (!slb) {if (rwx ==2 ) { - env->exception_index =POWERPC_EXCP_ISEG ; + cs->exception_index =POWERPC_EXCP_ISEG ; env->error_code =0 ; }else { - env->exception_index =POWERPC_EXCP_DSEG ; + cs->exception_index =POWERPC_EXCP_DSEG ; env->error_code =0 ; env->spr[SPR_DAR ] = eaddr; }
@@ -437,7 +438,7 @@ int ppc_hash64_handle_mmu_fault(CPUPPCState *env, target_ulong eaddr,/* 3. Check for segment level no-execute violation */ if ((rwx ==2 ) && (slb->vsid &SLB_VSID_N )) { - env->exception_index =POWERPC_EXCP_ISI ; + cs->exception_index =POWERPC_EXCP_ISI ; env->error_code =0x10000000 ;return 1 ; }
@@ -446,10 +447,10 @@ int ppc_hash64_handle_mmu_fault(CPUPPCState *env, target_ulong eaddr, pte_offset =ppc_hash64_htab_lookup (env, slb, eaddr, &pte);if (pte_offset ==-1 ) {if (rwx ==2 ) { - env->exception_index =POWERPC_EXCP_ISI ; + cs->exception_index =POWERPC_EXCP_ISI ; env->error_code =0x40000000 ; }else { - env->exception_index =POWERPC_EXCP_DSI ; + cs->exception_index =POWERPC_EXCP_DSI ; env->error_code =0 ; env->spr[SPR_DAR ] = eaddr;if (rwx ==1 ) {
@@ -472,12 +473,12 @@ int ppc_hash64_handle_mmu_fault(CPUPPCState *env, target_ulong eaddr,/* Access right violation */ LOG_MMU ("PTE access rejected\n" );if (rwx ==2 ) { - env->exception_index =POWERPC_EXCP_ISI ; + cs->exception_index =POWERPC_EXCP_ISI ; env->error_code =0x08000000 ; }else {target_ulong dsisr =0 ; - env->exception_index =POWERPC_EXCP_DSI ; + cs->exception_index =POWERPC_EXCP_DSI ; env->error_code =0 ; env->spr[SPR_DAR ] = eaddr;if (need_prot[rwx] & ~pp_prot) {
target-ppc/mmu_helper.c +22 -21
159 lines not on this page · raw message
target-ppc/translate_init.c +1 -1
@@ -8511,7 +8511,7 @@ static void ppc_cpu_reset(CPUState *s) env->reserve_addr = (target_ulong)-1ULL ;/* Be sure no exception or interrupt is pending */ env->pending_interrupts =0 ; - env->exception_index =POWERPC_EXCP_NONE ; + s->exception_index =POWERPC_EXCP_NONE ; env->error_code =0 ;#if defined(TARGET_PPC64 ) && !defined(CONFIG_USER_ONLY )
target-ppc/user_only_helper.c +1 -1
@@ -39,7 +39,7 @@ int ppc_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int rw, env->spr[SPR_DAR ] = address; env->spr[SPR_DSISR ] = error_code; } - env->exception_index = exception; + cs->exception_index = exception; env->error_code = error_code;return 1 ;
target-s390x/helper.c +19 -20
@@ -88,10 +88,7 @@ S390CPU *cpu_s390x_init(const char *cpu_model)void s390_cpu_do_interrupt (CPUState *cs) { -S390CPU *cpu =S390_CPU (cs); -CPUS390XState *env = &cpu->env; - - env->exception_index =-1 ; + cs->exception_index =-1 ; } int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr address,
@@ -99,7 +96,7 @@ int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr address, {S390CPU *cpu =S390_CPU (cs); - cpu->env.exception_index =EXCP_PGM ; + cs->exception_index =EXCP_PGM ; cpu->env.int_pgm_code =PGM_ADDRESSING ;/* On real machines this value is dropped into LowMem. Since this is userland, simply put this someplace that cpu_loop can find it. */
@@ -113,7 +110,9 @@ int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr address,static void trigger_pgm_exception (CPUS390XState *env,uint32_t code,uint32_t ilen) { - env->exception_index =EXCP_PGM ; +CPUState *cs =CPU (s390_env_get_cpu (env)); + + cs->exception_index =EXCP_PGM ; env->int_pgm_code = code; env->int_pgm_ilen = ilen; }
@@ -427,7 +426,7 @@ hwaddr s390_cpu_get_phys_page_debug(CPUState *cs, vaddr vaddr)CPUS390XState *env = &cpu->env;target_ulong raddr;int prot =PAGE_READ |PAGE_WRITE |PAGE_EXEC ; -int old_exc = env->exception_index; +int old_exc = cs->exception_index;uint64_t asc = env->psw.mask &PSW_MASK_ASC ;/* 31-Bit mode */
@@ -436,7 +435,7 @@ hwaddr s390_cpu_get_phys_page_debug(CPUState *cs, vaddr vaddr) }mmu_translate (env, vaddr,2 , asc, &raddr, &prot); - env->exception_index = old_exc; + cs->exception_index = old_exc;return raddr; }
@@ -454,7 +453,7 @@ void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr) } } cs->halted =1 ; - env->exception_index =EXCP_HLT ; + cs->exception_index =EXCP_HLT ; } env->psw.addr = addr;
@@ -751,43 +750,43 @@ void s390_cpu_do_interrupt(CPUState *cs)CPUS390XState *env = &cpu->env;qemu_log_mask (CPU_LOG_INT ,"%s: %d at pc=%" PRIx64"\n" , - __func__, env->exception_index, env->psw.addr); + __func__, cs->exception_index, env->psw.addr);s390_add_running_cpu (cpu);/* handle machine checks */ if ((env->psw.mask &PSW_MASK_MCHECK ) && - (env->exception_index ==-1 )) { + (cs->exception_index ==-1 )) {if (env->pending_int &INTERRUPT_MCHK ) { - env->exception_index =EXCP_MCHK ; + cs->exception_index =EXCP_MCHK ; } }/* handle external interrupts */ if ((env->psw.mask &PSW_MASK_EXT ) && - env->exception_index ==-1 ) { + cs->exception_index ==-1 ) {if (env->pending_int &INTERRUPT_EXT ) {/* code is already in env */ - env->exception_index =EXCP_EXT ; + cs->exception_index =EXCP_EXT ; }else if (env->pending_int &INTERRUPT_TOD ) {cpu_inject_ext (cpu,0x1004 ,0 ,0 ); - env->exception_index =EXCP_EXT ; + cs->exception_index =EXCP_EXT ; env->pending_int &= ~INTERRUPT_EXT ; env->pending_int &= ~INTERRUPT_TOD ; }else if (env->pending_int &INTERRUPT_CPUTIMER ) {cpu_inject_ext (cpu,0x1005 ,0 ,0 ); - env->exception_index =EXCP_EXT ; + cs->exception_index =EXCP_EXT ; env->pending_int &= ~INTERRUPT_EXT ; env->pending_int &= ~INTERRUPT_TOD ; } }/* handle I/O interrupts */ if ((env->psw.mask &PSW_MASK_IO ) && - (env->exception_index ==-1 )) { + (cs->exception_index ==-1 )) {if (env->pending_int &INTERRUPT_IO ) { - env->exception_index =EXCP_IO ; + cs->exception_index =EXCP_IO ; } } -switch (env->exception_index) { +switch (cs->exception_index) {case EXCP_PGM :do_program_interrupt (env);break ;
@@ -804,7 +803,7 @@ void s390_cpu_do_interrupt(CPUState *cs)do_mchk_interrupt (env);break ; } - env->exception_index =-1 ; + cs->exception_index =-1 ;if (!env->pending_int) { cs->interrupt_request &= ~CPU_INTERRUPT_HARD ;
target-s390x/mem_helper.c +5 -4
@@ -1048,8 +1048,9 @@ void HELPER(stura)(CPUS390XState *env, uint64_t addr, uint64_t v1)/* load real address */ uint64_t HELPER (lra )(CPUS390XState *env,uint64_t addr) { +CPUState *cs =CPU (s390_env_get_cpu (env));uint32_t cc =0 ; -int old_exc = env->exception_index; +int old_exc = cs->exception_index;uint64_t asc = env->psw.mask &PSW_MASK_ASC ;uint64_t ret;int flags;
@@ -1059,16 +1060,16 @@ uint64_t HELPER(lra)(CPUS390XState *env, uint64_t addr)program_interrupt (env,PGM_SPECIAL_OP ,2 ); } - env->exception_index = old_exc; + cs->exception_index = old_exc;if (mmu_translate (env, addr,0 , asc, &ret, &flags)) { cc =3 ; } -if (env->exception_index ==EXCP_PGM ) { +if (cs->exception_index ==EXCP_PGM ) { ret = env->int_pgm_code |0x80000000 ; }else { ret |= addr & ~TARGET_PAGE_MASK ; } - env->exception_index = old_exc; + cs->exception_index = old_exc; env->cc_op = cc;return ret;
target-s390x/misc_helper.c +11 -4
@@ -46,9 +46,10 @@ void QEMU_NORETURN runtime_exception(CPUS390XState *env, int excp,uintptr_t retaddr) { +CPUState *cs =CPU (s390_env_get_cpu (env));int t; - env->exception_index =EXCP_PGM ; + cs->exception_index =EXCP_PGM ; env->int_pgm_code = excp;/* Use the (ultimate) callers address to find the insn that trapped. */
@@ -65,8 +66,10 @@ void QEMU_NORETURN runtime_exception(CPUS390XState *env, int excp,/* Raise an exception statically from a TB. */ void HELPER (exception )(CPUS390XState *env,uint32_t excp) { +CPUState *cs =CPU (s390_env_get_cpu (env)); +HELPER_LOG ("%s: exception %d\n" , __func__, excp); - env->exception_index = excp; + cs->exception_index = excp;cpu_loop_exit (env); }
@@ -154,17 +157,21 @@ static inline void ebcdic_put(uint8_t *p, const char *ascii, int len)void program_interrupt (CPUS390XState *env,uint32_t code,int ilen) { +S390CPU *cpu =s390_env_get_cpu (env); +qemu_log_mask (CPU_LOG_INT ,"program interrupt at %#" PRIx64"\n" , env->psw.addr);if (kvm_enabled ()) {#ifdef CONFIG_KVM -kvm_s390_interrupt (s390_env_get_cpu (env),KVM_S390_PROGRAM_INT , code); +kvm_s390_interrupt (cpu,KVM_S390_PROGRAM_INT , code);#endif }else { +CPUState *cs =CPU (cpu); + env->int_pgm_code = code; env->int_pgm_ilen = ilen; - env->exception_index =EXCP_PGM ; + cs->exception_index =EXCP_PGM ;cpu_loop_exit (env); } }
target-sh4/helper.c +25 -26
123 lines not on this page · raw message
target-sh4/op_helper.c +3 -1
@@ -69,7 +69,9 @@ void helper_ldtlb(CPUSH4State *env) static inline void QEMU_NORETURN raise_exception(CPUSH4State *env, int index,uintptr_t retaddr) { - env->exception_index = index; +CPUState *cs =CPU (sh_env_get_cpu (env)); + + cs->exception_index = index;if (retaddr) {cpu_restore_state (env, retaddr); }
target-sparc/helper.c +7 -3
@@ -24,13 +24,17 @@void helper_raise_exception (CPUSPARCState *env,int tt) { - env->exception_index = tt; +CPUState *cs =CPU (sparc_env_get_cpu (env)); + + cs->exception_index = tt;cpu_loop_exit (env); }void helper_debug (CPUSPARCState *env) { - env->exception_index =EXCP_DEBUG ; +CPUState *cs =CPU (sparc_env_get_cpu (env)); + + cs->exception_index =EXCP_DEBUG ;cpu_loop_exit (env); }
@@ -232,7 +236,7 @@ void helper_power_down(CPUSPARCState *env)CPUState *cs =CPU (sparc_env_get_cpu (env)); cs->halted =1 ; - env->exception_index =EXCP_HLT ; + cs->exception_index =EXCP_HLT ; env->pc = env->npc; env->npc = env->pc +4 ;cpu_loop_exit (env);
target-sparc/int32_helper.c +4 -4
@@ -62,7 +62,7 @@ void sparc_cpu_do_interrupt(CPUState *cs) {SPARCCPU *cpu =SPARC_CPU (cs);CPUSPARCState *env = &cpu->env; -int cwp, intno = env->exception_index; +int cwp, intno = cs->exception_index;/* Compute PSR before exposing state. */ if (env->cc_op !=CC_OP_FLAGS ) {
@@ -105,12 +105,12 @@ void sparc_cpu_do_interrupt(CPUState *cs)#endif #if !defined(CONFIG_USER_ONLY )if (env->psret ==0 ) { -if (env->exception_index ==0x80 && +if (cs->exception_index ==0x80 && env->def->features &CPU_FEATURE_TA0_SHUTDOWN ) {qemu_system_shutdown_request (); }else {cpu_abort (env,"Trap 0x%02x while interrupts disabled, Error state" , - env->exception_index); + cs->exception_index); }return ; }
@@ -125,7 +125,7 @@ void sparc_cpu_do_interrupt(CPUState *cs) env->tbr = (env->tbr &TBR_BASE_MASK ) | (intno <<4 ); env->pc = env->tbr; env->npc = env->pc +4 ; - env->exception_index =-1 ; + cs->exception_index =-1 ;#if !defined(CONFIG_USER_ONLY )/* IRQ acknowledgment */
target-sparc/int64_helper.c +3 -3
@@ -63,7 +63,7 @@ void sparc_cpu_do_interrupt(CPUState *cs) {SPARCCPU *cpu =SPARC_CPU (cs);CPUSPARCState *env = &cpu->env; -int intno = env->exception_index; +int intno = cs->exception_index;trap_state *tsptr;/* Compute PSR before exposing state. */
@@ -112,7 +112,7 @@ void sparc_cpu_do_interrupt(CPUState *cs)#if !defined(CONFIG_USER_ONLY )if (env->tl >= env->maxtl) {cpu_abort (env,"Trap 0x%04x while trap level (%d) >= MAXTL (%d)," -" Error state" , env->exception_index, env->tl, env->maxtl); +" Error state" , cs->exception_index, env->tl, env->maxtl);return ; }#endif
@@ -160,7 +160,7 @@ void sparc_cpu_do_interrupt(CPUState *cs) env->tbr |= ((env->tl >1 ) ?1 <<14 :0 ) | (intno <<5 ); env->pc = env->tbr; env->npc = env->pc +4 ; - env->exception_index =-1 ; + cs->exception_index =-1 ; }trap_state *cpu_tsptr (CPUSPARCState * env)
target-sparc/ldst_helper.c +2 -1
@@ -1284,6 +1284,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val,uint64_t helper_ld_asi (CPUSPARCState *env,target_ulong addr,int asi,int size,int sign) { +CPUState *cs =CPU (sparc_env_get_cpu (env));uint64_t ret =0 ;#if defined(DEBUG_ASI )target_ulong last_addr = addr;
@@ -1317,7 +1318,7 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr, int asi, int size,dump_asi ("read " , last_addr, asi, size, ret);#endif /* env->exception_index is set in get_physical_address_data(). */ -helper_raise_exception (env, env->exception_index); +helper_raise_exception (env, cs->exception_index); }/* convert nonfaulting load ASIs to normal load ASIs */
target-sparc/mmu_helper.c +11 -11
@@ -28,12 +28,10 @@int sparc_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw,int mmu_idx) { -SPARCCPU *cpu =SPARC_CPU (cs); -if (rw &2 ) { - cpu->env.exception_index =TT_TFAULT ; + cs->exception_index =TT_TFAULT ; }else { - cpu->env.exception_index =TT_DFAULT ; + cs->exception_index =TT_DFAULT ; }return 1 ; }
@@ -238,9 +236,9 @@ int sparc_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int rw,return 0 ; }else {if (rw &2 ) { - env->exception_index =TT_TFAULT ; + cs->exception_index =TT_TFAULT ; }else { - env->exception_index =TT_DFAULT ; + cs->exception_index =TT_DFAULT ; }return 1 ; }
@@ -489,6 +487,7 @@ static int get_physical_address_data(CPUSPARCState *env, hwaddr *physical, int *prot, target_ulong address, int rw, int mmu_idx) { +CPUState *cs =CPU (sparc_env_get_cpu (env));unsigned int i;uint64_t context;uint64_t sfsr =0 ;
@@ -553,10 +552,10 @@ static int get_physical_address_data(CPUSPARCState *env,if (do_fault) {/* faults above are reported with TT_DFAULT. */ - env->exception_index =TT_DFAULT ; + cs->exception_index =TT_DFAULT ; }else if (!TTE_IS_W_OK (env->dtlb[i].tte) && (rw ==1 )) { do_fault =1 ; - env->exception_index =TT_DPROT ; + cs->exception_index =TT_DPROT ;trace_mmu_helper_dprot (address, context, mmu_idx, env->tl); }
@@ -600,7 +599,7 @@ static int get_physical_address_data(CPUSPARCState *env,* - JPS1: SFAR updated and some fields of SFSR updated */ env->dmmu.tag_access = (address & ~0x1fffULL ) | context; - env->exception_index =TT_DMISS ; + cs->exception_index =TT_DMISS ;return 1 ; }
@@ -608,6 +607,7 @@ static int get_physical_address_code(CPUSPARCState *env, hwaddr *physical, int *prot, target_ulong address, int mmu_idx) { +CPUState *cs =CPU (sparc_env_get_cpu (env));unsigned int i;uint64_t context;
@@ -651,7 +651,7 @@ static int get_physical_address_code(CPUSPARCState *env,/* FIXME: ASI field in SFSR must be set */ env->immu.sfsr |=SFSR_FT_PRIV_BIT |SFSR_VALID_BIT ; - env->exception_index =TT_TFAULT ; + cs->exception_index =TT_TFAULT ; env->immu.tag_access = (address & ~0x1fffULL ) | context;
@@ -669,7 +669,7 @@ static int get_physical_address_code(CPUSPARCState *env,/* Context is stored in DMMU (dmmuregs[1]) also for IMMU */ env->immu.tag_access = (address & ~0x1fffULL ) | context; - env->exception_index =TT_TMISS ; + cs->exception_index =TT_TMISS ;return 1 ; }
target-unicore32/op_helper.c +3 -1
@@ -16,7 +16,9 @@void HELPER (exception )(CPUUniCore32State *env,uint32_t excp) { - env->exception_index = excp; +CPUState *cs =CPU (uc32_env_get_cpu (env)); + + cs->exception_index = excp;cpu_loop_exit (env); }
target-unicore32/softmmu.c +4 -4
@@ -79,7 +79,7 @@ void uc32_cpu_do_interrupt(CPUState *cs)uint32_t addr;int new_mode; -switch (env->exception_index) { +switch (cs->exception_index) {case UC32_EXCP_PRIV : new_mode =ASR_MODE_PRIV ; addr =0x08 ;
@@ -99,7 +99,7 @@ void uc32_cpu_do_interrupt(CPUState *cs) addr =0x18 ;break ;default : -cpu_abort (env,"Unhandled exception 0x%x\n" , env->exception_index); +cpu_abort (env,"Unhandled exception 0x%x\n" , cs->exception_index);return ; }/* High vectors. */
@@ -256,9 +256,9 @@ int uc32_cpu_handle_mmu_fault(CPUState *cs, vaddr address, env->cp0.c3_faultstatus = ret; env->cp0.c4_faultaddr = address;if (access_type ==2 ) { - env->exception_index =UC32_EXCP_ITRAP ; + cs->exception_index =UC32_EXCP_ITRAP ; }else { - env->exception_index =UC32_EXCP_DTRAP ; + cs->exception_index =UC32_EXCP_DTRAP ; }return ret; }
target-xtensa/helper.c +11 -9
@@ -169,6 +169,8 @@ static void handle_interrupt(CPUXtensaState *env) (env->config->level_mask[level] & env->sregs[INTSET] & env->sregs[INTENABLE])) { +CPUState *cs =CPU (xtensa_env_get_cpu (env)); +if (level >1 ) { env->sregs[EPC1 + level -1 ] = env->pc; env->sregs[EPS2 + level -2 ] = env->sregs[PS ];
@@ -185,10 +187,10 @@ static void handle_interrupt(CPUXtensaState *env) }else { env->sregs[EPC1 ] = env->pc; } - env->exception_index =EXC_DOUBLE ; + cs->exception_index =EXC_DOUBLE ; }else { env->sregs[EPC1 ] = env->pc; - env->exception_index = + cs->exception_index = (env->sregs[PS ] &PS_UM ) ?EXC_USER :EXC_KERNEL ; } env->sregs[PS ] |=PS_EXCM ;
@@ -202,7 +204,7 @@ void xtensa_cpu_do_interrupt(CPUState *cs)XtensaCPU *cpu =XTENSA_CPU (cs);CPUXtensaState *env = &cpu->env; -if (env->exception_index ==EXC_IRQ ) { +if (cs->exception_index ==EXC_IRQ ) {qemu_log_mask (CPU_LOG_INT ,"%s(EXC_IRQ) level = %d, cintlevel = %d, " "pc = %08x, a0 = %08x, ps = %08x, "
@@ -215,7 +217,7 @@ void xtensa_cpu_do_interrupt(CPUState *cs)handle_interrupt (env); } -switch (env->exception_index) { +switch (cs->exception_index) {case EXC_WINDOW_OVERFLOW4 :case EXC_WINDOW_UNDERFLOW4 :case EXC_WINDOW_OVERFLOW8 :
@@ -228,15 +230,15 @@ void xtensa_cpu_do_interrupt(CPUState *cs)case EXC_DEBUG :qemu_log_mask (CPU_LOG_INT ,"%s(%d) " "pc = %08x, a0 = %08x, ps = %08x, ccount = %08x\n" , - __func__, env->exception_index, + __func__, cs->exception_index, env->pc, env->regs[0 ], env->sregs[PS ], env->sregs[CCOUNT ]); -if (env->config->exception_vector[env->exception_index]) { +if (env->config->exception_vector[cs->exception_index]) { env->pc =relocated_vector (env, - env->config->exception_vector[env->exception_index]); + env->config->exception_vector[cs->exception_index]); env->exception_taken =1 ; }else {qemu_log ("%s(pc = %08x) bad exception_index: %d\n" , - __func__, env->pc, env->exception_index); + __func__, env->pc, cs->exception_index); }break ;
@@ -245,7 +247,7 @@ void xtensa_cpu_do_interrupt(CPUState *cs)default :qemu_log ("%s(pc = %08x) unknown exception_index: %d\n" , - __func__, env->pc, env->exception_index); + __func__, env->pc, cs->exception_index);break ; }check_interrupts (env);
target-xtensa/op_helper.c +3 -1
@@ -96,7 +96,9 @@ static void tb_invalidate_virtual_addr(CPUXtensaState *env, uint32_t vaddr)void HELPER (exception )(CPUXtensaState *env,uint32_t excp) { - env->exception_index = excp; +CPUState *cs =CPU (xtensa_env_get_cpu (env)); + + cs->exception_index = excp;if (excp ==EXCP_DEBUG ) { env->exception_taken =0 ; }
user-exec.c +4 -2
@@ -41,7 +41,9 @@static void exception_action (CPUArchState *env1) {#if defined(TARGET_I386 ) -raise_exception_err (env1, env1->exception_index, env1->error_code); +CPUState *cpu =ENV_GET_CPU (env1); + +raise_exception_err (env1, cpu->exception_index, env1->error_code);#else cpu_loop_exit (env1);#endif
@@ -71,7 +73,7 @@ void cpu_resume_from_signal(CPUArchState *env1, void *puc)sigprocmask (SIG_SETMASK , &uc->sc_mask,NULL );#endif } - env1->exception_index =-1 ; + cpu->exception_index =-1 ;siglongjmp (cpu->jmp_env,1 ); }
Signature · 1 line
1.8.1.4