target/ppc: Convert to CPUClass::tlb_fill

Cc: qemu-ppc@nongnu.org
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2019-04-02 17:03:41 +07:00
parent 35e911ae2f
commit 351bc97ecf
4 changed files with 26 additions and 22 deletions

View File

@ -1311,10 +1311,9 @@ void ppc_translate_init(void);
* is returned if the signal was handled by the virtual CPU. * is returned if the signal was handled by the virtual CPU.
*/ */
int cpu_ppc_signal_handler(int host_signum, void *pinfo, void *puc); int cpu_ppc_signal_handler(int host_signum, void *pinfo, void *puc);
#if defined(CONFIG_USER_ONLY) bool ppc_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
int ppc_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size, int rw, MMUAccessType access_type, int mmu_idx,
int mmu_idx); bool probe, uintptr_t retaddr);
#endif
#if !defined(CONFIG_USER_ONLY) #if !defined(CONFIG_USER_ONLY)
void ppc_store_sdr1(CPUPPCState *env, target_ulong value); void ppc_store_sdr1(CPUPPCState *env, target_ulong value);

View File

@ -3057,15 +3057,9 @@ void helper_check_tlb_flush_global(CPUPPCState *env)
/*****************************************************************************/ /*****************************************************************************/
/* bool ppc_cpu_tlb_fill(CPUState *cs, vaddr addr, int size,
* try to fill the TLB and return an exception if error. If retaddr is MMUAccessType access_type, int mmu_idx,
* NULL, it means that the function was called in C code (i.e. not bool probe, uintptr_t retaddr)
* from generated code or from helper.c)
*
* XXX: fix it to restore all registers
*/
void tlb_fill(CPUState *cs, target_ulong addr, int size,
MMUAccessType access_type, int mmu_idx, uintptr_t retaddr)
{ {
PowerPCCPU *cpu = POWERPC_CPU(cs); PowerPCCPU *cpu = POWERPC_CPU(cs);
PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs); PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs);
@ -3078,7 +3072,17 @@ void tlb_fill(CPUState *cs, target_ulong addr, int size,
ret = cpu_ppc_handle_mmu_fault(env, addr, access_type, mmu_idx); ret = cpu_ppc_handle_mmu_fault(env, addr, access_type, mmu_idx);
} }
if (unlikely(ret != 0)) { if (unlikely(ret != 0)) {
if (probe) {
return false;
}
raise_exception_err_ra(env, cs->exception_index, env->error_code, raise_exception_err_ra(env, cs->exception_index, env->error_code,
retaddr); retaddr);
} }
return true;
}
void tlb_fill(CPUState *cs, target_ulong addr, int size,
MMUAccessType access_type, int mmu_idx, uintptr_t retaddr)
{
ppc_cpu_tlb_fill(cs, addr, size, access_type, mmu_idx, false, retaddr);
} }

View File

@ -10592,9 +10592,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data)
cc->gdb_read_register = ppc_cpu_gdb_read_register; cc->gdb_read_register = ppc_cpu_gdb_read_register;
cc->gdb_write_register = ppc_cpu_gdb_write_register; cc->gdb_write_register = ppc_cpu_gdb_write_register;
cc->do_unaligned_access = ppc_cpu_do_unaligned_access; cc->do_unaligned_access = ppc_cpu_do_unaligned_access;
#ifdef CONFIG_USER_ONLY #ifndef 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->get_phys_page_debug = ppc_cpu_get_phys_page_debug;
cc->vmsd = &vmstate_ppc_cpu; cc->vmsd = &vmstate_ppc_cpu;
#endif #endif
@ -10624,6 +10622,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data)
#endif #endif
#ifdef CONFIG_TCG #ifdef CONFIG_TCG
cc->tcg_initialize = ppc_translate_init; cc->tcg_initialize = ppc_translate_init;
cc->tlb_fill = ppc_cpu_tlb_fill;
#endif #endif
cc->disas_set_info = ppc_disas_set_info; cc->disas_set_info = ppc_disas_set_info;

View File

@ -20,21 +20,24 @@
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "cpu.h" #include "cpu.h"
#include "exec/exec-all.h"
int ppc_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw,
int mmu_idx) bool ppc_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
MMUAccessType access_type, int mmu_idx,
bool probe, uintptr_t retaddr)
{ {
PowerPCCPU *cpu = POWERPC_CPU(cs); PowerPCCPU *cpu = POWERPC_CPU(cs);
CPUPPCState *env = &cpu->env; CPUPPCState *env = &cpu->env;
int exception, error_code; int exception, error_code;
if (rw == 2) { if (access_type == MMU_INST_FETCH) {
exception = POWERPC_EXCP_ISI; exception = POWERPC_EXCP_ISI;
error_code = 0x40000000; error_code = 0x40000000;
} else { } else {
exception = POWERPC_EXCP_DSI; exception = POWERPC_EXCP_DSI;
error_code = 0x40000000; error_code = 0x40000000;
if (rw) { if (access_type == MMU_DATA_STORE) {
error_code |= 0x02000000; error_code |= 0x02000000;
} }
env->spr[SPR_DAR] = address; env->spr[SPR_DAR] = address;
@ -42,6 +45,5 @@ int ppc_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw,
} }
cs->exception_index = exception; cs->exception_index = exception;
env->error_code = error_code; env->error_code = error_code;
cpu_loop_exit_restore(cs, retaddr);
return 1;
} }