translate-all: Change cpu_restore_state() argument to CPUState

This lets us drop some local variables in tlb_fill() functions.

Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
Andreas Färber 2013-09-01 16:51:34 +02:00
parent 5638d180d6
commit 3f38f309b2
24 changed files with 46 additions and 63 deletions

View file

@ -406,7 +406,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
} }
if (!kvm_enabled()) { if (!kvm_enabled()) {
cpu_restore_state(env, cs->mem_io_pc); cpu_restore_state(cs, cs->mem_io_pc);
cpu_get_tb_cpu_state(env, &current_pc, &current_cs_base, cpu_get_tb_cpu_state(env, &current_pc, &current_cs_base,
&current_flags); &current_flags);
} }

View file

@ -80,7 +80,7 @@ void restore_state_to_opc(CPUArchState *env, struct TranslationBlock *tb,
void cpu_gen_init(void); void cpu_gen_init(void);
int cpu_gen_code(CPUArchState *env, struct TranslationBlock *tb, int cpu_gen_code(CPUArchState *env, struct TranslationBlock *tb,
int *gen_code_size_ptr); int *gen_code_size_ptr);
bool cpu_restore_state(CPUArchState *env, uintptr_t searched_pc); bool cpu_restore_state(CPUState *cpu, uintptr_t searched_pc);
void page_size_init(void); void page_size_init(void);
void QEMU_NORETURN cpu_resume_from_signal(CPUArchState *env1, void *puc); void QEMU_NORETURN cpu_resume_from_signal(CPUArchState *env1, void *puc);

View file

@ -526,7 +526,7 @@ void QEMU_NORETURN dynamic_excp(CPUAlphaState *env, uintptr_t retaddr,
cs->exception_index = excp; cs->exception_index = excp;
env->error_code = error; env->error_code = error;
if (retaddr) { if (retaddr) {
cpu_restore_state(env, retaddr); cpu_restore_state(cs, retaddr);
} }
cpu_loop_exit(cs); cpu_loop_exit(cs);
} }

View file

