cpu: Move tlb_fill to tcg_ops

Backports e124536f37377cff5d68925d4976ad604d0ebf3a
This commit is contained in:
Eduardo Habkost 2021-03-04 17:00:52 -05:00 committed by Lioncash
parent 03cc62e39c
commit 76a10fa8e0
8 changed files with 23 additions and 20 deletions

View file

@ -500,7 +500,7 @@ static void tlb_fill(CPUState *cpu, target_ulong addr, int size,
* This is not a probe, so only valid return is success; failure * This is not a probe, so only valid return is success; failure
* should result in exception + longjmp to the cpu loop. * should result in exception + longjmp to the cpu loop.
*/ */
ok = cc->tlb_fill(cpu, addr, size, access_type, mmu_idx, false, retaddr); ok = cc->tcg_ops.tlb_fill(cpu, addr, size, access_type, mmu_idx, false, retaddr);
assert(ok); assert(ok);
} }
@ -738,7 +738,7 @@ static int probe_access_internal(CPUArchState *env, target_ulong addr,
CPUState *cs = env_cpu(env); CPUState *cs = env_cpu(env);
CPUClass *cc = CPU_GET_CLASS(cs->uc, cs); CPUClass *cc = CPU_GET_CLASS(cs->uc, cs);
if (!cc->tlb_fill(cs, addr, fault_size, access_type, if (!cc->tcg_ops.tlb_fill(cs, addr, fault_size, access_type,
mmu_idx, nonfault, retaddr)) { mmu_idx, nonfault, retaddr)) {
/* Non-faulting page table read failed. */ /* Non-faulting page table read failed. */
*phost = NULL; *phost = NULL;
@ -882,7 +882,7 @@ void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr addr,
CPUState *cs = env_cpu(env); CPUState *cs = env_cpu(env);
CPUClass *cc = CPU_GET_CLASS(cs->uc, cs); CPUClass *cc = CPU_GET_CLASS(cs->uc, cs);
if (!cc->tlb_fill(cs, addr, 0, access_type, mmu_idx, true, 0)) { if (!cc->tcg_ops.tlb_fill(cs, addr, 0, access_type, mmu_idx, true, 0)) {
/* Non-faulting page table read failed. */ /* Non-faulting page table read failed. */
return NULL; return NULL;
} }

View file

@ -104,6 +104,18 @@ typedef struct TcgCpuOperations {
void (*cpu_exec_exit)(CPUState *cpu); void (*cpu_exec_exit)(CPUState *cpu);
/** @cpu_exec_interrupt: Callback for processing interrupts in cpu_exec */ /** @cpu_exec_interrupt: Callback for processing interrupts in cpu_exec */
bool (*cpu_exec_interrupt)(CPUState *cpu, int interrupt_request); bool (*cpu_exec_interrupt)(CPUState *cpu, int interrupt_request);
/**
* @tlb_fill: Handle a softmmu tlb miss or user-only address fault
*
* For system mode, if the access is valid, call tlb_set_page
* and return true; if the access is invalid, and probe is
* true, return false; otherwise raise an exception and do
* not return. For user-only mode, always raise an exception
* and do not return.
*/
bool (*tlb_fill)(CPUState *cpu, vaddr address, int size,
MMUAccessType access_type, int mmu_idx,
bool probe, uintptr_t retaddr);
} TcgCpuOperations; } TcgCpuOperations;
@ -136,12 +148,6 @@ typedef struct TcgCpuOperations {
* If the target behaviour here is anything other than "set * If the target behaviour here is anything other than "set
* the PC register to the value passed in" then the target must * the PC register to the value passed in" then the target must
* also implement the synchronize_from_tb hook. * also implement the synchronize_from_tb hook.
* @tlb_fill: Callback for handling a softmmu tlb miss or user-only
* address fault. For system mode, if the access is valid, call
* tlb_set_page and return true; if the access is invalid, and
* probe is true, return false; otherwise raise an exception and
* do not return. For user-only mode, always raise an exception
* and do not return.
* @get_phys_page_debug: Callback for obtaining a physical address. * @get_phys_page_debug: Callback for obtaining a physical address.
* @get_phys_page_attrs_debug: Callback for obtaining a physical address and the * @get_phys_page_attrs_debug: Callback for obtaining a physical address and the
* associated memory transaction attributes to use for the access. * associated memory transaction attributes to use for the access.
@ -189,9 +195,6 @@ typedef struct CPUClass {
void (*get_memory_mapping)(CPUState *cpu, MemoryMappingList *list, void (*get_memory_mapping)(CPUState *cpu, MemoryMappingList *list,
Error **errp); Error **errp);
void (*set_pc)(CPUState *cpu, vaddr value); void (*set_pc)(CPUState *cpu, vaddr value);
bool (*tlb_fill)(CPUState *cpu, vaddr address, int size,
MMUAccessType access_type, int mmu_idx,
bool probe, uintptr_t retaddr);
hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr); hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr, hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
MemTxAttrs *attrs); MemTxAttrs *attrs);

View file

@ -2111,7 +2111,7 @@ static void arm_cpu_class_init(struct uc_struct *uc, ObjectClass *oc, void *data
cc->tcg_ops.initialize = arm_translate_init; cc->tcg_ops.initialize = arm_translate_init;
cc->tcg_ops.cpu_exec_interrupt = arm_cpu_exec_interrupt; cc->tcg_ops.cpu_exec_interrupt = arm_cpu_exec_interrupt;
cc->tcg_ops.synchronize_from_tb = arm_cpu_synchronize_from_tb; cc->tcg_ops.synchronize_from_tb = arm_cpu_synchronize_from_tb;
cc->tlb_fill = arm_cpu_tlb_fill; cc->tcg_ops.tlb_fill = arm_cpu_tlb_fill;
cc->debug_excp_handler = arm_debug_excp_handler; cc->debug_excp_handler = arm_debug_excp_handler;
cc->debug_check_watchpoint = arm_debug_check_watchpoint; cc->debug_check_watchpoint = arm_debug_check_watchpoint;
cc->do_unaligned_access = arm_cpu_do_unaligned_access; cc->do_unaligned_access = arm_cpu_do_unaligned_access;

View file

@ -5884,12 +5884,12 @@ static void x86_cpu_common_class_init(struct uc_struct *uc, ObjectClass *oc, voi
#endif #endif
#ifdef CONFIG_TCG #ifdef CONFIG_TCG
cc->tcg_ops.initialize = tcg_x86_init; cc->tcg_ops.initialize = tcg_x86_init;
cc->tcg_ops.tlb_fill = x86_cpu_tlb_fill;
cc->tcg_ops.synchronize_from_tb = x86_cpu_synchronize_from_tb; cc->tcg_ops.synchronize_from_tb = x86_cpu_synchronize_from_tb;
cc->tcg_ops.cpu_exec_enter = x86_cpu_exec_enter; cc->tcg_ops.cpu_exec_enter = x86_cpu_exec_enter;
cc->tcg_ops.cpu_exec_exit = x86_cpu_exec_exit; cc->tcg_ops.cpu_exec_exit = x86_cpu_exec_exit;
cc->tcg_ops.cpu_exec_interrupt = x86_cpu_exec_interrupt; cc->tcg_ops.cpu_exec_interrupt = x86_cpu_exec_interrupt;
cc->do_interrupt = x86_cpu_do_interrupt; cc->do_interrupt = x86_cpu_do_interrupt;
cc->tlb_fill = x86_cpu_tlb_fill;
#endif #endif
#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY) #if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
cc->debug_excp_handler = breakpoint_handler; cc->debug_excp_handler = breakpoint_handler;

View file

@ -268,7 +268,7 @@ static void m68k_cpu_class_init(struct uc_struct *uc, ObjectClass *c, void *data
cc->do_interrupt = m68k_cpu_do_interrupt; cc->do_interrupt = m68k_cpu_do_interrupt;
cc->tcg_ops.cpu_exec_interrupt = m68k_cpu_exec_interrupt; cc->tcg_ops.cpu_exec_interrupt = m68k_cpu_exec_interrupt;
cc->set_pc = m68k_cpu_set_pc; cc->set_pc = m68k_cpu_set_pc;
cc->tlb_fill = m68k_cpu_tlb_fill; cc->tcg_ops.tlb_fill = m68k_cpu_tlb_fill;
#if defined(CONFIG_SOFTMMU) #if defined(CONFIG_SOFTMMU)
cc->do_transaction_failed = m68k_cpu_transaction_failed; cc->do_transaction_failed = m68k_cpu_transaction_failed;
cc->get_phys_page_debug = m68k_cpu_get_phys_page_debug; cc->get_phys_page_debug = m68k_cpu_get_phys_page_debug;

View file

@ -184,7 +184,7 @@ static void mips_cpu_class_init(struct uc_struct *uc, ObjectClass *c, void *data
cc->tcg_ops.initialize = mips_tcg_init; cc->tcg_ops.initialize = mips_tcg_init;
cc->tcg_ops.cpu_exec_interrupt = mips_cpu_exec_interrupt; cc->tcg_ops.cpu_exec_interrupt = mips_cpu_exec_interrupt;
cc->tcg_ops.synchronize_from_tb = mips_cpu_synchronize_from_tb; cc->tcg_ops.synchronize_from_tb = mips_cpu_synchronize_from_tb;
cc->tlb_fill = mips_cpu_tlb_fill; cc->tcg_ops.tlb_fill = mips_cpu_tlb_fill;
#endif #endif
} }

View file

@ -358,7 +358,7 @@ static void riscv_cpu_class_init(struct uc_struct *uc, ObjectClass *oc, void *da
cc->class_by_name = riscv_cpu_class_by_name; cc->class_by_name = riscv_cpu_class_by_name;
cc->has_work = riscv_cpu_has_work; cc->has_work = riscv_cpu_has_work;
cc->do_interrupt = riscv_cpu_do_interrupt; cc->do_interrupt = riscv_cpu_do_interrupt;
cc->cpu_exec_interrupt = riscv_cpu_exec_interrupt; cc->tcg_ops.cpu_exec_interrupt = riscv_cpu_exec_interrupt;
//cc->dump_state = riscv_cpu_dump_state; //cc->dump_state = riscv_cpu_dump_state;
cc->set_pc = riscv_cpu_set_pc; cc->set_pc = riscv_cpu_set_pc;
cc->tcg_ops.synchronize_from_tb = riscv_cpu_synchronize_from_tb; cc->tcg_ops.synchronize_from_tb = riscv_cpu_synchronize_from_tb;
@ -373,7 +373,7 @@ static void riscv_cpu_class_init(struct uc_struct *uc, ObjectClass *oc, void *da
cc->get_phys_page_debug = riscv_cpu_get_phys_page_debug; cc->get_phys_page_debug = riscv_cpu_get_phys_page_debug;
#endif #endif
cc->tcg_ops.initialize = riscv_translate_init; cc->tcg_ops.initialize = riscv_translate_init;
cc->tlb_fill = riscv_cpu_tlb_fill; cc->tcg_ops.tlb_fill = riscv_cpu_tlb_fill;
/* For now, mark unmigratable: */ /* For now, mark unmigratable: */
//cc->vmsd = &vmstate_riscv_cpu; //cc->vmsd = &vmstate_riscv_cpu;
} }

View file

@ -848,7 +848,7 @@ static void sparc_cpu_class_init(struct uc_struct *uc, ObjectClass *oc, void *da
#endif #endif
cc->set_pc = sparc_cpu_set_pc; cc->set_pc = sparc_cpu_set_pc;
cc->tcg_ops.synchronize_from_tb = sparc_cpu_synchronize_from_tb; cc->tcg_ops.synchronize_from_tb = sparc_cpu_synchronize_from_tb;
cc->tlb_fill = sparc_cpu_tlb_fill; cc->tcg_ops.tlb_fill = sparc_cpu_tlb_fill;
#ifndef CONFIG_USER_ONLY #ifndef CONFIG_USER_ONLY
cc->do_transaction_failed = sparc_cpu_do_transaction_failed; cc->do_transaction_failed = sparc_cpu_do_transaction_failed;
cc->do_unaligned_access = sparc_cpu_do_unaligned_access; cc->do_unaligned_access = sparc_cpu_do_unaligned_access;