From 7510454e3e74aafa2e6c50388bf24904644b6a96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 26 Aug 2013 03:01:33 +0200 Subject: cpu: Turn cpu_handle_mmu_fault() into a CPUClass hook MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Note that while such functions may exist both for *-user and softmmu, only *-user uses the CPUState hook, while softmmu reuses the prototype for calling it directly. Signed-off-by: Andreas Färber --- target-arm/cpu.c | 4 +++- target-arm/cpu.h | 5 ++--- target-arm/helper.c | 13 +++++++++---- target-arm/op_helper.c | 3 ++- 4 files changed, 16 insertions(+), 9 deletions(-) (limited to 'target-arm') diff --git a/target-arm/cpu.c b/target-arm/cpu.c index d792a912e7..be17d72537 100644 --- a/target-arm/cpu.c +++ b/target-arm/cpu.c @@ -1013,7 +1013,9 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) 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; -#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 diff --git a/target-arm/cpu.h b/target-arm/cpu.h index 00d91d1231..bf37cd60d0 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -339,9 +339,8 @@ static inline bool is_a64(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); /* SCTLR bit meanings. Several bits have been reused in newer * versions of the architecture; in that case we define constants diff --git a/target-arm/helper.c b/target-arm/helper.c index f64be6f36d..d3e68a6e24 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -2655,9 +2655,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; @@ -3623,9 +3626,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; diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c index 5851e041a0..ced6a7b83c 100644 --- a/target-arm/op_helper.c +++ b/target-arm/op_helper.c @@ -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 */ -- cgit v1.2.1