@ -105,7 +105,7 @@ static void do_unaligned_access(CPUAlphaState *env, target_ulong addr,
uint32_t insn; uint32_t insn;
if (retaddr) { if (retaddr) {
cpu_restore_state(env, retaddr); cpu_restore_state(cs, retaddr);
} }
pc = env->pc; pc = env->pc;
@ -159,11 +159,8 @@ void tlb_fill(CPUState *cs, target_ulong addr, int is_write,
ret = alpha_cpu_handle_mmu_fault(cs, addr, is_write, mmu_idx); ret = alpha_cpu_handle_mmu_fault(cs, addr, is_write, mmu_idx);
if (unlikely(ret != 0)) { if (unlikely(ret != 0)) {
AlphaCPU *cpu = ALPHA_CPU(cs);
CPUAlphaState *env = &cpu->env;
if (retaddr) { if (retaddr) {
cpu_restore_state(env, retaddr); cpu_restore_state(cs, retaddr);
} }
/* Exception index and error code are already set */ /* Exception index and error code are already set */
cpu_loop_exit(cs); cpu_loop_exit(cs);

View file

@ -87,7 +87,7 @@ void tlb_fill(CPUState *cs, target_ulong addr, int is_write, int mmu_idx,
if (retaddr) { if (retaddr) {
/* now we have a real cpu fault */ /* now we have a real cpu fault */
cpu_restore_state(env, retaddr); cpu_restore_state(cs, retaddr);
} }
raise_exception(env, cs->exception_index); raise_exception(env, cs->exception_index);
} }

View file

@ -67,7 +67,7 @@ void tlb_fill(CPUState *cs, target_ulong addr, int is_write, int mmu_idx,
if (unlikely(ret)) { if (unlikely(ret)) {
if (retaddr) { if (retaddr) {
/* now we have a real cpu fault */ /* now we have a real cpu fault */
if (cpu_restore_state(env, retaddr)) { if (cpu_restore_state(cs, retaddr)) {
/* Evaluate flags after retranslation. */ /* Evaluate flags after retranslation. */
helper_top_evaluate_flags(env); helper_top_evaluate_flags(env);
} }

View file

@ -1263,7 +1263,7 @@ void cpu_report_tpr_access(CPUX86State *env, TPRAccess access)
cpu_interrupt(cs, CPU_INTERRUPT_TPR); cpu_interrupt(cs, CPU_INTERRUPT_TPR);
} else { } else {
cpu_restore_state(env, cs->mem_io_pc); cpu_restore_state(cs, cs->mem_io_pc);
apic_handle_tpr_access_report(cpu->apic_state, env->eip, access); apic_handle_tpr_access_report(cpu->apic_state, env->eip, access);
} }

View file

@ -145,7 +145,7 @@ void tlb_fill(CPUState *cs, target_ulong addr, int is_write, int mmu_idx,
if (retaddr) { if (retaddr) {
/* now we have a real cpu fault */ /* now we have a real cpu fault */
cpu_restore_state(env, retaddr); cpu_restore_state(cs, retaddr);
} }
raise_exception_err(env, cs->exception_index, env->error_code); raise_exception_err(env, cs->exception_index, env->error_code);
} }

View file

@ -160,12 +160,9 @@ void tlb_fill(CPUState *cs, target_ulong addr, int is_write, int mmu_idx,
ret = lm32_cpu_handle_mmu_fault(cs, addr, is_write, mmu_idx); ret = lm32_cpu_handle_mmu_fault(cs, addr, is_write, mmu_idx);
if (unlikely(ret)) { if (unlikely(ret)) {
LM32CPU *cpu = LM32_CPU(cs);
CPULM32State *env = &cpu->env;
if (retaddr) { if (retaddr) {
/* now we have a real cpu fault */ /* now we have a real cpu fault */
cpu_restore_state(env, retaddr); cpu_restore_state(cs, retaddr);
} }
cpu_loop_exit(cs); cpu_loop_exit(cs);
} }

View file

@ -60,12 +60,9 @@ void tlb_fill(CPUState *cs, target_ulong addr, int is_write, int mmu_idx,
ret = m68k_cpu_handle_mmu_fault(cs, addr, is_write, mmu_idx); ret = m68k_cpu_handle_mmu_fault(cs, addr, is_write, mmu_idx);
if (unlikely(ret)) { if (unlikely(ret)) {
M68kCPU *cpu = M68K_CPU(cs);
CPUM68KState *env = &cpu->env;
if (retaddr) { if (retaddr) {
/* now we have a real cpu fault */ /* now we have a real cpu fault */
cpu_restore_state(env, retaddr); cpu_restore_state(cs, retaddr);
} }
cpu_loop_exit(cs); cpu_loop_exit(cs);
} }

View file

@ -49,12 +49,9 @@ void tlb_fill(CPUState *cs, target_ulong addr, int is_write, int mmu_idx,
ret = mb_cpu_handle_mmu_fault(cs, addr, is_write, mmu_idx); ret = mb_cpu_handle_mmu_fault(cs, addr, is_write, mmu_idx);
if (unlikely(ret)) { if (unlikely(ret)) {
MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs);
CPUMBState *env = &cpu->env;
if (retaddr) { if (retaddr) {
/* now we have a real cpu fault */ /* now we have a real cpu fault */
cpu_restore_state(env, retaddr); cpu_restore_state(cs, retaddr);
} }
cpu_loop_exit(cs); cpu_loop_exit(cs);
} }

View file

@ -48,7 +48,7 @@ static inline void QEMU_NORETURN do_raise_exception_err(CPUMIPSState *env,
if (pc) { if (pc) {
/* now we have a real cpu fault */ /* now we have a real cpu fault */
cpu_restore_state(env, pc); cpu_restore_state(cs, pc);
} }
cpu_loop_exit(cs); cpu_loop_exit(cs);

View file

@ -49,14 +49,12 @@
void tlb_fill(CPUState *cs, target_ulong addr, int is_write, int mmu_idx, void tlb_fill(CPUState *cs, target_ulong addr, int is_write, int mmu_idx,
uintptr_t retaddr) uintptr_t retaddr)
{ {
MoxieCPU *cpu = MOXIE_CPU(cs);
CPUMoxieState *env = &cpu->env;
int ret; int ret;
ret = moxie_cpu_handle_mmu_fault(cs, addr, is_write, mmu_idx); ret = moxie_cpu_handle_mmu_fault(cs, addr, is_write, mmu_idx);
if (unlikely(ret)) { if (unlikely(ret)) {
if (retaddr) { if (retaddr) {
cpu_restore_state(env, retaddr); cpu_restore_state(cs, retaddr);
} }
} }
cpu_loop_exit(cs); cpu_loop_exit(cs);
@ -70,7 +68,7 @@ void helper_raise_exception(CPUMoxieState *env, int ex)
/* Stash the exception type. */ /* Stash the exception type. */
env->sregs[2] = ex; env->sregs[2] = ex;
/* Stash the address where the exception occurred. */ /* Stash the address where the exception occurred. */
cpu_restore_state(env, GETPC()); cpu_restore_state(cs, GETPC());
env->sregs[5] = env->pc; env->sregs[5] = env->pc;
/* Jump the the exception handline routine. */ /* Jump the the exception handline routine. */
env->pc = env->sregs[1]; env->pc = env->sregs[1];

View file

@ -44,12 +44,9 @@ void tlb_fill(CPUState *cs, target_ulong addr, int is_write,
ret = openrisc_cpu_handle_mmu_fault(cs, addr, is_write, mmu_idx); ret = openrisc_cpu_handle_mmu_fault(cs, addr, is_write, mmu_idx);
if (ret) { if (ret) {
OpenRISCCPU *cpu = OPENRISC_CPU(cs);
CPUOpenRISCState *env = &cpu->env;
if (retaddr) { if (retaddr) {
/* now we have a real cpu fault. */ /* now we have a real cpu fault. */
cpu_restore_state(env, retaddr); cpu_restore_state(cs, retaddr);
} }
/* Raise Exception. */ /* Raise Exception. */
cpu_loop_exit(cs); cpu_loop_exit(cs);

View file

@ -2909,7 +2909,7 @@ void tlb_fill(CPUState *cs, target_ulong addr, int is_write, int mmu_idx,
if (unlikely(ret != 0)) { if (unlikely(ret != 0)) {
if (likely(retaddr)) { if (likely(retaddr)) {
/* now we have a real cpu fault */ /* now we have a real cpu fault */
cpu_restore_state(env, retaddr); cpu_restore_state(cs, retaddr);
} }
helper_raise_exception_err(env, cs->exception_index, env->error_code); helper_raise_exception_err(env, cs->exception_index, env->error_code);
} }

View file

@ -51,12 +51,9 @@ void tlb_fill(CPUState *cs, target_ulong addr, int is_write, int mmu_idx,
ret = s390_cpu_handle_mmu_fault(cs, addr, is_write, mmu_idx); ret = s390_cpu_handle_mmu_fault(cs, addr, is_write, mmu_idx);
if (unlikely(ret != 0)) { if (unlikely(ret != 0)) {
S390CPU *cpu = S390_CPU(cs);
CPUS390XState *env = &cpu->env;
if (likely(retaddr)) { if (likely(retaddr)) {
/* now we have a real cpu fault */ /* now we have a real cpu fault */
cpu_restore_state(env, retaddr); cpu_restore_state(cs, retaddr);
} }
cpu_loop_exit(cs); cpu_loop_exit(cs);
} }

View file

@ -54,7 +54,7 @@ void QEMU_NORETURN runtime_exception(CPUS390XState *env, int excp,
env->int_pgm_code = excp; env->int_pgm_code = excp;
/* Use the (ultimate) callers address to find the insn that trapped. */ /* Use the (ultimate) callers address to find the insn that trapped. */
cpu_restore_state(env, retaddr); cpu_restore_state(cs, retaddr);
/* Advance past the insn. */ /* Advance past the insn. */
t = cpu_ldub_code(env, env->psw.addr); t = cpu_ldub_code(env, env->psw.addr);

View file

@ -46,11 +46,8 @@ void tlb_fill(CPUState *cs, target_ulong addr, int is_write, int mmu_idx,
ret = superh_cpu_handle_mmu_fault(cs, addr, is_write, mmu_idx); ret = superh_cpu_handle_mmu_fault(cs, addr, is_write, mmu_idx);
if (ret) { if (ret) {
/* now we have a real cpu fault */ /* now we have a real cpu fault */
SuperHCPU *cpu = SUPERH_CPU(cs);
CPUSH4State *env = &cpu->env;
if (retaddr) { if (retaddr) {
cpu_restore_state(env, retaddr); cpu_restore_state(cs, retaddr);
} }
cpu_loop_exit(cs); cpu_loop_exit(cs);
} }
@ -75,7 +72,7 @@ static inline void QEMU_NORETURN raise_exception(CPUSH4State *env, int index,
cs->exception_index = index; cs->exception_index = index;
if (retaddr) { if (retaddr) {
cpu_restore_state(env, retaddr); cpu_restore_state(cs, retaddr);
} }
cpu_loop_exit(cs); cpu_loop_exit(cs);
} }

View file

@ -71,6 +71,7 @@ void helper_tick_set_limit(void *opaque, uint64_t limit)
static target_ulong helper_udiv_common(CPUSPARCState *env, target_ulong a, static target_ulong helper_udiv_common(CPUSPARCState *env, target_ulong a,
target_ulong b, int cc) target_ulong b, int cc)
{ {
SPARCCPU *cpu = sparc_env_get_cpu(env);
int overflow = 0; int overflow = 0;
uint64_t x0; uint64_t x0;
uint32_t x1; uint32_t x1;
@ -79,7 +80,7 @@ static target_ulong helper_udiv_common(CPUSPARCState *env, target_ulong a,
x1 = (b & 0xffffffff); x1 = (b & 0xffffffff);
if (x1 == 0) { if (x1 == 0) {
cpu_restore_state(env, GETPC()); cpu_restore_state(CPU(cpu), GETPC());
helper_raise_exception(env, TT_DIV_ZERO); helper_raise_exception(env, TT_DIV_ZERO);
} }
@ -110,6 +111,7 @@ target_ulong helper_udiv_cc(CPUSPARCState *env, target_ulong a, target_ulong b)
static target_ulong helper_sdiv_common(CPUSPARCState *env, target_ulong a, static target_ulong helper_sdiv_common(CPUSPARCState *env, target_ulong a,
target_ulong b, int cc) target_ulong b, int cc)
{ {
SPARCCPU *cpu = sparc_env_get_cpu(env);
int overflow = 0; int overflow = 0;
int64_t x0; int64_t x0;
int32_t x1; int32_t x1;
@ -118,7 +120,7 @@ static target_ulong helper_sdiv_common(CPUSPARCState *env, target_ulong a,
x1 = (b & 0xffffffff); x1 = (b & 0xffffffff);
if (x1 == 0) { if (x1 == 0) {
cpu_restore_state(env, GETPC()); cpu_restore_state(CPU(cpu), GETPC());
helper_raise_exception(env, TT_DIV_ZERO); helper_raise_exception(env, TT_DIV_ZERO);
} }
@ -151,7 +153,9 @@ int64_t helper_sdivx(CPUSPARCState *env, int64_t a, int64_t b)
{ {
if (b == 0) { if (b == 0) {
/* Raise divide by zero trap. */ /* Raise divide by zero trap. */
cpu_restore_state(env, GETPC()); SPARCCPU *cpu = sparc_env_get_cpu(env);
cpu_restore_state(CPU(cpu), GETPC());
helper_raise_exception(env, TT_DIV_ZERO); helper_raise_exception(env, TT_DIV_ZERO);
} else if (b == -1) { } else if (b == -1) {
/* Avoid overflow trap with i386 divide insn. */ /* Avoid overflow trap with i386 divide insn. */
@ -165,7 +169,9 @@ uint64_t helper_udivx(CPUSPARCState *env, uint64_t a, uint64_t b)
{ {
if (b == 0) { if (b == 0) {
/* Raise divide by zero trap. */ /* Raise divide by zero trap. */
cpu_restore_state(env, GETPC()); SPARCCPU *cpu = sparc_env_get_cpu(env);
cpu_restore_state(CPU(cpu), GETPC());
helper_raise_exception(env, TT_DIV_ZERO); helper_raise_exception(env, TT_DIV_ZERO);
} }
return a / b; return a / b;
@ -175,6 +181,7 @@ uint64_t helper_udivx(CPUSPARCState *env, uint64_t a, uint64_t b)
target_ulong helper_taddcctv(CPUSPARCState *env, target_ulong src1, target_ulong helper_taddcctv(CPUSPARCState *env, target_ulong src1,
target_ulong src2) target_ulong src2)
{ {
SPARCCPU *cpu = sparc_env_get_cpu(env);
target_ulong dst; target_ulong dst;
/* Tag overflow occurs if either input has bits 0 or 1 set. */ /* Tag overflow occurs if either input has bits 0 or 1 set. */
@ -197,13 +204,14 @@ target_ulong helper_taddcctv(CPUSPARCState *env, target_ulong src1,
return dst; return dst;
tag_overflow: tag_overflow:
cpu_restore_state(env, GETPC()); cpu_restore_state(CPU(cpu), GETPC());
helper_raise_exception(env, TT_TOVF); helper_raise_exception(env, TT_TOVF);
} }
target_ulong helper_tsubcctv(CPUSPARCState *env, target_ulong src1, target_ulong helper_tsubcctv(CPUSPARCState *env, target_ulong src1,
target_ulong src2) target_ulong src2)
{ {
SPARCCPU *cpu = sparc_env_get_cpu(env);
target_ulong dst; target_ulong dst;
/* Tag overflow occurs if either input has bits 0 or 1 set. */ /* Tag overflow occurs if either input has bits 0 or 1 set. */
@ -226,7 +234,7 @@ target_ulong helper_tsubcctv(CPUSPARCState *env, target_ulong src1,
return dst; return dst;
tag_overflow: tag_overflow:
cpu_restore_state(env, GETPC()); cpu_restore_state(CPU(cpu), GETPC());
helper_raise_exception(env, TT_TOVF); helper_raise_exception(env, TT_TOVF);
} }

View file

@ -2424,12 +2424,13 @@ static void QEMU_NORETURN do_unaligned_access(CPUSPARCState *env,
target_ulong addr, int is_write, target_ulong addr, int is_write,
int is_user, uintptr_t retaddr) int is_user, uintptr_t retaddr)
{ {
SPARCCPU *cpu = sparc_env_get_cpu(env);
#ifdef DEBUG_UNALIGNED #ifdef DEBUG_UNALIGNED
printf("Unaligned access to 0x" TARGET_FMT_lx " from 0x" TARGET_FMT_lx printf("Unaligned access to 0x" TARGET_FMT_lx " from 0x" TARGET_FMT_lx
"\n", addr, env->pc); "\n", addr, env->pc);
#endif #endif
if (retaddr) { if (retaddr) {
cpu_restore_state(env, retaddr); cpu_restore_state(CPU(cpu), retaddr);
} }
helper_raise_exception(env, TT_UNALIGNED); helper_raise_exception(env, TT_UNALIGNED);
} }
@ -2445,11 +2446,8 @@ void tlb_fill(CPUState *cs, target_ulong addr, int is_write, int mmu_idx,
ret = sparc_cpu_handle_mmu_fault(cs, addr, is_write, mmu_idx); ret = sparc_cpu_handle_mmu_fault(cs, addr, is_write, mmu_idx);
if (ret) { if (ret) {
SPARCCPU *cpu = SPARC_CPU(cs);
CPUSPARCState *env = &cpu->env;
if (retaddr) { if (retaddr) {
cpu_restore_state(env, retaddr); cpu_restore_state(cs, retaddr);
} }
cpu_loop_exit(cs); cpu_loop_exit(cs);
} }

View file

@ -264,12 +264,9 @@ void tlb_fill(CPUState *cs, target_ulong addr, int is_write,
ret = uc32_cpu_handle_mmu_fault(cs, addr, is_write, mmu_idx); ret = uc32_cpu_handle_mmu_fault(cs, addr, is_write, mmu_idx);
if (unlikely(ret)) { if (unlikely(ret)) {
UniCore32CPU *cpu = UNICORE32_CPU(cs);
CPUUniCore32State *env = &cpu->env;
if (retaddr) { if (retaddr) {
/* now we have a real cpu fault */ /* now we have a real cpu fault */
cpu_restore_state(env, retaddr); cpu_restore_state(cs, retaddr);
} }
cpu_loop_exit(cs); cpu_loop_exit(cs);
} }

View file

@ -52,9 +52,11 @@ static void do_unaligned_access(CPUXtensaState *env,
static void do_unaligned_access(CPUXtensaState *env, static void do_unaligned_access(CPUXtensaState *env,
target_ulong addr, int is_write, int is_user, uintptr_t retaddr) target_ulong addr, int is_write, int is_user, uintptr_t retaddr)
{ {
XtensaCPU *cpu = xtensa_env_get_cpu(env);
if (xtensa_option_enabled(env->config, XTENSA_OPTION_UNALIGNED_EXCEPTION) && if (xtensa_option_enabled(env->config, XTENSA_OPTION_UNALIGNED_EXCEPTION) &&
!xtensa_option_enabled(env->config, XTENSA_OPTION_HW_ALIGNMENT)) { !xtensa_option_enabled(env->config, XTENSA_OPTION_HW_ALIGNMENT)) {
cpu_restore_state(env, retaddr); cpu_restore_state(CPU(cpu), retaddr);
HELPER(exception_cause_vaddr)(env, HELPER(exception_cause_vaddr)(env,
env->pc, LOAD_STORE_ALIGNMENT_CAUSE, addr); env->pc, LOAD_STORE_ALIGNMENT_CAUSE, addr);
} }
@ -80,7 +82,7 @@ void tlb_fill(CPUState *cs,
paddr & TARGET_PAGE_MASK, paddr & TARGET_PAGE_MASK,
access, mmu_idx, page_size); access, mmu_idx, page_size);
} else { } else {
cpu_restore_state(env, retaddr); cpu_restore_state(cs, retaddr);
HELPER(exception_cause_vaddr)(env, env->pc, ret, vaddr); HELPER(exception_cause_vaddr)(env, env->pc, ret, vaddr);
} }
} }

View file

@ -253,8 +253,9 @@ static int cpu_restore_state_from_tb(TranslationBlock *tb, CPUArchState *env,
return 0; return 0;
} }
bool cpu_restore_state(CPUArchState *env, uintptr_t retaddr) bool cpu_restore_state(CPUState *cpu, uintptr_t retaddr)
{ {
CPUArchState *env = cpu->env_ptr;
TranslationBlock *tb; TranslationBlock *tb;
tb = tb_find_pc(retaddr); tb = tb_find_pc(retaddr);

View file

@ -117,7 +117,7 @@ static inline int handle_cpu_signal(uintptr_t pc, unsigned long address,
return 1; /* the MMU fault was handled without causing real CPU fault */ return 1; /* the MMU fault was handled without causing real CPU fault */
} }
/* now we have a real cpu fault */ /* now we have a real cpu fault */
cpu_restore_state(env, pc); cpu_restore_state(cpu, pc);
/* we restore the process signal mask as the sigreturn should /* we restore the process signal mask as the sigreturn should
do it (XXX: use sigsetjmp) */ do it (XXX: use sigsetjmp) */