Received: from eggs.gnu.org ([2001:4830:134:3::10]:49607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VH921-0004Rj-B3 for qemu-devel@nongnu.org; Wed, 04 Sep 2013 05:05:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VH91t-0007sW-12 for qemu-devel@nongnu.org; Wed, 04 Sep 2013 05:05:44 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 4 Sep 2013 11:04:43 +0200 Message-Id: <1378285521-3230-4-git-send-email-afaerber@suse.de> In-Reply-To: <1378285521-3230-1-git-send-email-afaerber@suse.de> References: <1378285521-3230-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [RFC qom-cpu 03/41] cpu: Turn cpu_get_tb_cpu_state() into a CPUClass hook List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Jia Liu , Anthony Green , Alexander Graf , Blue Swirl , Max Filippov , Michael Walle , "open list:PowerPC" , Paul Brook , "Edgar E. Iglesias" , Guan Xuetao , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Aurelien Jarno , Richard Henderson Signed-off-by: Andreas F=C3=A4rber --- 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(-) diff --git a/cpu-exec.c b/cpu-exec.c index e9866b8..c839f80 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -153,14 +153,16 @@ static TranslationBlock *tb_find_slow(CPUArchState = *env, =20 static inline TranslationBlock *tb_find_fast(CPUArchState *env) { + CPUState *cpu =3D ENV_GET_CPU(env); + CPUClass *cc =3D CPU_GET_CLASS(cpu); TranslationBlock *tb; - target_ulong cs_base, pc; + vaddr cs_base, pc; int flags; =20 /* 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 =3D env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)]; if (unlikely(!tb || tb->pc !=3D pc || tb->cs_base !=3D cs_base || tb->flags !=3D flags)) { diff --git a/exec.c b/exec.c index 87b0b39..4354eac 100644 --- a/exec.c +++ b/exec.c @@ -1478,8 +1478,10 @@ static const MemoryRegionOps notdirty_mem_ops =3D = { /* Generate a debug exception if a watchpoint has been hit. */ static void check_watchpoint(int offset, int len_mask, int flags) { - CPUArchState *env =3D current_cpu->env_ptr; - target_ulong pc, cs_base; + CPUState *cpu =3D current_cpu; + CPUArchState *env =3D cpu->env_ptr; + CPUClass *cc =3D 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_ma= sk, 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 =3D (env->mem_io_vaddr & TARGET_PAGE_MASK) + offset; @@ -1503,7 +1505,7 @@ static void check_watchpoint(int offset, int len_ma= sk, int flags) env->exception_index =3D 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); } diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c index d3a6fbe..7295e5b 100644 --- a/hw/i386/kvmvapic.c +++ b/hw/i386/kvmvapic.c @@ -395,8 +395,8 @@ static void patch_instruction(VAPICROMState *s, X86CP= U *cpu, target_ulong ip) VAPICHandlers *handlers; uint8_t opcode[2]; uint32_t imm32; - target_ulong current_pc =3D 0; - target_ulong current_cs_base =3D 0; + vaddr current_pc =3D 0; + vaddr current_cs_base =3D 0; int current_flags =3D 0; =20 if (smp_cpus =3D=3D 1) { @@ -406,8 +406,10 @@ static void patch_instruction(VAPICROMState *s, X86C= PU *cpu, target_ulong ip) } =20 if (!kvm_enabled()) { + CPUClass *cc =3D 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); } =20 diff --git a/include/qom/cpu.h b/include/qom/cpu.h index c78d572..3d6b66e 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -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_b= ase, + 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); diff --git a/target-alpha/cpu.c b/target-alpha/cpu.c index 15d6f1f..bb1eddc 100644 --- a/target-alpha/cpu.c +++ b/target-alpha/cpu.c @@ -31,6 +31,29 @@ static void alpha_cpu_set_pc(CPUState *cs, vaddr value= ) cpu->env.pc =3D value; } =20 +static void alpha_cpu_get_tb_cpu_state(const CPUState *cs, vaddr *pc, + vaddr *cs_base, int *pflags) +{ + AlphaCPU *cpu =3D ALPHA_CPU(cs); + CPUAlphaState *env =3D &cpu->env; + int flags =3D 0; + + *pc =3D env->pc; + *cs_base =3D 0; + + if (env->pal_mode) { + flags =3D TB_FLAGS_PAL_MODE; + } else { + flags =3D env->ps & PS_USER_MODE; + } + if (env->fen) { + flags |=3D TB_FLAGS_FEN; + } + flags |=3D env->amask << TB_FLAGS_AMASK_SHIFT; + + *pflags =3D flags; +} + static int alpha_cpu_mmu_index(const CPUState *cs) { AlphaCPU *cpu =3D ALPHA_CPU(cs); @@ -304,6 +327,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, voi= d *data) cc->dump_state =3D alpha_cpu_dump_state; cc->mmu_index =3D alpha_cpu_mmu_index; cc->set_pc =3D alpha_cpu_set_pc; + cc->get_tb_cpu_state =3D alpha_cpu_get_tb_cpu_state; cc->gdb_read_register =3D alpha_cpu_gdb_read_register; cc->gdb_write_register =3D alpha_cpu_gdb_write_register; #ifndef CONFIG_USER_ONLY diff --git a/target-alpha/cpu.h b/target-alpha/cpu.h index 808fe53..a4abce8 100644 --- a/target-alpha/cpu.h +++ b/target-alpha/cpu.h @@ -466,27 +466,6 @@ enum { TB_FLAGS_AMASK_PREFETCH =3D AMASK_PREFETCH << TB_FLAGS_AMASK_SHIFT, }; =20 -static inline void cpu_get_tb_cpu_state(CPUAlphaState *env, target_ulong= *pc, - target_ulong *cs_base, int *pfla= gs) -{ - int flags =3D 0; - - *pc =3D env->pc; - *cs_base =3D 0; - - if (env->pal_mode) { - flags =3D TB_FLAGS_PAL_MODE; - } else { - flags =3D env->ps & PS_USER_MODE; - } - if (env->fen) { - flags |=3D TB_FLAGS_FEN; - } - flags |=3D env->amask << TB_FLAGS_AMASK_SHIFT; - - *pflags =3D flags; -} - #include "exec/exec-all.h" =20 #endif /* !defined (__CPU_ALPHA_H__) */ diff --git a/target-arm/cpu.c b/target-arm/cpu.c index 6032a2c..53bf337 100644 --- a/target-arm/cpu.c +++ b/target-arm/cpu.c @@ -34,6 +34,33 @@ static void arm_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.regs[15] =3D value; } =20 +static void arm_cpu_get_tb_cpu_state(const CPUState *cs, vaddr *pc, + vaddr *cs_base, int *flags) +{ + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; + int privmode; + + *pc =3D env->regs[15]; + *cs_base =3D 0; + *flags =3D (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 =3D !((env->v7m.exception =3D=3D 0) && (env->v7m.contro= l & 1)); + } else { + privmode =3D (env->uncached_cpsr & CPSR_M) !=3D ARM_CPU_MODE_USR= ; + } + if (privmode) { + *flags |=3D ARM_TBFLAG_PRIV_MASK; + } + if (env->vfp.xregs[ARM_VFP_FPEXC] & (1 << 30)) { + *flags |=3D ARM_TBFLAG_VFPEN_MASK; + } +} + static int arm_cpu_mmu_index(const CPUState *cs) { ARMCPU *cpu =3D ARM_CPU(cs); @@ -908,6 +935,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void = *data) cc->dump_state =3D arm_cpu_dump_state; cc->mmu_index =3D arm_cpu_mmu_index; cc->set_pc =3D arm_cpu_set_pc; + cc->get_tb_cpu_state =3D arm_cpu_get_tb_cpu_state; cc->gdb_read_register =3D arm_cpu_gdb_read_register; cc->gdb_write_register =3D arm_cpu_gdb_write_register; #ifndef CONFIG_USER_ONLY diff --git a/target-arm/cpu.h b/target-arm/cpu.h index 19fa4ee..161b9fd 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -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) =20 -static inline void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *= pc, - target_ulong *cs_base, int *flag= s) -{ - int privmode; - *pc =3D env->regs[15]; - *cs_base =3D 0; - *flags =3D (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 =3D !((env->v7m.exception =3D=3D 0) && (env->v7m.contro= l & 1)); - } else { - privmode =3D (env->uncached_cpsr & CPSR_M) !=3D ARM_CPU_MODE_USR= ; - } - if (privmode) { - *flags |=3D ARM_TBFLAG_PRIV_MASK; - } - if (env->vfp.xregs[ARM_VFP_FPEXC] & (1 << 30)) { - *flags |=3D ARM_TBFLAG_VFPEN_MASK; - } -} - #include "exec/exec-all.h" =20 /* Load an instruction and return it in the standard little-endian order= */ diff --git a/target-cris/cpu.c b/target-cris/cpu.c index 1e5b425..39a25ed 100644 --- a/target-cris/cpu.c +++ b/target-cris/cpu.c @@ -33,6 +33,19 @@ static void cris_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc =3D value; } =20 +static void cris_cpu_get_tb_cpu_state(const CPUState *cs, vaddr *pc, + vaddr *cs_base, int *flags) +{ + CRISCPU *cpu =3D CRIS_CPU(cs); + CPUCRISState *env =3D &cpu->env; + + *pc =3D env->pc; + *cs_base =3D 0; + *flags =3D 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 =3D CRIS_CPU(cs); @@ -274,6 +287,7 @@ static void cris_cpu_class_init(ObjectClass *oc, void= *data) cc->dump_state =3D cris_cpu_dump_state; cc->mmu_index =3D cris_cpu_mmu_index; cc->set_pc =3D cris_cpu_set_pc; + cc->get_tb_cpu_state =3D cris_cpu_get_tb_cpu_state; cc->gdb_read_register =3D cris_cpu_gdb_read_register; cc->gdb_write_register =3D cris_cpu_gdb_write_register; #ifndef CONFIG_USER_ONLY diff --git a/target-cris/cpu.h b/target-cris/cpu.h index 0914103..9f1fa38 100644 --- a/target-cris/cpu.h +++ b/target-cris/cpu.h @@ -255,16 +255,6 @@ int cpu_cris_handle_mmu_fault(CPUCRISState *env, tar= get_ulong address, int rw, =20 #include "exec/cpu-all.h" =20 -static inline void cpu_get_tb_cpu_state(CPUCRISState *env, target_ulong = *pc, - target_ulong *cs_base, int *flag= s) -{ - *pc =3D env->pc; - *cs_base =3D 0; - *flags =3D env->dslot | - (env->pregs[PR_CCS] & (S_FLAG | P_FLAG | U_FLAG - | X_FLAG | PFIX_FLAG)); -} - #define cpu_list cris_cpu_list void cris_cpu_list(FILE *f, fprintf_function cpu_fprintf); =20 diff --git a/target-i386/cpu.c b/target-i386/cpu.c index a623383..995d5ff 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -2669,6 +2669,18 @@ static void x86_cpu_set_pc(CPUState *cs, vaddr val= ue) cpu->env.eip =3D value; } =20 +static void x86_cpu_get_tb_cpu_state(const CPUState *cs, vaddr *pc, + vaddr *cs_base, int *flags) +{ + X86CPU *cpu =3D X86_CPU(cs); + CPUX86State *env =3D &cpu->env; + + *cs_base =3D env->segs[R_CS].base; + *pc =3D *cs_base + env->eip; + *flags =3D env->hflags | + (env->eflags & (IOPL_MASK | TF_MASK | RF_MASK | VM_MASK | AC_MAS= K)); +} + static void x86_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *= tb) { X86CPU *cpu =3D X86_CPU(cs); @@ -2725,6 +2737,7 @@ static void x86_cpu_common_class_init(ObjectClass *= oc, void *data) cc->dump_state =3D x86_cpu_dump_state; cc->mmu_index =3D x86_cpu_mmu_index; cc->set_pc =3D x86_cpu_set_pc; + cc->get_tb_cpu_state =3D x86_cpu_get_tb_cpu_state; cc->synchronize_from_tb =3D x86_cpu_synchronize_from_tb; cc->gdb_read_register =3D x86_cpu_gdb_read_register; cc->gdb_write_register =3D x86_cpu_gdb_write_register; diff --git a/target-i386/cpu.h b/target-i386/cpu.h index fd16f20..999a46c 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -1157,15 +1157,6 @@ void optimize_flags_init(void); =20 #include "exec/exec-all.h" =20 -static inline void cpu_get_tb_cpu_state(CPUX86State *env, target_ulong *= pc, - target_ulong *cs_base, int *flag= s) -{ - *cs_base =3D env->segs[R_CS].base; - *pc =3D *cs_base + env->eip; - *flags =3D env->hflags | - (env->eflags & (IOPL_MASK | TF_MASK | RF_MASK | VM_MASK | AC_MAS= K)); -} - void do_cpu_init(X86CPU *cpu); void do_cpu_sipi(X86CPU *cpu); =20 diff --git a/target-lm32/cpu.c b/target-lm32/cpu.c index 4fa8605..7976d39 100644 --- a/target-lm32/cpu.c +++ b/target-lm32/cpu.c @@ -29,6 +29,16 @@ static void lm32_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc =3D value; } =20 +static void lm32_cpu_get_tb_cpu_state(const CPUState *cs, vaddr *pc, + vaddr *cs_base, int *flags) +{ + LM32CPU *cpu =3D LM32_CPU(cs); + + *pc =3D cpu->env.pc; + *cs_base =3D 0; + *flags =3D 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 =3D lm32_cpu_do_interrupt; cc->dump_state =3D lm32_cpu_dump_state; cc->set_pc =3D lm32_cpu_set_pc; + cc->get_tb_cpu_state =3D lm32_cpu_get_tb_cpu_state; cc->gdb_read_register =3D lm32_cpu_gdb_read_register; cc->gdb_write_register =3D lm32_cpu_gdb_write_register; #ifndef CONFIG_USER_ONLY diff --git a/target-lm32/cpu.h b/target-lm32/cpu.h index 11f54e7..a34f047 100644 --- a/target-lm32/cpu.h +++ b/target-lm32/cpu.h @@ -212,15 +212,6 @@ int cpu_lm32_handle_mmu_fault(CPULM32State *env, tar= get_ulong address, int rw, #define cpu_handle_mmu_fault cpu_lm32_handle_mmu_fault =20 #include "exec/cpu-all.h" - -static inline void cpu_get_tb_cpu_state(CPULM32State *env, target_ulong = *pc, - target_ulong *cs_base, int *flag= s) -{ - *pc =3D env->pc; - *cs_base =3D 0; - *flags =3D 0; -} - #include "exec/exec-all.h" =20 #endif diff --git a/target-m68k/cpu.c b/target-m68k/cpu.c index 00454ab..6dbfe89 100644 --- a/target-m68k/cpu.c +++ b/target-m68k/cpu.c @@ -30,6 +30,19 @@ static void m68k_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc =3D value; } =20 +static void m68k_cpu_get_tb_cpu_state(const CPUState *cs, vaddr *pc, + vaddr *cs_base, int *flags) +{ + M68kCPU *cpu =3D M68K_CPU(cs); + CPUM68KState *env =3D &cpu->env; + + *pc =3D env->pc; + *cs_base =3D 0; + *flags =3D (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 =3D M68K_CPU(cs); @@ -206,6 +219,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void = *data) cc->dump_state =3D m68k_cpu_dump_state; cc->mmu_index =3D m68k_cpu_mmu_index; cc->set_pc =3D m68k_cpu_set_pc; + cc->get_tb_cpu_state =3D m68k_cpu_get_tb_cpu_state; cc->gdb_read_register =3D m68k_cpu_gdb_read_register; cc->gdb_write_register =3D m68k_cpu_gdb_write_register; #ifndef CONFIG_USER_ONLY diff --git a/target-m68k/cpu.h b/target-m68k/cpu.h index d1291d8..5c7992e 100644 --- a/target-m68k/cpu.h +++ b/target-m68k/cpu.h @@ -238,17 +238,6 @@ int cpu_m68k_handle_mmu_fault(CPUM68KState *env, tar= get_ulong address, int rw, #define cpu_handle_mmu_fault cpu_m68k_handle_mmu_fault =20 #include "exec/cpu-all.h" - -static inline void cpu_get_tb_cpu_state(CPUM68KState *env, target_ulong = *pc, - target_ulong *cs_base, int *flag= s) -{ - *pc =3D env->pc; - *cs_base =3D 0; - *flags =3D (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" =20 #endif diff --git a/target-microblaze/cpu.c b/target-microblaze/cpu.c index 929efd8..fbcdcc4 100644 --- a/target-microblaze/cpu.c +++ b/target-microblaze/cpu.c @@ -33,6 +33,18 @@ static void mb_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.sregs[SR_PC] =3D value; } =20 +static void mb_cpu_get_tb_cpu_state(const CPUState *cs, vaddr *pc, + vaddr *cs_base, int *flags) +{ + MicroBlazeCPU *cpu =3D MICROBLAZE_CPU(cs); + CPUMBState *env =3D &cpu->env; + + *pc =3D env->sregs[SR_PC]; + *cs_base =3D 0; + *flags =3D (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 =3D MICROBLAZE_CPU(cs); @@ -163,6 +175,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *= data) cc->dump_state =3D mb_cpu_dump_state; cc->mmu_index =3D mb_cpu_mmu_index; cc->set_pc =3D mb_cpu_set_pc; + cc->get_tb_cpu_state =3D mb_cpu_get_tb_cpu_state; cc->gdb_read_register =3D mb_cpu_gdb_read_register; cc->gdb_write_register =3D mb_cpu_gdb_write_register; #ifndef CONFIG_USER_ONLY diff --git a/target-microblaze/cpu.h b/target-microblaze/cpu.h index a81f899..d80f812 100644 --- a/target-microblaze/cpu.h +++ b/target-microblaze/cpu.h @@ -332,15 +332,6 @@ static inline target_ulong cpu_get_pc(CPUMBState *en= v) return env->sregs[SR_PC]; } =20 -static inline void cpu_get_tb_cpu_state(CPUMBState *env, target_ulong *p= c, - target_ulong *cs_base, int *flag= s) -{ - *pc =3D env->sregs[SR_PC]; - *cs_base =3D 0; - *flags =3D (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, diff --git a/target-mips/cpu.c b/target-mips/cpu.c index cb916f3..4aa06bb 100644 --- a/target-mips/cpu.c +++ b/target-mips/cpu.c @@ -35,6 +35,17 @@ static void mips_cpu_set_pc(CPUState *cs, vaddr value) } } =20 +static void mips_cpu_get_tb_cpu_state(const CPUState *cs, vaddr *pc, + vaddr *cs_base, int *flags) +{ + MIPSCPU *cpu =3D MIPS_CPU(cs); + CPUMIPSState *env =3D &cpu->env; + + *pc =3D env->active_tc.PC; + *cs_base =3D 0; + *flags =3D env->hflags & (MIPS_HFLAG_TMASK | MIPS_HFLAG_BMASK); +} + static void mips_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock = *tb) { MIPSCPU *cpu =3D MIPS_CPU(cs); @@ -138,6 +149,7 @@ static void mips_cpu_class_init(ObjectClass *c, void = *data) cc->dump_state =3D mips_cpu_dump_state; cc->mmu_index =3D mips_cpu_mmu_index; cc->set_pc =3D mips_cpu_set_pc; + cc->get_tb_cpu_state =3D mips_cpu_get_tb_cpu_state; cc->synchronize_from_tb =3D mips_cpu_synchronize_from_tb; cc->gdb_read_register =3D mips_cpu_gdb_read_register; cc->gdb_write_register =3D mips_cpu_gdb_write_register; diff --git a/target-mips/cpu.h b/target-mips/cpu.h index 22643ff..91217ed 100644 --- a/target-mips/cpu.h +++ b/target-mips/cpu.h @@ -659,14 +659,6 @@ hwaddr cpu_mips_translate_address (CPUMIPSState *env= , target_ulong address, #endif target_ulong exception_resume_pc (CPUMIPSState *env); =20 -static inline void cpu_get_tb_cpu_state(CPUMIPSState *env, target_ulong = *pc, - target_ulong *cs_base, int *flag= s) -{ - *pc =3D env->active_tc.PC; - *cs_base =3D 0; - *flags =3D env->hflags & (MIPS_HFLAG_TMASK | MIPS_HFLAG_BMASK); -} - static inline int mips_vpe_active(CPUMIPSState *env) { int active =3D 1; diff --git a/target-moxie/cpu.c b/target-moxie/cpu.c index 66f337e..9983c99 100644 --- a/target-moxie/cpu.c +++ b/target-moxie/cpu.c @@ -29,6 +29,16 @@ static void moxie_cpu_set_pc(CPUState *cs, vaddr value= ) cpu->env.pc =3D value; } =20 +static void moxie_cpu_get_tb_cpu_state(const CPUState *cs, vaddr *pc, + vaddr *cs_base, int *flags) +{ + MoxieCPU *cpu =3D MOXIE_CPU(cs); + + *pc =3D cpu->env.pc; + *cs_base =3D 0; + *flags =3D 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, voi= d *data) cc->do_interrupt =3D moxie_cpu_do_interrupt; cc->dump_state =3D moxie_cpu_dump_state; cc->set_pc =3D moxie_cpu_set_pc; + cc->get_tb_cpu_state =3D moxie_cpu_get_tb_cpu_state; #ifndef CONFIG_USER_ONLY cc->get_phys_page_debug =3D moxie_cpu_get_phys_page_debug; cc->vmsd =3D &vmstate_moxie_cpu; diff --git a/target-moxie/cpu.h b/target-moxie/cpu.h index affcfca..7e33efe 100644 --- a/target-moxie/cpu.h +++ b/target-moxie/cpu.h @@ -139,14 +139,6 @@ static inline CPUMoxieState *cpu_init(const char *cp= u_model) #include "exec/cpu-all.h" #include "exec/exec-all.h" =20 -static inline void cpu_get_tb_cpu_state(CPUMoxieState *env, target_ulong= *pc, - target_ulong *cs_base, int *flag= s) -{ - *pc =3D env->pc; - *cs_base =3D 0; - *flags =3D 0; -} - int cpu_moxie_handle_mmu_fault(CPUMoxieState *env, target_ulong address, int rw, int mmu_idx); =20 diff --git a/target-openrisc/cpu.c b/target-openrisc/cpu.c index 4872fcf..107e5f9 100644 --- a/target-openrisc/cpu.c +++ b/target-openrisc/cpu.c @@ -27,6 +27,17 @@ static void openrisc_cpu_set_pc(CPUState *cs, vaddr va= lue) cpu->env.pc =3D value; } =20 +static void openrisc_cpu_get_tb_cpu_state(const CPUState *cs, vaddr *pc, + vaddr *cs_base, int *flags) +{ + OpenRISCCPU *cpu =3D OPENRISC_CPU(cs); + + *pc =3D cpu->env.pc; + *cs_base =3D 0; + /* D_FLAG -- branch instruction exception */ + *flags =3D (cpu->env.flags & D_FLAG); +} + static int openrisc_cpu_mmu_index(const CPUState *cs) { OpenRISCCPU *cpu =3D OPENRISC_CPU(cs); @@ -174,6 +185,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, = void *data) cc->dump_state =3D openrisc_cpu_dump_state; cc->mmu_index =3D openrisc_cpu_mmu_index; cc->set_pc =3D openrisc_cpu_set_pc; + cc->get_tb_cpu_state =3D openrisc_cpu_get_tb_cpu_state; cc->gdb_read_register =3D openrisc_cpu_gdb_read_register; cc->gdb_write_register =3D openrisc_cpu_gdb_write_register; #ifndef CONFIG_USER_ONLY diff --git a/target-openrisc/cpu.h b/target-openrisc/cpu.h index 2a1ca92..a41c271 100644 --- a/target-openrisc/cpu.h +++ b/target-openrisc/cpu.h @@ -399,16 +399,6 @@ static inline CPUOpenRISCState *cpu_init(const char = *cpu_model) =20 #include "exec/cpu-all.h" =20 -static inline void cpu_get_tb_cpu_state(CPUOpenRISCState *env, - target_ulong *pc, - target_ulong *cs_base, int *flag= s) -{ - *pc =3D env->pc; - *cs_base =3D 0; - /* D_FLAG -- branch instruction exception */ - *flags =3D (env->flags & D_FLAG); -} - #define CPU_INTERRUPT_TIMER CPU_INTERRUPT_TGT_INT_0 =20 #include "exec/exec-all.h" diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h index 9c99f0d..2ebf0a1 100644 --- a/target-ppc/cpu.h +++ b/target-ppc/cpu.h @@ -2015,14 +2015,6 @@ static inline void cpu_write_xer(CPUPPCState *env,= target_ulong xer) env->xer =3D xer & ~((1u << XER_SO) | (1u << XER_OV) | (1u << XER_CA= )); } =20 -static inline void cpu_get_tb_cpu_state(CPUPPCState *env, target_ulong *= pc, - target_ulong *cs_base, int *flag= s) -{ - *pc =3D env->nip; - *cs_base =3D 0; - *flags =3D env->hflags; -} - #if !defined(CONFIG_USER_ONLY) static inline int booke206_tlbm_id(CPUPPCState *env, ppcmas_tlb_t *tlbm) { diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c index e4bcf74..338d8fe 100644 --- a/target-ppc/translate_init.c +++ b/target-ppc/translate_init.c @@ -8437,6 +8437,16 @@ static void ppc_cpu_set_pc(CPUState *cs, vaddr val= ue) cpu->env.nip =3D value; } =20 +static void ppc_cpu_get_tb_cpu_state(const CPUState *cs, vaddr *pc, + vaddr *cs_base, int *flags) +{ + PowerPCCPU *cpu =3D POWERPC_CPU(cs); + + *pc =3D cpu->env.nip; + *cs_base =3D 0; + *flags =3D cpu->env.hflags; +} + static int ppc_cpu_mmu_index(const CPUState *cs) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); @@ -8582,6 +8592,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, voi= d *data) cc->dump_statistics =3D ppc_cpu_dump_statistics; cc->mmu_index =3D ppc_cpu_mmu_index; cc->set_pc =3D ppc_cpu_set_pc; + cc->get_tb_cpu_state =3D ppc_cpu_get_tb_cpu_state; cc->gdb_read_register =3D ppc_cpu_gdb_read_register; cc->gdb_write_register =3D ppc_cpu_gdb_write_register; #ifndef CONFIG_USER_ONLY diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c index 6b200fe..a4a5370 100644 --- a/target-s390x/cpu.c +++ b/target-s390x/cpu.c @@ -65,6 +65,18 @@ static void s390_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.psw.addr =3D value; } =20 +static void s390_cpu_get_tb_cpu_state(const CPUState *cs, vaddr *pc, + vaddr *cs_base, int *flags) +{ + S390CPU *cpu =3D S390_CPU(cs); + CPUS390XState *env =3D &cpu->env; + + *pc =3D env->psw.addr; + *cs_base =3D 0; + *flags =3D ((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 =3D S390_CPU(cs); @@ -242,6 +254,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void= *data) cc->dump_state =3D s390_cpu_dump_state; cc->mmu_index =3D s390_cpu_mmu_index; cc->set_pc =3D s390_cpu_set_pc; + cc->get_tb_cpu_state =3D s390_cpu_get_tb_cpu_state; cc->gdb_read_register =3D s390_cpu_gdb_read_register; cc->gdb_write_register =3D s390_cpu_gdb_write_register; #ifndef CONFIG_USER_ONLY diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h index d7970e6..cad092b 100644 --- a/target-s390x/cpu.h +++ b/target-s390x/cpu.h @@ -273,15 +273,6 @@ typedef struct CPUS390XState { #define FLAG_MASK_64 (PSW_MASK_64 >> 32) #define FLAG_MASK_32 0x00001000 =20 -static inline void cpu_get_tb_cpu_state(CPUS390XState* env, target_ulong= *pc, - target_ulong *cs_base, int *flag= s) -{ - *pc =3D env->psw.addr; - *cs_base =3D 0; - *flags =3D ((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 diff --git a/target-sh4/cpu.c b/target-sh4/cpu.c index df1c0e8..647a527 100644 --- a/target-sh4/cpu.c +++ b/target-sh4/cpu.c @@ -31,6 +31,22 @@ static void superh_cpu_set_pc(CPUState *cs, vaddr valu= e) cpu->env.pc =3D value; } =20 +static void superh_cpu_get_tb_cpu_state(const CPUState *cs, vaddr *pc, + vaddr *cs_base, int *flags) +{ + SuperHCPU *cpu =3D SUPERH_CPU(cs); + CPUSH4State *env =3D &cpu->env; + + *pc =3D env->pc; + *cs_base =3D 0; + *flags =3D (env->flags & (DELAY_SLOT | DELAY_SLOT_CONDITIONAL | + DELAY_SLOT_TRUE | DELAY_SLOT_CLEARME)) /* B= its 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, TranslationBloc= k *tb) { SuperHCPU *cpu =3D SUPERH_CPU(cs); @@ -300,6 +316,7 @@ static void superh_cpu_class_init(ObjectClass *oc, vo= id *data) cc->dump_state =3D superh_cpu_dump_state; cc->mmu_index =3D superh_cpu_mmu_index; cc->set_pc =3D superh_cpu_set_pc; + cc->get_tb_cpu_state =3D superh_cpu_get_tb_cpu_state; cc->synchronize_from_tb =3D superh_cpu_synchronize_from_tb; cc->gdb_read_register =3D superh_cpu_gdb_read_register; cc->gdb_write_register =3D superh_cpu_gdb_write_register; diff --git a/target-sh4/cpu.h b/target-sh4/cpu.h index 6125c20..42ecdd7 100644 --- a/target-sh4/cpu.h +++ b/target-sh4/cpu.h @@ -335,19 +335,6 @@ static inline int cpu_ptel_pr (uint32_t ptel) =20 #define TB_FLAG_PENDING_MOVCA (1 << 4) =20 -static inline void cpu_get_tb_cpu_state(CPUSH4State *env, target_ulong *= pc, - target_ulong *cs_base, int *flag= s) -{ - *pc =3D env->pc; - *cs_base =3D 0; - *flags =3D (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 1= 9-21 */ - | (env->sr & (SR_MD | SR_RB)) /* Bits 2= 9-30 */ - | (env->sr & SR_FD) /* Bit 15= */ - | (env->movcal_backup ? TB_FLAG_PENDING_MOVCA : 0); /* Bit 4= */ -} - #include "exec/exec-all.h" =20 #endif /* _CPU_SH4_H */ diff --git a/target-sparc/cpu.c b/target-sparc/cpu.c index 1d27f9e..49a4469 100644 --- a/target-sparc/cpu.c +++ b/target-sparc/cpu.c @@ -731,6 +731,36 @@ static void sparc_cpu_set_pc(CPUState *cs, vaddr val= ue) cpu->env.npc =3D value + 4; } =20 +static void sparc_cpu_get_tb_cpu_state(const CPUState *cs, vaddr *pc, + vaddr *cs_base, int *flags) +{ + SPARCCPU *cpu =3D SPARC_CPU(cs); + CPUSPARCState *env =3D &cpu->env; + + *pc =3D env->pc; + *cs_base =3D env->npc; +#ifdef TARGET_SPARC64 + /* AM . Combined FPU enable bits . PRIV . DMMU enabled . IMMU enable= d */ + *flags =3D (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 |=3D TB_FLAG_AM_ENABLED; + } + if ((env->def->features & CPU_FEATURE_FLOAT) && (env->pstate & PS_PE= F) + && (env->fprs & FPRS_FEF)) { + *flags |=3D TB_FLAG_FPU_ENABLED; + } +#else + /* FPU enable . Supervisor */ + *flags =3D env->psrs; + if ((env->def->features & CPU_FEATURE_FLOAT) && env->psref) { + *flags |=3D TB_FLAG_FPU_ENABLED; + } +#endif +} + static void sparc_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock= *tb) { SPARCCPU *cpu =3D SPARC_CPU(cs); @@ -823,6 +853,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, voi= d *data) #endif cc->mmu_index =3D sparc_cpu_mmu_index; cc->set_pc =3D sparc_cpu_set_pc; + cc->get_tb_cpu_state =3D sparc_cpu_get_tb_cpu_state; cc->synchronize_from_tb =3D sparc_cpu_synchronize_from_tb; cc->gdb_read_register =3D sparc_cpu_gdb_read_register; cc->gdb_write_register =3D sparc_cpu_gdb_write_register; diff --git a/target-sparc/cpu.h b/target-sparc/cpu.h index 93590b8..f078851 100644 --- a/target-sparc/cpu.h +++ b/target-sparc/cpu.h @@ -683,33 +683,6 @@ trap_state* cpu_tsptr(CPUSPARCState* env); #define TB_FLAG_FPU_ENABLED (1 << 4) #define TB_FLAG_AM_ENABLED (1 << 5) =20 -static inline void cpu_get_tb_cpu_state(CPUSPARCState *env, target_ulong= *pc, - target_ulong *cs_base, int *flag= s) -{ - *pc =3D env->pc; - *cs_base =3D env->npc; -#ifdef TARGET_SPARC64 - // AM . Combined FPU enable bits . PRIV . DMMU enabled . IMMU enable= d - *flags =3D (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 |=3D TB_FLAG_AM_ENABLED; - } - if ((env->def->features & CPU_FEATURE_FLOAT) && (env->pstate & PS_PE= F) - && (env->fprs & FPRS_FEF)) { - *flags |=3D TB_FLAG_FPU_ENABLED; - } -#else - // FPU enable . Supervisor - *flags =3D env->psrs; - if ((env->def->features & CPU_FEATURE_FLOAT) && env->psref) { - *flags |=3D TB_FLAG_FPU_ENABLED; - } -#endif -} - static inline bool tb_fpu_enabled(int tb_flags) { #if defined(CONFIG_USER_ONLY) diff --git a/target-unicore32/cpu.c b/target-unicore32/cpu.c index 3ed9ea3..e5fddcf 100644 --- a/target-unicore32/cpu.c +++ b/target-unicore32/cpu.c @@ -23,6 +23,19 @@ static void uc32_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.regs[31] =3D value; } =20 +static void uc32_cpu_get_tb_cpu_state(const CPUState *cs, vaddr *pc, + vaddr *cs_base, int *flags) +{ + UniCore32CPU *cpu =3D UNICORE32_CPU(cs); + + *pc =3D cpu->env.regs[31]; + *cs_base =3D 0; + *flags =3D 0; + if ((cpu->env.uncached_asr & ASR_M) !=3D ASR_MODE_USER) { + *flags |=3D (1 << 6); + } +} + static int uc32_cpu_mmu_index(const CPUState *cs) { UniCore32CPU *cpu =3D UNICORE32_CPU(cs); @@ -156,6 +169,7 @@ static void uc32_cpu_class_init(ObjectClass *oc, void= *data) cc->dump_state =3D uc32_cpu_dump_state; cc->mmu_index =3D uc32_cpu_mmu_index; cc->set_pc =3D uc32_cpu_set_pc; + cc->get_tb_cpu_state =3D uc32_cpu_get_tb_cpu_state; #ifndef CONFIG_USER_ONLY cc->get_phys_page_debug =3D uc32_cpu_get_phys_page_debug; #endif diff --git a/target-unicore32/cpu.h b/target-unicore32/cpu.h index 07693d5..75f5fa9 100644 --- a/target-unicore32/cpu.h +++ b/target-unicore32/cpu.h @@ -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" =20 -static inline void cpu_get_tb_cpu_state(CPUUniCore32State *env, target_u= long *pc, - target_ulong *cs_base, int *flag= s) -{ - *pc =3D env->regs[31]; - *cs_base =3D 0; - *flags =3D 0; - if ((env->uncached_asr & ASR_M) !=3D ASR_MODE_USER) { - *flags |=3D (1 << 6); - } -} - void uc32_translate_init(void); void switch_mode(CPUUniCore32State *, int); =20 diff --git a/target-xtensa/cpu.c b/target-xtensa/cpu.c index f99feaa..2b47d13 100644 --- a/target-xtensa/cpu.c +++ b/target-xtensa/cpu.c @@ -40,6 +40,39 @@ static void xtensa_cpu_set_pc(CPUState *cs, vaddr valu= e) cpu->env.pc =3D value; } =20 +static void xtensa_cpu_get_tb_cpu_state(const CPUState *cs, vaddr *pc, + vaddr *cs_base, int *flags) +{ + XtensaCPU *cpu =3D XTENSA_CPU(cs); + CPUXtensaState *env =3D &cpu->env; + + *pc =3D env->pc; + *cs_base =3D 0; + *flags =3D 0; + *flags |=3D xtensa_get_ring(env); + if (env->sregs[PS] & PS_EXCM) { + *flags |=3D XTENSA_TBFLAG_EXCM; + } + if (xtensa_option_enabled(env->config, XTENSA_OPTION_EXTENDED_L32R) = && + (env->sregs[LITBASE] & 1)) { + *flags |=3D XTENSA_TBFLAG_LITBASE; + } + if (xtensa_option_enabled(env->config, XTENSA_OPTION_DEBUG)) { + if (xtensa_get_cintlevel(env) < env->config->debug_level) { + *flags |=3D XTENSA_TBFLAG_DEBUG; + } + if (xtensa_get_cintlevel(env) < env->sregs[ICOUNTLEVEL]) { + *flags |=3D XTENSA_TBFLAG_ICOUNT; + } + } + if (xtensa_option_enabled(env->config, XTENSA_OPTION_COPROCESSOR)) { + *flags |=3D env->sregs[CPENABLE] << XTENSA_TBFLAG_CPENABLE_SHIFT= ; + } + if (cs->singlestep_enabled && env->exception_taken) { + *flags |=3D XTENSA_TBFLAG_EXCEPTION; + } +} + static int xtensa_cpu_mmu_index(const CPUState *cs) { XtensaCPU *cpu =3D XTENSA_CPU(cs); @@ -151,6 +184,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, vo= id *data) cc->dump_state =3D xtensa_cpu_dump_state; cc->mmu_index =3D xtensa_cpu_mmu_index; cc->set_pc =3D xtensa_cpu_set_pc; + cc->get_tb_cpu_state =3D xtensa_cpu_get_tb_cpu_state; cc->gdb_read_register =3D xtensa_cpu_gdb_read_register; cc->gdb_write_register =3D xtensa_cpu_gdb_write_register; #ifndef CONFIG_USER_ONLY diff --git a/target-xtensa/cpu.h b/target-xtensa/cpu.h index 4fdaf20..5d2a059 100644 --- a/target-xtensa/cpu.h +++ b/target-xtensa/cpu.h @@ -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 =20 -static inline void cpu_get_tb_cpu_state(CPUXtensaState *env, target_ulon= g *pc, - target_ulong *cs_base, int *flags) -{ - *pc =3D env->pc; - *cs_base =3D 0; - *flags =3D 0; - *flags |=3D xtensa_get_ring(env); - if (env->sregs[PS] & PS_EXCM) { - *flags |=3D XTENSA_TBFLAG_EXCM; - } - if (xtensa_option_enabled(env->config, XTENSA_OPTION_EXTENDED_L32R) = && - (env->sregs[LITBASE] & 1)) { - *flags |=3D XTENSA_TBFLAG_LITBASE; - } - if (xtensa_option_enabled(env->config, XTENSA_OPTION_DEBUG)) { - if (xtensa_get_cintlevel(env) < env->config->debug_level) { - *flags |=3D XTENSA_TBFLAG_DEBUG; - } - if (xtensa_get_cintlevel(env) < env->sregs[ICOUNTLEVEL]) { - *flags |=3D XTENSA_TBFLAG_ICOUNT; - } - } - if (xtensa_option_enabled(env->config, XTENSA_OPTION_COPROCESSOR)) { - *flags |=3D env->sregs[CPENABLE] << XTENSA_TBFLAG_CPENABLE_SHIFT= ; - } - if (ENV_GET_CPU(env)->singlestep_enabled && env->exception_taken) { - *flags |=3D XTENSA_TBFLAG_EXCEPTION; - } -} - #include "exec/cpu-all.h" #include "exec/exec-all.h" =20 diff --git a/translate-all.c b/translate-all.c index 2c923c6..6000d4a 100644 --- a/translate-all.c +++ b/translate-all.c @@ -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 =3D NULL; int current_tb_not_found =3D is_cpu_write_access; TranslationBlock *current_tb =3D NULL; int current_tb_modified =3D 0; - target_ulong current_pc =3D 0; - target_ulong current_cs_base =3D 0; + vaddr current_pc =3D 0; + vaddr current_cs_base =3D 0; int current_flags =3D 0; #endif /* TARGET_HAS_PRECISE_SMC */ =20 @@ -1032,6 +1033,9 @@ void tb_invalidate_phys_page_range(tb_page_addr_t s= tart, tb_page_addr_t end, #if defined(TARGET_HAS_PRECISE_SMC) || !defined(CONFIG_USER_ONLY) if (cpu !=3D NULL) { env =3D cpu->env_ptr; +#ifdef TARGET_HAS_PRECISE_SMC + cc =3D CPU_GET_CLASS(cpu); +#endif } #endif =20 @@ -1073,7 +1077,7 @@ void tb_invalidate_phys_page_range(tb_page_addr_t s= tart, tb_page_addr_t end, =20 current_tb_modified =3D 1; cpu_restore_state_from_tb(current_tb, env, env->mem_io_p= c); - 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 =3D NULL; CPUState *cpu =3D current_cpu; + CPUClass *cc =3D NULL; CPUArchState *env =3D NULL; int current_tb_modified =3D 0; - target_ulong current_pc =3D 0; - target_ulong current_cs_base =3D 0; + vaddr current_pc =3D 0; + vaddr current_cs_base =3D 0; int current_flags =3D 0; #endif =20 @@ -1176,6 +1181,7 @@ static void tb_invalidate_phys_page(tb_page_addr_t = addr, } if (cpu !=3D NULL) { env =3D cpu->env_ptr; + cc =3D CPU_GET_CLASS(cpu); } #endif while (tb !=3D NULL) { @@ -1192,7 +1198,7 @@ static void tb_invalidate_phys_page(tb_page_addr_t = addr, =20 current_tb_modified =3D 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 */ --=20 1.8.1.4