tcg: Add CPUClass::tlb_fill
v3 cover tcg: Add CPUClass::tlb_fill
Changes from v2:
* Re-remove the cpu_dump_state from nios-linux-user.
* Assert !probe for sparc32, undoing other mmureg changes.
* Better describe the SVE bug fixed by the final patch.
Patches without review:
0014-target-nios2-Convert-to-CPUClass-tlb_fill.patch 0020-target-sparc-Convert-to-CPUClass-tlb_fill.patch
Changes from v1:
* Do not unify user-only and system tlb_fill functions
(alpha, microblaze, nios2, s390x, sparc, xtensa).
* Split the mips patch into multiple.
* Other random changes per review.
Blurb from v1:
There is currently a lot of confusion between foo_cpu_handle_mmu_fault and tlb_fill.
In particular, foo_cpu_handle_mmu_fault was only defined for user-only, and its only valid action was to set up the cpu for cpu_loop_exit so that we can deliver a SIGSEGV to the guest. And yet, we had code that tried to return from the host SIGSEGV handler to retry the instruction.
We had, for some targets, a definition of foo_cpu_handle_mmu_fault for softmmu. Sometimes this was called from tlb_fill, sometimes not.
Finally, we have a use case for SVE that wants a non-faulting tlb_fill, so while we're changing the interface, let's go ahead and include that.
r~
Richard Henderson (27):
tcg: Add CPUClass::tlb_fill
target/alpha: Convert to CPUClass::tlb_fill
target/arm: Convert to CPUClass::tlb_fill
target/cris: Convert to CPUClass::tlb_fill
target/hppa: Convert to CPUClass::tlb_fill
target/i386: Convert to CPUClass::tlb_fill
target/lm32: Convert to CPUClass::tlb_fill
target/m68k: Convert to CPUClass::tlb_fill target/microblaze: Convert to CPUClass::tlb_fill target/mips: Pass a valid error to raise_mmu_exception for user-only target/mips: Tidy control flow in mips_cpu_handle_mmu_fault target/mips: Convert to CPUClass::tlb_fill
target/moxie: Convert to CPUClass::tlb_fill
target/nios2: Convert to CPUClass::tlb_fill target/openrisc: Convert to CPUClass::tlb_fill target/ppc: Convert to CPUClass::tlb_fill
target/riscv: Convert to CPUClass::tlb_fill
target/s390x: Convert to CPUClass::tlb_fill
target/sh4: Convert to CPUClass::tlb_fill
target/sparc: Convert to CPUClass::tlb_fill target/tilegx: Convert to CPUClass::tlb_fill target/tricore: Convert to CPUClass::tlb_fill target/unicore32: Convert to CPUClass::tlb_fill target/xtensa: Convert to CPUClass::tlb_fill
tcg: Use CPUClass::tlb_fill in cputlb.c
tcg: Remove CPUClass::handle_mmu_fault
tcg: Use tlb_fill probe from tlb_vaddr_to_host
include/exec/cpu_ldst.h | 50 ++------- include/exec/exec-all.h | 9 -- include/qom/cpu.h | 12 +- target/alpha/cpu.h | 5 +- target/arm/internals.h | 10 +- target/cris/cpu.h | 5 +- target/hppa/cpu.h | 8 +- target/i386/cpu.h | 5 +- target/lm32/cpu.h | 5 +- target/m68k/cpu.h | 5 +- target/microblaze/cpu.h | 5 +- target/mips/internal.h | 5 +- target/moxie/cpu.h | 5 +- target/nios2/cpu.h | 5 +- target/openrisc/cpu.h | 5 +- target/ppc/cpu.h | 7 +- target/riscv/cpu.h | 5 +- target/s390x/internal.h | 5 +- target/sh4/cpu.h | 5 +- target/sparc/cpu.h | 5 +- target/tricore/cpu.h | 6 +- target/unicore32/cpu.h | 5 +- target/xtensa/cpu.h | 5 +- accel/tcg/cputlb.c | 88 +++++++++++++-- accel/tcg/user-exec.c | 36 ++---- target/alpha/cpu.c | 5 +- target/alpha/helper.c | 24 ++-- target/alpha/mem_helper.c | 16 --- target/arm/cpu.c | 22 +--- target/arm/helper.c | 90 ++++++++------- target/arm/op_helper.c | 29 +---- target/arm/sve_helper.c | 6 +- target/cris/cpu.c | 5 +- target/cris/helper.c | 61 ++++++----- target/cris/op_helper.c | 28 ----- target/hppa/cpu.c | 5 +- target/hppa/mem_helper.c | 16 ++- target/i386/cpu.c | 5 +- target/i386/excp_helper.c | 53 +++++---- target/i386/mem_helper.c | 21 ---- target/lm32/cpu.c | 5 +- target/lm32/helper.c | 8 +- target/lm32/op_helper.c | 16 --- target/m68k/cpu.c | 2 +- target/m68k/helper.c | 89 ++++++++------- target/m68k/op_helper.c | 15 --- target/microblaze/cpu.c | 5 +- target/microblaze/helper.c | 101 ++++++++--------- target/microblaze/op_helper.c | 19 ---- target/mips/cpu.c | 5 +- target/mips/helper.c | 81 ++++++-------- target/mips/op_helper.c | 15 --- target/moxie/cpu.c | 5 +- target/moxie/helper.c | 65 +++-------- target/nios2/cpu.c | 5 +- target/nios2/helper.c | 170 ++++++++++++++-------------- target/nios2/mmu.c | 12 -- target/openrisc/cpu.c | 5 +- target/openrisc/mmu.c | 69 ++++++------ target/ppc/mmu_helper.c | 16 ++- target/ppc/translate_init.inc.c | 5 +- target/ppc/user_only_helper.c | 14 ++- target/riscv/cpu.c | 5 +- target/riscv/cpu_helper.c | 50 ++++----- target/s390x/cpu.c | 5 +- target/s390x/excp_helper.c | 67 +++++++---- target/s390x/mem_helper.c | 16 --- target/sh4/cpu.c | 5 +- target/sh4/helper.c | 189 +++++++++++++++----------------- target/sh4/op_helper.c | 12 -- target/sparc/cpu.c | 5 +- target/sparc/ldst_helper.c | 15 --- target/sparc/mmu_helper.c | 58 ++++++---- target/tilegx/cpu.c | 10 +- target/tricore/cpu.c | 1 + target/tricore/helper.c | 23 ++-- target/tricore/op_helper.c | 26 ----- target/unicore32/cpu.c | 5 +- target/unicore32/helper.c | 23 ---- target/unicore32/op_helper.c | 14 --- target/unicore32/softmmu.c | 13 ++- target/xtensa/cpu.c | 5 +- target/xtensa/helper.c | 33 +++--- 83 files changed, 868 insertions(+), 1131 deletions(-)
Signature · 1 line
2.17.1
PATCH v3 1/27 tcg: Add CPUClass::tlb_fill
This hook will replace the (user-only mode specific) handle_mmu_fault hook, and the (system mode specific) tlb_fill function.
The handle_mmu_fault hook was written as if there was a valid way to recover from an mmu fault, and had 3 possible return states. In reality, the only valid action is to raise an exception, return to the main loop, and deliver the SIGSEGV to the guest.
Note that all of the current implementations of handle_mmu_fault for guests which support linux-user do in fact only ever return 1, which is the signal to return to the main loop.
Using the hook for system mode requires that all targets be converted, so for now the hook is (optionally) used only from user-only mode.
--- include/qom/cpu.h | 9 +++++++++ accel/tcg/user-exec.c | 39 ++++++++++++++------------------------- 2 files changed, 23 insertions(+), 25 deletions(-)
include/qom/cpu.h +9 -0
@@ -118,6 +118,12 @@ struct TranslationBlock;* will need to do more. If this hook is not implemented then the * default is to call @set_pc(tb->pc). * @handle_mmu_fault: Callback for handling an MMU fault. +* @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_attrs_debug: Callback for obtaining a physical address and the * associated memory transaction attributes to use for the access.
@@ -191,6 +197,9 @@ typedef struct CPUClass {void (*synchronize_from_tb)(CPUState *cpu,struct TranslationBlock *tb);int (*handle_mmu_fault)(CPUState *cpu,vaddr address,int size,int rw,int mmu_index); +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_attrs_debug)(CPUState *cpu,vaddr addr,MemTxAttrs *attrs);
accel/tcg/user-exec.c +14 -25
@@ -65,6 +65,7 @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info,CPUClass *cc;int ret;unsigned long address = (unsigned long )info->si_addr; +MMUAccessType access_type;/* We must handle PC addresses from two different sources: * a call return address and a signal frame address.
@@ -147,35 +148,23 @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info,are still valid segv ones */ address =h2g_nocheck (address); - cc =CPU_GET_CLASS (cpu); -/* see if it is an MMU fault */ -g_assert (cc->handle_mmu_fault); - ret = cc->handle_mmu_fault (cpu, address,0 , is_write,MMU_USER_IDX ); - -if (ret ==0 ) { -/* The MMU fault was handled without causing real CPU fault. -* Retain helper_retaddr for a possible second fault. -*/ -return 1 ; - } - -/* All other paths lead to cpu_exit; clear helper_retaddr -* for next execution. +/* +* There is no way the target can handle this other than raising +* an exception. Undo signal and retaddr state prior to longjmp. */ +sigprocmask (SIG_SETMASK , old_set,NULL ); helper_retaddr =0 ; -if (ret <0 ) { -return 0 ;/* not an MMU fault */ + cc =CPU_GET_CLASS (cpu); +if (cc->tlb_fill) { + access_type = is_write ?MMU_DATA_STORE :MMU_DATA_LOAD ; + cc->tlb_fill (cpu, address,0 , access_type,MMU_USER_IDX , false, pc); +g_assert_not_reached (); + }else { + ret = cc->handle_mmu_fault (cpu, address,0 , is_write,MMU_USER_IDX ); +g_assert (ret >0 ); +cpu_loop_exit_restore (cpu, pc); } - -/* Now we have a real cpu fault. */ -cpu_restore_state (cpu, pc, true); - -sigprocmask (SIG_SETMASK , old_set,NULL ); -cpu_loop_exit (cpu); - -/* never comes here */ -return 1 ; }#if defined(__i386__)
Signature · 1 line
2.17.1
PATCH v3 2/27 target/alpha: Convert to CPUClass::tlb_fill
In reply to Richard Henderson---
v2: Keep user-only and system tlb_fill separate.
--- target/alpha/cpu.h | 5 +++-- target/alpha/cpu.c | 5 ++--- target/alpha/helper.c | 30 +++++++++++++++++++++--------- target/alpha/mem_helper.c | 16 ---------------- 4 files changed, 26 insertions(+), 30 deletions(-)
target/alpha/cpu.h +3 -2
@@ -475,8 +475,9 @@ void alpha_cpu_list(void);is returned if the signal was handled by the virtual CPU. */ int cpu_alpha_signal_handler (int host_signum,void *pinfo,void *puc); -int alpha_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size,int rw, -int mmu_idx); +bool alpha_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr); void QEMU_NORETURN dynamic_excp(CPUAlphaState *, uintptr_t, int, int); void QEMU_NORETURN arith_excp(CPUAlphaState *, uintptr_t, int, uint64_t);
target/alpha/cpu.c +2 -3
@@ -225,9 +225,8 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = alpha_cpu_set_pc; cc->gdb_read_register = alpha_cpu_gdb_read_register; cc->gdb_write_register = alpha_cpu_gdb_write_register; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = alpha_cpu_handle_mmu_fault; -#else + cc->tlb_fill = alpha_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY cc->do_transaction_failed = alpha_cpu_do_transaction_failed; cc->do_unaligned_access = alpha_cpu_do_unaligned_access; cc->get_phys_page_debug = alpha_cpu_get_phys_page_debug;
target/alpha/helper.c +21 -9
@@ -104,14 +104,15 @@ void cpu_alpha_store_gr(CPUAlphaState *env, unsigned reg, uint64_t val) }#if defined(CONFIG_USER_ONLY ) -int alpha_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int size, -int rw,int mmu_idx) +bool alpha_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr) {AlphaCPU *cpu =ALPHA_CPU (cs); cs->exception_index =EXCP_MMFAULT ; cpu->env.trap_arg0 = address; -return 1 ; +cpu_loop_exit_restore (cs, retaddr); }#else /* Returns the OSF/1 entMM failure indication, or -1 on success. */
@@ -248,26 +249,37 @@ hwaddr alpha_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)return (fail >=0 ?-1 : phys); } -int alpha_cpu_handle_mmu_fault (CPUState *cs,vaddr addr,int size,int rw, -int mmu_idx) +bool alpha_cpu_tlb_fill (CPUState *cs,vaddr addr,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr) {AlphaCPU *cpu =ALPHA_CPU (cs);CPUAlphaState *env = &cpu->env;target_ulong phys;int prot, fail; - fail =get_physical_address (env, addr,1 << rw, mmu_idx, &phys, &prot); + fail =get_physical_address (env, addr,1 << access_type, + mmu_idx, &phys, &prot);if (unlikely (fail >=0 )) { +if (probe) { +return false; + } cs->exception_index =EXCP_MMFAULT ; env->trap_arg0 = addr; env->trap_arg1 = fail; - env->trap_arg2 = (rw ==2 ?-1 : rw); -return 1 ; + env->trap_arg2 = (access_type ==MMU_INST_FETCH ?-1 : access_type); +cpu_loop_exit_restore (cs, retaddr); }tlb_set_page (cs, addr &TARGET_PAGE_MASK , phys &TARGET_PAGE_MASK , prot, mmu_idx,TARGET_PAGE_SIZE ); -return 0 ; +return true; +} + +void tlb_fill (CPUState *cs,target_ulong addr,int size, +MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) +{ +alpha_cpu_tlb_fill (cs, addr, size, access_type, mmu_idx, false, retaddr); }#endif /* USER_ONLY */
target/alpha/mem_helper.c +0 -16
@@ -62,20 +62,4 @@ void alpha_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, env->error_code =0 ; cpu_loop_exit_restore(cs, retaddr); } - -/* try to fill the TLB and return an exception if error. If retaddr is -NULL, it means that the function was called in C code (i.e. not -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) -{ -int ret; - - ret =alpha_cpu_handle_mmu_fault (cs, addr, size, access_type, mmu_idx); -if (unlikely (ret !=0 )) { -/* Exception index and error code are already set */ -cpu_loop_exit_restore (cs, retaddr); - } -}#endif /* CONFIG_USER_ONLY */
Signature · 1 line
2.17.1
PATCH v3 3/27 target/arm: Convert to CPUClass::tlb_fill
In reply to Richard Henderson---
v2: Reword a comment to match the new interface.
--- target/arm/internals.h | 10 +++-- target/arm/cpu.c | 22 +--------- target/arm/helper.c | 98 ++++++++++++++++++++++++++---------------- target/arm/op_helper.c | 29 ++----------- 4 files changed, 73 insertions(+), 86 deletions(-)
target/arm/internals.h +6 -4
@@ -761,10 +761,12 @@ static inline bool arm_extabort_type(MemTxResult result)return result !=MEMTX_DECODE_ERROR ; } -/* Do a page table walk and add page to TLB if possible */ -bool arm_tlb_fill (CPUState *cpu,vaddr address, -MMUAccessType access_type,int mmu_idx, -ARMMMUFaultInfo *fi); +bool arm_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr); + +void arm_deliver_fault(ARMCPU *cpu, vaddr addr, MMUAccessType access_type, + int mmu_idx, ARMMMUFaultInfo *fi) QEMU_NORETURN;/* Return true if the stage 1 translation regime is using LPAE format page * tables */
target/arm/cpu.c +2 -20
@@ -2133,23 +2133,6 @@ static Property arm_cpu_properties[] = { DEFINE_PROP_END_OF_LIST() }; -#ifdef CONFIG_USER_ONLY -static int arm_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int size, -int rw,int mmu_idx) -{ -ARMCPU *cpu =ARM_CPU (cs); -CPUARMState *env = &cpu->env; - - env->exception.vaddress = address; -if (rw ==2 ) { - cs->exception_index =EXCP_PREFETCH_ABORT ; - }else { - cs->exception_index =EXCP_DATA_ABORT ; - } -return 1 ; -} -#endif -static gchar *arm_gdb_arch_name (CPUState *cs) {ARMCPU *cpu =ARM_CPU (cs);
@@ -2182,9 +2165,8 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->synchronize_from_tb = arm_cpu_synchronize_from_tb; cc->gdb_read_register = arm_cpu_gdb_read_register; cc->gdb_write_register = arm_cpu_gdb_write_register; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = arm_cpu_handle_mmu_fault; -#else + cc->tlb_fill = arm_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY cc->do_interrupt = arm_cpu_do_interrupt; cc->do_unaligned_access = arm_cpu_do_unaligned_access; cc->do_transaction_failed = arm_cpu_do_transaction_failed;
target/arm/helper.c +61 -37
110 lines not on this page · raw message
target/arm/op_helper.c +4 -25
@@ -126,8 +126,8 @@ static inline uint32_t merge_syn_data_abort(uint32_t template_syn,return syn; } -static void deliver_fault (ARMCPU *cpu,vaddr addr,MMUAccessType access_type, -int mmu_idx,ARMMMUFaultInfo *fi) +void arm_deliver_fault (ARMCPU *cpu,vaddr addr,MMUAccessType access_type, +int mmu_idx,ARMMMUFaultInfo *fi) {CPUARMState *env = &cpu->env;int target_el;
@@ -179,27 +179,6 @@ static void deliver_fault(ARMCPU *cpu, vaddr addr, MMUAccessType access_type,raise_exception (env, exc, syn, target_el); } -/* try to fill the TLB and return an exception if error. If retaddr is -* NULL, it means that the function was called in C code (i.e. not -* from generated code or from helper.c) -*/ -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -bool ret; -ARMMMUFaultInfo fi = {}; - - ret =arm_tlb_fill (cs, addr, access_type, mmu_idx, &fi); -if (unlikely (ret)) { -ARMCPU *cpu =ARM_CPU (cs); - -/* now we have a real cpu fault */ -cpu_restore_state (cs, retaddr, true); - -deliver_fault (cpu, addr, access_type, mmu_idx, &fi); - } -} -/* Raise a data fault alignment exception for the specified virtual address */ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, MMUAccessType access_type,
@@ -212,7 +191,7 @@ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,cpu_restore_state (cs, retaddr, true); fi.type = ARMFault_Alignment; -deliver_fault (cpu, vaddr, access_type, mmu_idx, &fi); +arm_deliver_fault (cpu, vaddr, access_type, mmu_idx, &fi); }/* arm_cpu_do_transaction_failed: handle a memory system error response
@@ -233,7 +212,7 @@ void arm_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, fi.ea =arm_extabort_type (response); fi.type = ARMFault_SyncExternal; - deliver_fault(cpu, addr, access_type, mmu_idx, &fi); + arm_deliver_fault(cpu, addr, access_type, mmu_idx, &fi); }#endif /* !defined(CONFIG_USER_ONLY) */
Signature · 1 line
2.17.1
PATCH v3 4/27 target/cris: Convert to CPUClass::tlb_fill
In reply to Richard HendersonRemove dumping of cpu state. Remove logging of PC, as that value is garbage until cpu_restore_state.
--- target/cris/cpu.h | 5 +-- target/cris/cpu.c | 5 ++- target/cris/helper.c | 67 +++++++++++++++++++++++------------------ target/cris/op_helper.c | 28 ----------------- 4 files changed, 42 insertions(+), 63 deletions(-)
target/cris/cpu.h +3 -2
@@ -281,8 +281,9 @@ static inline int cpu_mmu_index (CPUCRISState *env, bool ifetch)return !!(env->pregs[PR_CCS ] &U_FLAG ); } -int cris_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size,int rw, -int mmu_idx); +bool cris_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr);/* Support function regs. */ #define SFR_RW_GC_CFG 0][0
target/cris/cpu.c +2 -3
@@ -269,9 +269,8 @@ static void cris_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = cris_cpu_set_pc; cc->gdb_read_register = cris_cpu_gdb_read_register; cc->gdb_write_register = cris_cpu_gdb_write_register; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = cris_cpu_handle_mmu_fault; -#else + cc->tlb_fill = cris_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = cris_cpu_get_phys_page_debug; dc->vmsd = &vmstate_cris_cpu;#endif
target/cris/helper.c +37 -30
106 lines not on this page · raw message
target/cris/op_helper.c +0 -28
@@ -37,34 +37,6 @@#define D_LOG (...) do { } while (0)#endif -#if !defined(CONFIG_USER_ONLY ) -/* Try to fill the TLB and return an exception if error. If retaddr is -NULL, it means that the function was called in C code (i.e. not -from generated code or from helper.c) */ -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -CRISCPU *cpu =CRIS_CPU (cs); -CPUCRISState *env = &cpu->env; -int ret; - -D_LOG ("%s pc=%x tpc=%x ra=%p\n" , __func__, - env->pc, env->pregs[PR_EDA ], (void *)retaddr); - ret =cris_cpu_handle_mmu_fault (cs, addr, size, access_type, mmu_idx); -if (unlikely (ret)) { -if (retaddr) { -/* now we have a real cpu fault */ -if (cpu_restore_state (cs, retaddr, true)) { -/* Evaluate flags after retranslation. */ -helper_top_evaluate_flags (env); - } - } -cpu_loop_exit (cs); - } -} - -#endif -void helper_raise_exception (CPUCRISState *env,uint32_t index) {CPUState *cs =CPU (cris_env_get_cpu (env));
Signature · 1 line
2.17.1
PATCH v3 5/27 target/hppa: Convert to CPUClass::tlb_fill
In reply to Richard Henderson--- target/hppa/cpu.h | 8 ++++---- target/hppa/cpu.c | 5 ++--- target/hppa/mem_helper.c | 22 +++++++++++++++++----- 3 files changed, 23 insertions(+), 12 deletions(-)
target/hppa/cpu.h +4 -4
@@ -360,10 +360,10 @@ int hppa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);void hppa_cpu_do_interrupt (CPUState *cpu);bool hppa_cpu_exec_interrupt (CPUState *cpu,int int_req);void hppa_cpu_dump_state (CPUState *cs,FILE *f,int ); -#ifdef CONFIG_USER_ONLY -int hppa_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size, -int rw,int midx); -#else +bool hppa_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr); +#ifndef CONFIG_USER_ONLY int hppa_get_physical_address (CPUHPPAState *env,vaddr addr,int mmu_idx,int type,hwaddr *pphys,int *pprot);extern const MemoryRegionOps hppa_io_eir_ops;
target/hppa/cpu.c +2 -3
@@ -163,9 +163,8 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *data) cc->synchronize_from_tb = hppa_cpu_synchronize_from_tb; cc->gdb_read_register = hppa_cpu_gdb_read_register; cc->gdb_write_register = hppa_cpu_gdb_write_register; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = hppa_cpu_handle_mmu_fault; -#else + cc->tlb_fill = hppa_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = hppa_cpu_get_phys_page_debug; dc->vmsd = &vmstate_hppa_cpu;#endif
target/hppa/mem_helper.c +17 -5
@@ -25,8 +25,9 @@#include "trace.h" #ifdef CONFIG_USER_ONLY -int hppa_cpu_handle_mmu_fault (CPUState *cs,vaddr address, -int size,int rw,int mmu_idx) +bool hppa_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr) {HPPACPU *cpu =HPPA_CPU (cs);
@@ -34,7 +35,7 @@ int hppa_cpu_handle_mmu_fault(CPUState *cs, vaddr address,which would affect si_code. */ cs->exception_index =EXCP_DMP ; cpu->env.cr[CR_IOR ] = address; - return 1; + cpu_loop_exit_restore(cs, retaddr); }#else static hppa_tlb_entry *hppa_find_tlb (CPUHPPAState *env,vaddr addr)
@@ -213,8 +214,9 @@ hwaddr hppa_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)return excp ==EXCP_DTLB_MISS ?-1 : phys; } -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType type,int mmu_idx,uintptr_t retaddr) +bool hppa_cpu_tlb_fill (CPUState *cs,vaddr addr,int size, +MMUAccessType type,int mmu_idx, +bool probe,uintptr_t retaddr) {HPPACPU *cpu =HPPA_CPU (cs);CPUHPPAState *env = &cpu->env;
@@ -236,6 +238,9 @@ void tlb_fill(CPUState *cs, target_ulong addr, int size, excp =hppa_get_physical_address (env, addr, mmu_idx, a_prot, &phys, &prot);if (unlikely (excp >=0 )) { +if (probe) { +return false; + }trace_hppa_tlb_fill_excp (env, addr, size, type, mmu_idx);/* Failure. Raise the indicated exception. */ cs->exception_index = excp;
@@ -252,6 +257,13 @@ void tlb_fill(CPUState *cs, target_ulong addr, int size,/* Success! Store the translation into the QEMU TLB. */ tlb_set_page (cs, addr &TARGET_PAGE_MASK , phys &TARGET_PAGE_MASK , prot, mmu_idx,TARGET_PAGE_SIZE ); +return true; +} + +void tlb_fill (CPUState *cs,target_ulong addr,int size, +MMUAccessType type,int mmu_idx,uintptr_t retaddr) +{ +hppa_cpu_tlb_fill (cs, addr, size, type, mmu_idx, false, retaddr); }/* Insert (Insn/Data) TLB Address. Note this is PA 1.1 only. */
Signature · 1 line
2.17.1
PATCH v3 6/27 target/i386: Convert to CPUClass::tlb_fill
In reply to Richard HendersonWe do not support probing, but we do not need it yet either.
--- target/i386/cpu.h | 5 ++-- target/i386/cpu.c | 5 ++-- target/i386/excp_helper.c | 61 +++++++++++++++++++++++++-------------- target/i386/mem_helper.c | 21 -------------- 4 files changed, 44 insertions(+), 48 deletions(-)
target/i386/cpu.h +3 -2
@@ -1656,8 +1656,9 @@ void host_cpuid(uint32_t function, uint32_t count,void host_vendor_fms (char *vendor,int *family,int *model,int *stepping);/* helper.c */ -int x86_cpu_handle_mmu_fault (CPUState *cpu,vaddr addr,int size, -int is_write,int mmu_idx); +bool x86_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr);void x86_cpu_set_a20 (X86CPU *cpu,int a20_state);#ifndef CONFIG_USER_ONLY
target/i386/cpu.c +2 -3
@@ -5915,9 +5915,8 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = x86_cpu_gdb_write_register; cc->get_arch_id = x86_cpu_get_arch_id; cc->get_paging_enabled = x86_cpu_get_paging_enabled; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = x86_cpu_handle_mmu_fault; -#else + cc->tlb_fill = x86_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY cc->asidx_from_attrs = x86_asidx_from_attrs; cc->get_memory_mapping = x86_cpu_get_memory_mapping; cc->get_phys_page_debug = x86_cpu_get_phys_page_debug;
target/i386/excp_helper.c +39 -22
76 lines not on this page · raw message
target/i386/mem_helper.c +0 -21
@@ -191,24 +191,3 @@ void helper_boundl(CPUX86State *env, target_ulong a0, int v)raise_exception_ra (env,EXCP05_BOUND ,GETPC ()); } } - -#if !defined(CONFIG_USER_ONLY ) -/* try to fill the TLB and return an exception if error. If retaddr is -* NULL, it means that the function was called in C code (i.e. not -* 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) -{ -X86CPU *cpu =X86_CPU (cs); -CPUX86State *env = &cpu->env; -int ret; - - env->retaddr = retaddr; - ret =x86_cpu_handle_mmu_fault (cs, addr, size, access_type, mmu_idx); -if (ret) { -raise_exception_err_ra (env, cs->exception_index, env->error_code, retaddr); - } -} -#endif
Signature · 1 line
2.17.1
PATCH v3 7/27 target/lm32: Convert to CPUClass::tlb_fill
In reply to Richard Henderson--- target/lm32/cpu.h | 5 +++-- target/lm32/cpu.c | 5 ++--- target/lm32/helper.c | 12 +++++++++--- target/lm32/op_helper.c | 16 ---------------- 4 files changed, 14 insertions(+), 24 deletions(-)
target/lm32/cpu.h +3 -2
@@ -261,8 +261,9 @@ bool lm32_cpu_do_semihosting(CPUState *cs);#define cpu_list lm32_cpu_list#define cpu_signal_handler cpu_lm32_signal_handler -int lm32_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size,int rw, -int mmu_idx); +bool lm32_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr);#include "exec/cpu-all.h"
target/lm32/cpu.c +2 -3
@@ -231,9 +231,8 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = lm32_cpu_set_pc; cc->gdb_read_register = lm32_cpu_gdb_read_register; cc->gdb_write_register = lm32_cpu_gdb_write_register; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = lm32_cpu_handle_mmu_fault; -#else + cc->tlb_fill = lm32_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = lm32_cpu_get_phys_page_debug; cc->vmsd = &vmstate_lm32_cpu;#endif
target/lm32/helper.c +9 -3
@@ -25,8 +25,9 @@#include "exec/semihost.h" #include "exec/log.h" -int lm32_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int size,int rw, -int mmu_idx) +bool lm32_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr) {LM32CPU *cpu =LM32_CPU (cs);CPULM32State *env = &cpu->env;
@@ -40,8 +41,13 @@ int lm32_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw, }else {tlb_set_page (cs, address, address, prot, mmu_idx,TARGET_PAGE_SIZE ); } +return true; +} -return 0 ; +void tlb_fill (CPUState *cs,target_ulong addr,int size, +MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) +{ +lm32_cpu_tlb_fill (cs, addr, size, access_type, mmu_idx, false, retaddr); }hwaddr lm32_cpu_get_phys_page_debug (CPUState *cs,vaddr addr)
target/lm32/op_helper.c +0 -16
@@ -143,21 +143,5 @@ uint32_t HELPER(rcsr_jrx)(CPULM32State *env) {return lm32_juart_get_jrx (env->juart_state); } - -/* Try to fill the TLB and return an exception if error. If retaddr is -* NULL, it means that the function was called in C code (i.e. not -* from generated code or from helper.c) -*/ -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -int ret; - - ret =lm32_cpu_handle_mmu_fault (cs, addr, size, access_type, mmu_idx); -if (unlikely (ret)) { -/* now we have a real cpu fault */ -cpu_loop_exit_restore (cs, retaddr); - } -}#endif
Signature · 1 line
2.17.1
PATCH v3 8/27 target/m68k: Convert to CPUClass::tlb_fill
In reply to Richard Henderson--- target/m68k/cpu.h | 5 ++- target/m68k/cpu.c | 2 +- target/m68k/helper.c | 87 ++++++++++++++++++++++------------------- target/m68k/op_helper.c | 15 ------- 4 files changed, 50 insertions(+), 59 deletions(-)
target/m68k/cpu.h +3 -2
@@ -542,8 +542,9 @@ static inline int cpu_mmu_index (CPUM68KState *env, bool ifetch)return (env->sr &SR_S ) ==0 ?1 :0 ; } -int m68k_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size,int rw, -int mmu_idx); +bool m68k_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr);void m68k_cpu_unassigned_access (CPUState *cs,hwaddr addr,bool is_write,bool is_exec,int is_asi,unsigned size);
target/m68k/cpu.c +1 -1
@@ -269,7 +269,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) cc->set_pc = m68k_cpu_set_pc; cc->gdb_read_register = m68k_cpu_gdb_read_register; cc->gdb_write_register = m68k_cpu_gdb_write_register; - cc->handle_mmu_fault = m68k_cpu_handle_mmu_fault; + cc->tlb_fill = m68k_cpu_tlb_fill;#if defined(CONFIG_SOFTMMU ) cc->do_unassigned_access = m68k_cpu_unassigned_access; cc->get_phys_page_debug = m68k_cpu_get_phys_page_debug;
target/m68k/helper.c +46 -41
138 lines not on this page · raw message
target/m68k/op_helper.c +0 -15
@@ -36,21 +36,6 @@ static inline void do_interrupt_m68k_hardirq(CPUM68KState *env)#else -/* Try to fill the TLB and return an exception if error. If retaddr is -NULL, it means that the function was called in C code (i.e. not -from generated code or from helper.c) */ -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -int ret; - - ret =m68k_cpu_handle_mmu_fault (cs, addr, size, access_type, mmu_idx); -if (unlikely (ret)) { -/* now we have a real cpu fault */ -cpu_loop_exit_restore (cs, retaddr); - } -} -static void cf_rte (CPUM68KState *env) {uint32_t sp;
Signature · 1 line
2.17.1
PATCH v3 9/27 target/microblaze: Convert to CPUClass::tlb_fill
In reply to Richard Henderson---
v2: Keep user-only and system tlb_fill separate.
--- target/microblaze/cpu.h | 5 +- target/microblaze/cpu.c | 5 +- target/microblaze/helper.c | 107 ++++++++++++++++++---------------- target/microblaze/op_helper.c | 19 ------ 4 files changed, 62 insertions(+), 74 deletions(-)
target/microblaze/cpu.h +3 -2
@@ -374,8 +374,9 @@ static inline int cpu_mmu_index (CPUMBState *env, bool ifetch)return MMU_KERNEL_IDX ; } -int mb_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size,int rw, -int mmu_idx); +bool mb_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr);#include "exec/cpu-all.h"
target/microblaze/cpu.c +2 -3
@@ -304,9 +304,8 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = mb_cpu_set_pc; cc->gdb_read_register = mb_cpu_gdb_read_register; cc->gdb_write_register = mb_cpu_gdb_write_register; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = mb_cpu_handle_mmu_fault; -#else + cc->tlb_fill = mb_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY cc->do_transaction_failed = mb_cpu_transaction_failed; cc->get_phys_page_debug = mb_cpu_get_phys_page_debug;#endif
target/microblaze/helper.c +57 -50
130 lines not on this page · raw message
target/microblaze/op_helper.c +0 -19
@@ -28,25 +28,6 @@#define D (x) -#if !defined(CONFIG_USER_ONLY ) - -/* Try to fill the TLB and return an exception if error. If retaddr is -* NULL, it means that the function was called in C code (i.e. not -* from generated code or from helper.c) -*/ -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -int ret; - - ret =mb_cpu_handle_mmu_fault (cs, addr, size, access_type, mmu_idx); -if (unlikely (ret)) { -/* now we have a real cpu fault */ -cpu_loop_exit_restore (cs, retaddr); - } -} -#endif -void helper_put (uint32_t id,uint32_t ctrl,uint32_t data) {int test = ctrl &STREAM_TEST ;
Signature · 1 line
2.17.1
PATCH v3 10/27 target/mips: Pass a valid error to raise_mmu_exception for user-only
In reply to Richard HendersonAt present we give ret = 0, or TLBRET_MATCH. This gets matched by the default case, which falls through to TLBRET_BADADDR. However, it makes more sense to use a proper value. All of the tlb-related exceptions are handled identically in cpu_loop.c, so TLBRET_BADADDR is as good as any other. Retain it.
--- target/mips/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/mips/helper.c +1 -1
@@ -884,7 +884,7 @@ int mips_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw,int prot;int access_type;#endif -int ret =0 ; +int ret =TLBRET_BADADDR ;#if 0 log_cpu_state (cs,0 );
Signature · 1 line
2.17.1
PATCH v3 11/27 target/mips: Tidy control flow in mips_cpu_handle_mmu_fault
In reply to Richard HendersonSince the only non-negative TLBRET_* value is TLBRET_MATCH, the subsequent test for ret < 0 is useless. Use early return to allow subsequent blocks to be unindented.
--- target/mips/helper.c | 54 ++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 30 deletions(-)
target/mips/helper.c +24 -30
@@ -915,41 +915,35 @@ int mips_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw,tlb_set_page (cs, address &TARGET_PAGE_MASK , physical &TARGET_PAGE_MASK , prot |PAGE_EXEC , mmu_idx,TARGET_PAGE_SIZE ); - ret = 0; - }else if (ret <0 ) -#endif - { -#if !defined(CONFIG_USER_ONLY ) +return 0 ; + }#if !defined(TARGET_MIPS64 ) -if ((ret ==TLBRET_NOMATCH ) && (env->tlb->nb_tlb >1 )) { -/* -* Memory reads during hardware page table walking are performed -* as if they were kernel-mode load instructions. -*/ -int mode = (env->hflags &MIPS_HFLAG_KSU ); -bool ret_walker; - env->hflags &= ~MIPS_HFLAG_KSU ; - ret_walker =page_table_walk_refill (env, address, rw, mmu_idx); - env->hflags |= mode; -if (ret_walker) { - ret =get_physical_address (env, &physical, &prot, - address, rw, access_type, mmu_idx); -if (ret ==TLBRET_MATCH ) { -tlb_set_page (cs, address &TARGET_PAGE_MASK , - physical &TARGET_PAGE_MASK , prot |PAGE_EXEC , - mmu_idx,TARGET_PAGE_SIZE ); - ret =0 ; -return ret; - } +if ((ret ==TLBRET_NOMATCH ) && (env->tlb->nb_tlb >1 )) { +/* +* Memory reads during hardware page table walking are performed +* as if they were kernel-mode load instructions. +*/ +int mode = (env->hflags &MIPS_HFLAG_KSU ); +bool ret_walker; + env->hflags &= ~MIPS_HFLAG_KSU ; + ret_walker =page_table_walk_refill (env, address, rw, mmu_idx); + env->hflags |= mode; +if (ret_walker) { + ret =get_physical_address (env, &physical, &prot, + address, rw, access_type, mmu_idx); +if (ret ==TLBRET_MATCH ) { +tlb_set_page (cs, address &TARGET_PAGE_MASK , + physical &TARGET_PAGE_MASK , prot |PAGE_EXEC , + mmu_idx,TARGET_PAGE_SIZE ); +return 0 ; } } -#endif -#endif -raise_mmu_exception (env, address, rw, ret); - ret =1 ; } +#endif +#endif -return ret; +raise_mmu_exception (env, address, rw, ret); +return 1 ; }#if !defined(CONFIG_USER_ONLY )
Signature · 1 line
2.17.1
PATCH v3 12/27 target/mips: Convert to CPUClass::tlb_fill
In reply to Richard HendersonNote that env->active_tc.PC is removed from the qemu_log as that value is garbage. The PC isn't recovered until cpu_restore_state, called from cpu_loop_exit_restore, called from do_raise_exception_err.
---
v2: Split out other mips cleanups to simplify the diff
--- target/mips/internal.h | 5 +++-- target/mips/cpu.c | 5 ++--- target/mips/helper.c | 45 ++++++++++++++++++++++------------------- target/mips/op_helper.c | 15 -------------- 4 files changed, 29 insertions(+), 41 deletions(-)
target/mips/internal.h +3 -2
@@ -202,8 +202,9 @@ void cpu_mips_start_count(CPUMIPSState *env);void cpu_mips_stop_count (CPUMIPSState *env);/* helper.c */ -int mips_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size,int rw, -int mmu_idx); +bool mips_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr);/* op_helper.c */ uint32_t float_class_s (uint32_t arg,float_status *fst);
target/mips/cpu.c +2 -3
@@ -197,9 +197,8 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->synchronize_from_tb = mips_cpu_synchronize_from_tb; cc->gdb_read_register = mips_cpu_gdb_read_register; cc->gdb_write_register = mips_cpu_gdb_write_register; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = mips_cpu_handle_mmu_fault; -#else + cc->tlb_fill = mips_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY cc->do_unassigned_access = mips_cpu_unassigned_access; cc->do_unaligned_access = mips_cpu_do_unaligned_access; cc->get_phys_page_debug = mips_cpu_get_phys_page_debug;
target/mips/helper.c +24 -21
89 lines not on this page · raw message
target/mips/op_helper.c +0 -15
@@ -2669,21 +2669,6 @@ void mips_cpu_do_unaligned_access(CPUState *cs, vaddr addr,do_raise_exception_err (env, excp, error_code, retaddr); } -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -int ret; - - ret =mips_cpu_handle_mmu_fault (cs, addr, size, access_type, mmu_idx); -if (ret) { -MIPSCPU *cpu =MIPS_CPU (cs); -CPUMIPSState *env = &cpu->env; - -do_raise_exception_err (env, cs->exception_index, - env->error_code, retaddr); - } -} -void mips_cpu_unassigned_access (CPUState *cs,hwaddr addr,bool is_write,bool is_exec,int unused,unsigned size)
Signature · 1 line
2.17.1
PATCH v3 13/27 target/moxie: Convert to CPUClass::tlb_fill
In reply to Richard HendersonRemove the user-only functions, as we don't have a user-only config. Fix the unconditional call to tlb_set_page, even if the translation failed.
--- target/moxie/cpu.h | 5 ++-- target/moxie/cpu.c | 5 ++-- target/moxie/helper.c | 61 ++++++++++--------------------------------- 3 files changed, 19 insertions(+), 52 deletions(-)
target/moxie/cpu.h +3 -2
@@ -139,7 +139,8 @@ static inline void cpu_get_tb_cpu_state(CPUMoxieState *env, target_ulong *pc, *flags = 0; } -int moxie_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size, -int rw,int mmu_idx); +bool moxie_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr);#endif /* MOXIE_CPU_H */
target/moxie/cpu.c +2 -3
@@ -112,9 +112,8 @@ static void moxie_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = moxie_cpu_do_interrupt; cc->dump_state = moxie_cpu_dump_state; cc->set_pc = moxie_cpu_set_pc; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = moxie_cpu_handle_mmu_fault; -#else + cc->tlb_fill = moxie_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = moxie_cpu_get_phys_page_debug; cc->vmsd = &vmstate_moxie_cpu;#endif
target/moxie/helper.c +14 -47
89 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 14/27 target/nios2: Convert to CPUClass::tlb_fill
In reply to Richard HendersonRemove the leftover debugging cpu_dump_state.
---
v2: Keep user-only and system tlb_fill separate.
--- target/nios2/cpu.h | 5 +- target/nios2/cpu.c | 5 +- target/nios2/helper.c | 176 +++++++++++++++++++++--------------------- target/nios2/mmu.c | 12 --- 4 files changed, 91 insertions(+), 107 deletions(-)
target/nios2/cpu.h +3 -2
@@ -252,8 +252,9 @@ static inline int cpu_mmu_index(CPUNios2State *env, bool ifetch)MMU_SUPERVISOR_IDX ; } -int nios2_cpu_handle_mmu_fault (CPUState *env,vaddr address,int size, -int rw,int mmu_idx); +bool nios2_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr);static inline int cpu_interrupts_enabled (CPUNios2State *env) {
target/nios2/cpu.c +2 -3
@@ -200,9 +200,8 @@ static void nios2_cpu_class_init(ObjectClass *oc, void *data) cc->dump_state = nios2_cpu_dump_state; cc->set_pc = nios2_cpu_set_pc; cc->disas_set_info = nios2_cpu_disas_set_info; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = nios2_cpu_handle_mmu_fault; -#else + cc->tlb_fill = nios2_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY cc->do_unaligned_access = nios2_cpu_do_unaligned_access; cc->get_phys_page_debug = nios2_cpu_get_phys_page_debug;#endif
target/nios2/helper.c +86 -90
194 lines not on this page · raw message
target/nios2/mmu.c +0 -12
@@ -36,18 +36,6 @@#define MMU_LOG (x)#endif -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -int ret; - - ret =nios2_cpu_handle_mmu_fault (cs, addr, size, access_type, mmu_idx); -if (unlikely (ret)) { -/* now we have a real cpu fault */ -cpu_loop_exit_restore (cs, retaddr); - } -} -void mmu_read_debug (CPUNios2State *env,uint32_t rn) {switch (rn) {
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH v3 14/27] target/nios2: Convert to CPUClass::tlb_fill
Quoted 9 lines · Richard Henderson
Remove the leftover debugging
cpu_dump_state.Cc Chris Wulff <[email protected]>Cc Marek Vasut <[email protected]>Signed-off-by Richard Henderson <[email protected]>---
v2: Keep user-only and systemtlb_fillseparate.
---
thanks
-- PMM
PATCH v3 15/27 target/openrisc: Convert to CPUClass::tlb_fill
In reply to Richard Henderson--- target/openrisc/cpu.h | 5 ++-- target/openrisc/cpu.c | 5 ++-- target/openrisc/mmu.c | 65 ++++++++++++++++++++++--------------------- 3 files changed, 39 insertions(+), 36 deletions(-)
target/openrisc/cpu.h +3 -2
@@ -344,8 +344,9 @@ hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);int openrisc_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int openrisc_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);void openrisc_translate_init (void ); -int openrisc_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size, -int rw,int mmu_idx); +bool openrisc_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr);int cpu_openrisc_signal_handler (int host_signum,void *pinfo,void *puc);int print_insn_or1k (bfd_vma addr,disassemble_info *info);
target/openrisc/cpu.c +2 -3
@@ -149,9 +149,8 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = openrisc_cpu_set_pc; cc->gdb_read_register = openrisc_cpu_gdb_read_register; cc->gdb_write_register = openrisc_cpu_gdb_write_register; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = openrisc_cpu_handle_mmu_fault; -#else + cc->tlb_fill = openrisc_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = openrisc_cpu_get_phys_page_debug; dc->vmsd = &vmstate_openrisc_cpu;#endif
target/openrisc/mmu.c +34 -31
79 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 16/27 target/ppc: Convert to CPUClass::tlb_fill
In reply to Richard Henderson--- target/ppc/cpu.h | 7 +++---- target/ppc/mmu_helper.c | 22 +++++++++++++--------- target/ppc/translate_init.inc.c | 5 ++--- target/ppc/user_only_helper.c | 14 ++++++++------ 4 files changed, 26 insertions(+), 22 deletions(-)
target/ppc/cpu.h +3 -4
@@ -1311,10 +1311,9 @@ void ppc_translate_init(void);* is returned if the signal was handled by the virtual CPU. */ int cpu_ppc_signal_handler (int host_signum,void *pinfo,void *puc); -#if defined(CONFIG_USER_ONLY ) -int ppc_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size,int rw, -int mmu_idx); -#endif +bool ppc_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr);#if !defined(CONFIG_USER_ONLY )void ppc_store_sdr1 (CPUPPCState *env,target_ulong value);
target/ppc/mmu_helper.c +13 -9
@@ -3057,15 +3057,9 @@ void helper_check_tlb_flush_global(CPUPPCState *env)/*****************************************************************************/ -/* -* try to fill the TLB and return an exception if error. If retaddr is -* NULL, it means that the function was called in C code (i.e. not -* 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) +bool ppc_cpu_tlb_fill (CPUState *cs,vaddr addr,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr) {PowerPCCPU *cpu =POWERPC_CPU (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); }if (unlikely (ret !=0 )) { +if (probe) { +return false; + }raise_exception_err_ra (env, cs->exception_index, env->error_code, 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); }
target/ppc/translate_init.inc.c +2 -3
@@ -10592,9 +10592,8 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_read_register = ppc_cpu_gdb_read_register; cc->gdb_write_register = ppc_cpu_gdb_write_register; cc->do_unaligned_access = ppc_cpu_do_unaligned_access; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = ppc_cpu_handle_mmu_fault; -#else + cc->tlb_fill = ppc_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = ppc_cpu_get_phys_page_debug; cc->vmsd = &vmstate_ppc_cpu;#endif
target/ppc/user_only_helper.c +8 -6
@@ -20,21 +20,24 @@#include "qemu/osdep.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);CPUPPCState *env = &cpu->env;int exception, error_code; -if (rw ==2 ) { +if (access_type ==MMU_INST_FETCH ) { exception =POWERPC_EXCP_ISI ; error_code =0x40000000 ; }else { exception =POWERPC_EXCP_DSI ; error_code =0x40000000 ; -if (rw) { +if (access_type ==MMU_DATA_STORE ) { error_code |=0x02000000 ; } 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; env->error_code = error_code; - -return 1 ; +cpu_loop_exit_restore (cs, retaddr); }
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH v3 16/27] target/ppc: Convert to CPUClass::tlb_fill
Quoted 4 lines · Richard Henderson
Cc David Gibson <[email protected]>Reviewed-by Peter Maydell <[email protected]>Signed-off-by Richard Henderson <[email protected]>
Quoted 123 lines
--- target/ppc/cpu.h | 7 +++---- target/ppc/mmu_helper.c | 22 +++++++++++++--------- target/ppc/translate_init.inc.c | 5 ++--- target/ppc/user_only_helper.c | 14 ++++++++------ 4 files changed, 26 insertions(+), 22 deletions(-)target/ppc/cpu.h +3
-4@@ -1311,10 +1311,9 @@ void ppc_translate_init(void);* is returned if the signal was handled by the virtual CPU. */ int cpu_ppc_signal_handler (int host_signum,void *pinfo,void *puc); -#if defined(CONFIG_USER_ONLY ) -int ppc_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size,int rw, -int mmu_idx); -#endif +bool ppc_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr);#if !defined(CONFIG_USER_ONLY )void ppc_store_sdr1 (CPUPPCState *env,target_ulong value);target/ppc/mmu_helper.c +13
-9@@ -3057,15 +3057,9 @@ void helper_check_tlb_flush_global(CPUPPCState *env)/*****************************************************************************/ -/* -* try to fill the TLB and return an exception if error. If retaddr is -* NULL, it means that the function was called in C code (i.e. not -* 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) +bool ppc_cpu_tlb_fill (CPUState *cs,vaddr addr,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr) {PowerPCCPU *cpu =POWERPC_CPU (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); }if (unlikely (ret !=0 )) { +if (probe) { +return false; + }raise_exception_err_ra (env, cs->exception_index, env->error_code, 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); }target/ppc/translate_init.inc.c +2
-3@@ -10592,9 +10592,8 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_read_register = ppc_cpu_gdb_read_register; cc->gdb_write_register = ppc_cpu_gdb_write_register; cc->do_unaligned_access = ppc_cpu_do_unaligned_access; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = ppc_cpu_handle_mmu_fault; -#else + cc->tlb_fill = ppc_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = ppc_cpu_get_phys_page_debug; cc->vmsd = &vmstate_ppc_cpu;#endif target/ppc/user_only_helper.c +8
-6@@ -20,21 +20,24 @@#include "qemu/osdep.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);CPUPPCState *env = &cpu->env;int exception, error_code; -if (rw ==2 ) { +if (access_type ==MMU_INST_FETCH ) { exception =POWERPC_EXCP_ISI ; error_code =0x40000000 ; }else { exception =POWERPC_EXCP_DSI ; error_code =0x40000000 ; -if (rw) { +if (access_type ==MMU_DATA_STORE ) { error_code |=0x02000000 ; } 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; env->error_code = error_code; - -return 1 ; +cpu_loop_exit_restore (cs, retaddr); }
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
PATCH v3 17/27 target/riscv: Convert to CPUClass::tlb_fill
In reply to Richard HendersonNote that env->pc is removed from the qemu_log as that value is garbage. The PC isn't recovered until cpu_restore_state, called from cpu_loop_exit_restore, called from riscv_raise_exception.
--- target/riscv/cpu.h | 5 +++-- target/riscv/cpu.c | 5 ++--- target/riscv/cpu_helper.c | 46 ++++++++++++++++++--------------------- 3 files changed, 26 insertions(+), 30 deletions(-)
target/riscv/cpu.h +3 -2
@@ -261,8 +261,9 @@ hwaddr riscv_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);void riscv_cpu_do_unaligned_access (CPUState *cs,vaddr addr,MMUAccessType access_type,int mmu_idx,uintptr_t retaddr); -int riscv_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size, -int rw,int mmu_idx); +bool riscv_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr);char *riscv_isa_string (RISCVCPU *cpu);void riscv_cpu_list (void );
target/riscv/cpu.c +2 -3
@@ -355,9 +355,8 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data)#endif cc->gdb_stop_before_watchpoint = true; cc->disas_set_info = riscv_cpu_disas_set_info; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = riscv_cpu_handle_mmu_fault; -#else + cc->tlb_fill = riscv_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY cc->do_unaligned_access = riscv_cpu_do_unaligned_access; cc->get_phys_page_debug = riscv_cpu_get_phys_page_debug;#endif
target/riscv/cpu_helper.c +21 -25
82 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 18/27 target/s390x: Convert to CPUClass::tlb_fill
In reply to Richard Henderson---
v2: Keep user-only and system tlb_fill separate.
--- target/s390x/internal.h | 5 +-- target/s390x/cpu.c | 5 ++- target/s390x/excp_helper.c | 73 ++++++++++++++++++++++++++------------ target/s390x/mem_helper.c | 16 --------- 4 files changed, 55 insertions(+), 44 deletions(-)
target/s390x/internal.h +3 -2
@@ -263,8 +263,9 @@ ObjectClass *s390_cpu_class_by_name(const char *name);void s390x_cpu_debug_excp_handler (CPUState *cs);void s390_cpu_do_interrupt (CPUState *cpu);bool s390_cpu_exec_interrupt (CPUState *cpu,int int_req); -int s390_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size,int rw, -int mmu_idx); +bool s390_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr);void s390x_cpu_do_unaligned_access (CPUState *cs,vaddr addr,MMUAccessType access_type,int mmu_idx,uintptr_t retaddr);
target/s390x/cpu.c +2 -3
@@ -478,9 +478,8 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = s390_cpu_set_pc; cc->gdb_read_register = s390_cpu_gdb_read_register; cc->gdb_write_register = s390_cpu_gdb_write_register; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = s390_cpu_handle_mmu_fault; -#else + cc->tlb_fill = s390_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = s390_cpu_get_phys_page_debug; cc->vmsd = &vmstate_s390_cpu; cc->write_elf64_note = s390_cpu_write_elf64_note;
target/s390x/excp_helper.c +50 -23
123 lines not on this page · raw message
target/s390x/mem_helper.c +0 -16
@@ -33,22 +33,6 @@/*****************************************************************************/ /* Softmmu support */ -#if !defined(CONFIG_USER_ONLY ) - -/* try to fill the TLB and return an exception if error. If retaddr is -NULL, it means that the function was called in C code (i.e. not -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) -{ -int ret =s390_cpu_handle_mmu_fault (cs, addr, size, access_type, mmu_idx); -if (unlikely (ret !=0 )) { -cpu_loop_exit_restore (cs, retaddr); - } -} - -#endif /* #define DEBUG_HELPER */ #ifdef DEBUG_HELPER
Signature · 1 line
2.17.1
PATCH v3 19/27 target/sh4: Convert to CPUClass::tlb_fill
In reply to Richard Henderson--- target/sh4/cpu.h | 5 +- target/sh4/cpu.c | 5 +- target/sh4/helper.c | 197 ++++++++++++++++++++--------------------- target/sh4/op_helper.c | 12 --- 4 files changed, 101 insertions(+), 118 deletions(-)
target/sh4/cpu.h +3 -2
@@ -243,8 +243,9 @@ void superh_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,void sh4_translate_init (void );int cpu_sh4_signal_handler (int host_signum,void *pinfo,void *puc); -int superh_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size,int rw, -int mmu_idx); +bool superh_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr);void sh4_cpu_list (void );#if !defined(CONFIG_USER_ONLY )
target/sh4/cpu.c +2 -3
@@ -229,9 +229,8 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) cc->synchronize_from_tb = superh_cpu_synchronize_from_tb; cc->gdb_read_register = superh_cpu_gdb_read_register; cc->gdb_write_register = superh_cpu_gdb_write_register; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = superh_cpu_handle_mmu_fault; -#else + cc->tlb_fill = superh_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY cc->do_unaligned_access = superh_cpu_do_unaligned_access; cc->get_phys_page_debug = superh_cpu_get_phys_page_debug;#endif
target/sh4/helper.c +96 -101
224 lines not on this page · raw message
target/sh4/op_helper.c +0 -12
@@ -41,18 +41,6 @@ void superh_cpu_do_unaligned_access(CPUState *cs, vaddr addr, cpu_loop_exit_restore(cs, retaddr); } -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -int ret; - - ret =superh_cpu_handle_mmu_fault (cs, addr, size, access_type, mmu_idx); -if (ret) { -/* now we have a real cpu fault */ -cpu_loop_exit_restore (cs, retaddr); - } -} -#endif void helper_ldtlb (CPUSH4State *env)
Signature · 1 line
2.17.1
PATCH v3 20/27 target/sparc: Convert to CPUClass::tlb_fill
In reply to Richard Henderson---
v2: Keep user-only, sparc32, and sparc64 tlb_fill separate.
v3: Assert !probe for sparc32.
--- target/sparc/cpu.h | 5 ++-- target/sparc/cpu.c | 5 ++-- target/sparc/ldst_helper.c | 11 +------- target/sparc/mmu_helper.c | 58 ++++++++++++++++++++++++-------------- 4 files changed, 43 insertions(+), 36 deletions(-)
target/sparc/cpu.h +3 -2
@@ -579,8 +579,9 @@ void cpu_raise_exception_ra(CPUSPARCState *, int, uintptr_t) QEMU_NORETURN;void cpu_sparc_set_id (CPUSPARCState *env,unsigned int cpu);void sparc_cpu_list (void );/* mmu_helper.c */ -int sparc_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size,int rw, -int mmu_idx); +bool sparc_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr);target_ulong mmu_probe (CPUSPARCState *env,target_ulong address,int mmulev);void dump_mmu (CPUSPARCState *env);
target/sparc/cpu.c +2 -3
@@ -875,9 +875,8 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data) cc->synchronize_from_tb = sparc_cpu_synchronize_from_tb; cc->gdb_read_register = sparc_cpu_gdb_read_register; cc->gdb_write_register = sparc_cpu_gdb_write_register; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = sparc_cpu_handle_mmu_fault; -#else + cc->tlb_fill = sparc_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY cc->do_unassigned_access = sparc_cpu_unassigned_access; cc->do_unaligned_access = sparc_cpu_do_unaligned_access; cc->get_phys_page_debug = sparc_cpu_get_phys_page_debug;
target/sparc/ldst_helper.c +1 -10
@@ -1925,18 +1925,9 @@ void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr, cpu_raise_exception_ra(env, TT_UNALIGNED, retaddr); } -/* try to fill the TLB and return an exception if error. If retaddr is -NULL, it means that the function was called in C code (i.e. not -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) { -int ret; - - ret =sparc_cpu_handle_mmu_fault (cs, addr, size, access_type, mmu_idx); -if (ret) { -cpu_loop_exit_restore (cs, retaddr); - } +sparc_cpu_tlb_fill (cs, addr, size, access_type, mmu_idx, false, retaddr); }#endif
target/sparc/mmu_helper.c +37 -21
121 lines not on this page · raw message
Signature · 1 line
2.17.1
Peter Maydell
AppliedRe: [Qemu-devel] [PATCH v3 20/27] target/sparc: Convert to CPUClass::tlb_fill
Quoted 7 lines · Richard Henderson
Cc Artyom Tarasenko <[email protected]>Cc Mark Cave-Ayland <[email protected]>Signed-off-by Richard Henderson <[email protected]>---
v2: Keep user-only, sparc32, and sparc64tlb_fillseparate.
v3: Assert !probe for sparc32.
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/4.1
for any user-visible changes.
-- PMM
Peter Maydell
Reviewed-byRe: [Qemu-devel] [PATCH v3 20/27] target/sparc: Convert to CPUClass::tlb_fill
Quoted 12 lines · Peter Maydell
Quoted 7 lines · Richard Henderson
Cc Artyom Tarasenko <[email protected]>Cc Mark Cave-Ayland <[email protected]>Signed-off-by Richard Henderson <[email protected]>---
v2: Keep user-only, sparc32, and sparc64tlb_fillseparate.
v3: Assert !probe for sparc32.
Quoted 1 line
Applied, thanks.
Whoops, triggered the wrong canned reply in my mail client. What I meant was
thanks
-- PMM
PATCH v3 21/27 target/tilegx: Convert to CPUClass::tlb_fill
In reply to Richard Henderson--- target/tilegx/cpu.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
target/tilegx/cpu.c +6 -4
@@ -25,6 +25,7 @@#include "hw/qdev-properties.h" #include "linux-user/syscall_defs.h" #include "qemu/qemu-print.h" +#include "exec/exec-all.h" static void tilegx_cpu_dump_state (CPUState *cs,FILE *f,int flags) {
@@ -111,8 +112,9 @@ static void tilegx_cpu_do_interrupt(CPUState *cs) cs->exception_index =-1 ; } -static int tilegx_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int size, -int rw,int mmu_idx) +static bool tilegx_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr) {TileGXCPU *cpu =TILEGX_CPU (cs);
@@ -122,7 +124,7 @@ static int tilegx_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, cpu->env.signo =TARGET_SIGSEGV ; cpu->env.sigcode =0 ; -return 1 ; +cpu_loop_exit_restore (cs, retaddr); }static bool tilegx_cpu_exec_interrupt (CPUState *cs,int interrupt_request)
@@ -152,7 +154,7 @@ static void tilegx_cpu_class_init(ObjectClass *oc, void *data) cc->cpu_exec_interrupt = tilegx_cpu_exec_interrupt; cc->dump_state = tilegx_cpu_dump_state; cc->set_pc = tilegx_cpu_set_pc; - cc->handle_mmu_fault = tilegx_cpu_handle_mmu_fault; + cc->tlb_fill = tilegx_cpu_tlb_fill; cc->gdb_num_core_regs =0 ; cc->tcg_initialize = tilegx_tcg_init; }
Signature · 1 line
2.17.1
PATCH v3 22/27 target/tricore: Convert to CPUClass::tlb_fill
In reply to Richard Henderson--- target/tricore/cpu.h | 6 +++--- target/tricore/cpu.c | 1 + target/tricore/helper.c | 27 +++++++++++++++++++-------- target/tricore/op_helper.c | 26 -------------------------- 4 files changed, 23 insertions(+), 37 deletions(-)
target/tricore/cpu.h +3 -3
@@ -417,8 +417,8 @@ static inline void cpu_get_tb_cpu_state(CPUTriCoreState *env, target_ulong *pc,#define CPU_RESOLVING_TYPE TYPE_TRICORE_CPU/* helpers.c */ -int cpu_tricore_handle_mmu_fault (CPUState *cpu,target_ulong address, -int rw,int mmu_idx); -#define cpu_handle_mmu_fault cpu_tricore_handle_mmu_fault +bool tricore_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr);#endif /* TRICORE_CPU_H */
target/tricore/cpu.c +1 -0
@@ -166,6 +166,7 @@ static void tricore_cpu_class_init(ObjectClass *c, void *data) cc->synchronize_from_tb = tricore_cpu_synchronize_from_tb; cc->get_phys_page_attrs_debug = tricore_cpu_get_phys_page_attrs_debug; cc->tcg_initialize = tricore_tcg_init; + cc->tlb_fill = tricore_cpu_tlb_fill; }#define DEFINE_TRICORE_CPU_TYPE (cpu_model, initfn) \
target/tricore/helper.c +19 -8
@@ -50,8 +50,9 @@ static void raise_mmu_exception(CPUTriCoreState *env, target_ulong address, { } -int cpu_tricore_handle_mmu_fault (CPUState *cs,target_ulong address, -int rw,int mmu_idx) +bool tricore_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType rw,int mmu_idx, +bool probe,uintptr_t retaddr) {TriCoreCPU *cpu =TRICORE_CPU (cs);CPUTriCoreState *env = &cpu->env;
@@ -64,20 +65,30 @@ int cpu_tricore_handle_mmu_fault(CPUState *cs, target_ulong address, access_type =ACCESS_INT ; ret =get_physical_address (env, &physical, &prot, address, rw, access_type); -qemu_log_mask (CPU_LOG_MMU ,"%s address=" TARGET_FMT_lx" ret %d physical " TARGET_FMT_plx -" prot %d\n" , __func__, address, ret, physical, prot); + +qemu_log_mask (CPU_LOG_MMU ,"%s address=" TARGET_FMT_lx" ret %d physical " + TARGET_FMT_plx" prot %d\n" , + __func__, (target_ulong )address, ret, physical, prot);if (ret ==TLBRET_MATCH ) {tlb_set_page (cs, address &TARGET_PAGE_MASK , physical &TARGET_PAGE_MASK , prot |PAGE_EXEC , mmu_idx,TARGET_PAGE_SIZE ); - ret =0 ; - }else if (ret <0 ) { +return true; + }else { +assert (ret <0 ); +if (probe) { +return false; + }raise_mmu_exception (env, address, rw, ret); - ret =1 ; +cpu_loop_exit_restore (cs, retaddr); } +} -return ret; +void tlb_fill (CPUState *cs,target_ulong addr,int size, +MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) +{ +tricore_cpu_tlb_fill (cs, addr, size, access_type, mmu_idx, false, retaddr); }static void tricore_cpu_list_entry (gpointer data,gpointer user_data)
target/tricore/op_helper.c +0 -26
@@ -2793,29 +2793,3 @@ uint32_t helper_psw_read(CPUTriCoreState *env) {return psw_read (env); } - - -static inline void QEMU_NORETURN do_raise_exception_err(CPUTriCoreState *env, -uint32_t exception, -int error_code, -uintptr_t pc) -{ -CPUState *cs =CPU (tricore_env_get_cpu (env)); - cs->exception_index = exception; - env->error_code = error_code; -/* now we have a real cpu fault */ -cpu_loop_exit_restore (cs, pc); -} - -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -int ret; - ret =cpu_tricore_handle_mmu_fault (cs, addr, access_type, mmu_idx); -if (ret) { -TriCoreCPU *cpu =TRICORE_CPU (cs); -CPUTriCoreState *env = &cpu->env; -do_raise_exception_err (env, cs->exception_index, - env->error_code, retaddr); - } -}
Signature · 1 line
2.17.1
PATCH v3 23/27 target/unicore32: Convert to CPUClass::tlb_fill
In reply to Richard HendersonRemove the user-only functions, as we no longer have a user-only config.
--- target/unicore32/cpu.h | 5 +++-- target/unicore32/cpu.c | 5 +---- target/unicore32/helper.c | 23 ----------------------- target/unicore32/op_helper.c | 14 -------------- target/unicore32/softmmu.c | 19 +++++++++++++++---- 5 files changed, 19 insertions(+), 47 deletions(-)
target/unicore32/cpu.h +3 -2
@@ -178,8 +178,9 @@ static inline void cpu_get_tb_cpu_state(CPUUniCore32State *env, target_ulong *pc } } -int uc32_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size,int rw, -int mmu_idx); +bool uc32_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr);void uc32_translate_init (void );void switch_mode (CPUUniCore32State *,int );
target/unicore32/cpu.c +1 -4
@@ -138,11 +138,8 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data) cc->cpu_exec_interrupt = uc32_cpu_exec_interrupt; cc->dump_state = uc32_cpu_dump_state; cc->set_pc = uc32_cpu_set_pc; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = uc32_cpu_handle_mmu_fault; -#else + cc->tlb_fill = uc32_cpu_tlb_fill; cc->get_phys_page_debug = uc32_cpu_get_phys_page_debug; -#endif cc->tcg_initialize = uc32_translate_init; dc->vmsd = &vmstate_uc32_cpu; }
target/unicore32/helper.c +0 -23
@@ -215,29 +215,6 @@ void helper_cp1_putc(target_ulong x) }#endif -#ifdef CONFIG_USER_ONLY -void switch_mode (CPUUniCore32State *env,int mode) -{ -UniCore32CPU *cpu =uc32_env_get_cpu (env); - -if (mode !=ASR_MODE_USER ) { -cpu_abort (CPU (cpu),"Tried to switch out of user mode\n" ); - } -} - -void uc32_cpu_do_interrupt (CPUState *cs) -{ -cpu_abort (cs,"NO interrupt in user mode\n" ); -} - -int uc32_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int size, -int access_type,int mmu_idx) -{ -cpu_abort (cs,"NO mmu fault in user mode\n" ); -return 1 ; -} -#endif -bool uc32_cpu_exec_interrupt (CPUState *cs,int interrupt_request) {if (interrupt_request &CPU_INTERRUPT_HARD ) {
target/unicore32/op_helper.c +0 -14
@@ -242,17 +242,3 @@ uint32_t HELPER(ror_cc)(CPUUniCore32State *env, uint32_t x, uint32_t i)return ((uint32_t )x >> shift) | (x << (32 - shift)); } } - -#ifndef CONFIG_USER_ONLY -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -int ret; - - ret =uc32_cpu_handle_mmu_fault (cs, addr, size, access_type, mmu_idx); -if (unlikely (ret)) { -/* now we have a real cpu fault */ -cpu_loop_exit_restore (cs, retaddr); - } -} -#endif
target/unicore32/softmmu.c +15 -4
@@ -215,8 +215,9 @@ do_fault:return code; } -int uc32_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int size, -int access_type,int mmu_idx) +bool uc32_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr) {UniCore32CPU *cpu =UNICORE32_CPU (cs);CPUUniCore32State *env = &cpu->env;
@@ -257,7 +258,11 @@ int uc32_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, phys_addr &=TARGET_PAGE_MASK ; address &=TARGET_PAGE_MASK ;tlb_set_page (cs, address, phys_addr, prot, mmu_idx, page_size); -return 0 ; +return true; + } + +if (probe) { +return false; } env->cp0.c3_faultstatus = ret;
@@ -267,7 +272,13 @@ int uc32_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, }else { cs->exception_index =UC32_EXCP_DTRAP ; } -return ret; +cpu_loop_exit_restore (cs, retaddr); +} + +void tlb_fill (CPUState *cs,target_ulong addr,int size, +MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) +{ +uc32_cpu_tlb_fill (cs, addr, size, access_type, mmu_idx, false, retaddr); }hwaddr uc32_cpu_get_phys_page_debug (CPUState *cs,vaddr addr)
Signature · 1 line
2.17.1
PATCH v3 24/27 target/xtensa: Convert to CPUClass::tlb_fill
In reply to Richard Henderson---
v2: Keep user-only and system tlb_fill separate.
--- target/xtensa/cpu.h | 5 +++-- target/xtensa/cpu.c | 5 ++--- target/xtensa/helper.c | 39 ++++++++++++++++++++++++++------------- 3 files changed, 31 insertions(+), 18 deletions(-)
target/xtensa/cpu.h +3 -2
@@ -552,8 +552,9 @@ static inline XtensaCPU *xtensa_env_get_cpu(const CPUXtensaState *env)#define ENV_OFFSET offsetof(XtensaCPU, env) -int xtensa_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw,int size, -int mmu_idx); +bool xtensa_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr);void xtensa_cpu_do_interrupt (CPUState *cpu);bool xtensa_cpu_exec_interrupt (CPUState *cpu,int interrupt_request); void xtensa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr,
target/xtensa/cpu.c +2 -3
@@ -181,9 +181,8 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_read_register = xtensa_cpu_gdb_read_register; cc->gdb_write_register = xtensa_cpu_gdb_write_register; cc->gdb_stop_before_watchpoint = true; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = xtensa_cpu_handle_mmu_fault; -#else + cc->tlb_fill = xtensa_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY cc->do_unaligned_access = xtensa_cpu_do_unaligned_access; cc->get_phys_page_debug = xtensa_cpu_get_phys_page_debug; cc->do_transaction_failed = xtensa_cpu_do_transaction_failed;
target/xtensa/helper.c +26 -13
@@ -240,19 +240,21 @@ void xtensa_cpu_list(void)#ifdef CONFIG_USER_ONLY -int xtensa_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int size,int rw, -int mmu_idx) +bool xtensa_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr) {XtensaCPU *cpu =XTENSA_CPU (cs);CPUXtensaState *env = &cpu->env;qemu_log_mask (CPU_LOG_INT ,"%s: rw = %d, address = 0x%08" VADDR_PRIx", size = %d\n" , - __func__, rw, address, size); + __func__, access_type, address, size); env->sregs[EXCVADDR ] = address; - env->sregs[EXCCAUSE ] = rw ?STORE_PROHIBITED_CAUSE :LOAD_PROHIBITED_CAUSE ; + env->sregs[EXCCAUSE ] = (access_type ==MMU_DATA_STORE ? +STORE_PROHIBITED_CAUSE :LOAD_PROHIBITED_CAUSE ); cs->exception_index =EXC_USER ; -return 1 ; +cpu_loop_exit_restore (cs, retaddr); }#else
@@ -273,31 +275,42 @@ void xtensa_cpu_do_unaligned_access(CPUState *cs, } } -void tlb_fill (CPUState *cs,target_ulong vaddr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) +bool xtensa_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr) {XtensaCPU *cpu =XTENSA_CPU (cs);CPUXtensaState *env = &cpu->env;uint32_t paddr;uint32_t page_size;unsigned access; -int ret =xtensa_get_physical_addr (env, true, vaddr, access_type, mmu_idx, - &paddr, &page_size, &access); +int ret =xtensa_get_physical_addr (env, true, address, access_type, + mmu_idx, &paddr, &page_size, &access); -qemu_log_mask (CPU_LOG_MMU ,"%s(%08x, %d, %d) -> %08x, ret = %d\n" , - __func__, vaddr, access_type, mmu_idx, paddr, ret); +qemu_log_mask (CPU_LOG_MMU ,"%s(%08" VADDR_PRIx +", %d, %d) -> %08x, ret = %d\n" , + __func__, address, access_type, mmu_idx, paddr, ret);if (ret ==0 ) {tlb_set_page (cs, - vaddr &TARGET_PAGE_MASK , + address &TARGET_PAGE_MASK , paddr &TARGET_PAGE_MASK , access, mmu_idx, page_size); +return true; + }else if (probe) { +return false; }else {cpu_restore_state (cs, retaddr, true); -HELPER (exception_cause_vaddr)(env, env->pc, ret, vaddr); +HELPER (exception_cause_vaddr)(env, env->pc, ret, address); } } +void tlb_fill (CPUState *cs,target_ulong vaddr,int size, +MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) +{ +xtensa_cpu_tlb_fill (cs, vaddr, size, access_type, mmu_idx, false, retaddr); +} + void xtensa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, unsigned size, MMUAccessType access_type, int mmu_idx, MemTxAttrs attrs,
Signature · 1 line
2.17.1
PATCH v3 25/27 tcg: Use CPUClass::tlb_fill in cputlb.c
In reply to Richard HendersonWe can now use the CPUClass hook instead of a named function.
Create a static tlb_fill function to avoid other changes within cputlb.c. This also isolates the asserts within. Remove the named tlb_fill function from all of the targets.
--- include/exec/exec-all.h | 9 --------- accel/tcg/cputlb.c | 19 +++++++++++++++++++ target/alpha/helper.c | 6 ------ target/arm/helper.c | 8 -------- target/cris/helper.c | 6 ------ target/hppa/mem_helper.c | 6 ------ target/i386/excp_helper.c | 8 -------- target/lm32/helper.c | 6 ------ target/m68k/helper.c | 8 -------- target/microblaze/helper.c | 6 ------ target/mips/helper.c | 6 ------ target/moxie/helper.c | 6 ------ target/nios2/helper.c | 6 ------ target/openrisc/mmu.c | 6 ------ target/ppc/mmu_helper.c | 6 ------ target/riscv/cpu_helper.c | 6 ------ target/s390x/excp_helper.c | 6 ------ target/sh4/helper.c | 8 -------- target/sparc/ldst_helper.c | 6 ------ target/tricore/helper.c | 6 ------ target/unicore32/softmmu.c | 6 ------ target/xtensa/helper.c | 6 ------ 22 files changed, 19 insertions(+), 137 deletions(-)
include/exec/exec-all.h +0 -9
@@ -474,15 +474,6 @@ static inline void assert_no_pages_locked(void)*/ struct MemoryRegionSection *iotlb_to_section (CPUState *cpu,hwaddr index,MemTxAttrs attrs); - -/* -* Note: tlb_fill() can trigger a resize of the TLB. This means that all of the -* caller's prior references to the TLB table (e.g. CPUTLBEntry pointers) must -* be discarded and looked up again (e.g. via tlb_entry()). -*/ -void tlb_fill (CPUState *cpu,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr); -#endif #if defined(CONFIG_USER_ONLY )
accel/tcg/cputlb.c +19 -0
@@ -855,6 +855,25 @@ static inline ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr)return ram_addr; } +/* +* Note: tlb_fill() can trigger a resize of the TLB. This means that all of the +* caller's prior references to the TLB table (e.g. CPUTLBEntry pointers) must +* be discarded and looked up again (e.g. via tlb_entry()). +*/ +static void tlb_fill (CPUState *cpu,target_ulong addr,int size, +MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) +{ +CPUClass *cc =CPU_GET_CLASS (cpu); +bool ok; + +/* +* This is not a probe, so only valid return is success; failure +* should result in exception + longjmp to the cpu loop. +*/ + ok = cc->tlb_fill (cpu, addr, size, access_type, mmu_idx, false, retaddr); +assert (ok); +} + static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, int mmu_idx, target_ulong addr, uintptr_t retaddr,
target/alpha/helper.c +0 -6
@@ -275,12 +275,6 @@ bool alpha_cpu_tlb_fill(CPUState *cs, vaddr addr, int size, prot, mmu_idx, TARGET_PAGE_SIZE); return true; } - -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -alpha_cpu_tlb_fill (cs, addr, size, access_type, mmu_idx, false, retaddr); -}#endif /* USER_ONLY */ void alpha_cpu_do_interrupt (CPUState *cs)
target/arm/helper.c +0 -8
@@ -13127,14 +13127,6 @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size,#endif } -#ifndef CONFIG_USER_ONLY -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -arm_cpu_tlb_fill (cs, addr, size, access_type, mmu_idx, false, retaddr); -} -#endif -void HELPER (dc_zva )(CPUARMState *env,uint64_t vaddr_in) {/* Implement DC ZVA, which zeroes a fixed-length block of memory.
target/cris/helper.c +0 -6
@@ -123,12 +123,6 @@ bool cris_cpu_tlb_fill(CPUState *cs, vaddr address, int size,cpu_loop_exit (cs); } -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -cris_cpu_tlb_fill (cs, addr, size, access_type, mmu_idx, false, retaddr); -} -void crisv10_cpu_do_interrupt (CPUState *cs) {CRISCPU *cpu =CRIS_CPU (cs);
target/hppa/mem_helper.c +0 -6
@@ -260,12 +260,6 @@ bool hppa_cpu_tlb_fill(CPUState *cs, vaddr addr, int size,return true; } -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType type,int mmu_idx,uintptr_t retaddr) -{ -hppa_cpu_tlb_fill (cs, addr, size, type, mmu_idx, false, retaddr); -} -/* Insert (Insn/Data) TLB Address. Note this is PA 1.1 only. */ void HELPER (itlba )(CPUHPPAState *env,target_ulong addr,target_ureg reg) {
target/i386/excp_helper.c +0 -8
@@ -700,11 +700,3 @@ bool x86_cpu_tlb_fill(CPUState *cs, vaddr addr, int size,return true;#endif } - -#if !defined(CONFIG_USER_ONLY ) -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -x86_cpu_tlb_fill (cs, addr, size, access_type, mmu_idx, false, retaddr); -} -#endif
target/lm32/helper.c +0 -6
@@ -44,12 +44,6 @@ bool lm32_cpu_tlb_fill(CPUState *cs, vaddr address, int size,return true; } -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -lm32_cpu_tlb_fill (cs, addr, size, access_type, mmu_idx, false, retaddr); -} -hwaddr lm32_cpu_get_phys_page_debug (CPUState *cs,vaddr addr) {LM32CPU *cpu =LM32_CPU (cs);
target/m68k/helper.c +0 -8
@@ -884,14 +884,6 @@ bool m68k_cpu_tlb_fill(CPUState *cs, vaddr address, int size,cpu_loop_exit_restore (cs, retaddr); } -#ifndef CONFIG_USER_ONLY -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -m68k_cpu_tlb_fill (cs, addr, size, access_type, mmu_idx, false, retaddr); -} -#endif -uint32_t HELPER (bitrev )(uint32_t x) { x = ((x >>1 ) &0x55555555u ) | ((x <<1 ) &0xaaaaaaaau );
target/microblaze/helper.c +0 -6
@@ -108,12 +108,6 @@ bool mb_cpu_tlb_fill(CPUState *cs, vaddr address, int size,cpu_loop_exit_restore (cs, retaddr); } -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -mb_cpu_tlb_fill (cs, addr, size, access_type, mmu_idx, false, retaddr); -} -void mb_cpu_do_interrupt (CPUState *cs) {MicroBlazeCPU *cpu =MICROBLAZE_CPU (cs);
target/mips/helper.c +0 -6
@@ -944,12 +944,6 @@ bool mips_cpu_tlb_fill(CPUState *cs, vaddr address, int size, }#ifndef CONFIG_USER_ONLY -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -mips_cpu_tlb_fill (cs, addr, size, access_type, mmu_idx, false, retaddr); -} -hwaddr cpu_mips_translate_address (CPUMIPSState *env,target_ulong address,int rw) {hwaddr physical;
target/moxie/helper.c +0 -6
@@ -26,12 +26,6 @@#include "qemu/host-utils.h" #include "exec/helper-proto.h" -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -moxie_cpu_tlb_fill (cs, addr, size, access_type, mmu_idx, false, retaddr); -} -void helper_raise_exception (CPUMoxieState *env,int ex) {CPUState *cs =CPU (moxie_env_get_cpu (env));
target/nios2/helper.c +0 -6
@@ -311,10 +311,4 @@ bool nios2_cpu_tlb_fill(CPUState *cs, vaddr address, int size, env->regs[CR_BADADDR ] = address; cpu_loop_exit_restore(cs, retaddr); } - -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -nios2_cpu_tlb_fill (cs, addr, size, access_type, mmu_idx, false, retaddr); -}#endif /* !CONFIG_USER_ONLY */
target/openrisc/mmu.c +0 -6
@@ -178,10 +178,4 @@ hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) return phys_addr; } } - -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -openrisc_cpu_tlb_fill (cs, addr, size, access_type, mmu_idx,0 , retaddr); -}#endif
target/ppc/mmu_helper.c +0 -6
@@ -3080,9 +3080,3 @@ bool ppc_cpu_tlb_fill(CPUState *cs, vaddr addr, int size, }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); -}
target/riscv/cpu_helper.c +0 -6
@@ -378,12 +378,6 @@ void riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr, env->badaddr = addr;riscv_raise_exception (env, cs->exception_index, retaddr); } - -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -riscv_cpu_tlb_fill (cs, addr, size, access_type, mmu_idx, false, retaddr); -}#endif bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
target/s390x/excp_helper.c +0 -6
@@ -178,12 +178,6 @@ bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size,cpu_loop_exit (cs); } -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -s390_cpu_tlb_fill (cs, addr, size, access_type, mmu_idx, false, retaddr); -} -static void do_program_interrupt (CPUS390XState *env) {uint64_t mask, addr;
target/sh4/helper.c +0 -8
@@ -872,11 +872,3 @@ bool superh_cpu_tlb_fill(CPUState *cs, vaddr address, int size, }cpu_loop_exit_restore (cs, retaddr); } - -#ifndef CONFIG_USER_ONLY -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -superh_cpu_tlb_fill (cs, addr, size, access_type, mmu_idx, false, retaddr); -} -#endif
target/sparc/ldst_helper.c +0 -6
@@ -1924,10 +1924,4 @@ void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr,#endif cpu_raise_exception_ra(env, TT_UNALIGNED, retaddr); } - -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -sparc_cpu_tlb_fill (cs, addr, size, access_type, mmu_idx, false, retaddr); -}#endif
target/tricore/helper.c +0 -6
@@ -85,12 +85,6 @@ bool tricore_cpu_tlb_fill(CPUState *cs, vaddr address, int size, } } -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -tricore_cpu_tlb_fill (cs, addr, size, access_type, mmu_idx, false, retaddr); -} -static void tricore_cpu_list_entry (gpointer data,gpointer user_data) {ObjectClass *oc = data;
target/unicore32/softmmu.c +0 -6
@@ -275,12 +275,6 @@ bool uc32_cpu_tlb_fill(CPUState *cs, vaddr address, int size,cpu_loop_exit_restore (cs, retaddr); } -void tlb_fill (CPUState *cs,target_ulong addr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -uc32_cpu_tlb_fill (cs, addr, size, access_type, mmu_idx, false, retaddr); -} -hwaddr uc32_cpu_get_phys_page_debug (CPUState *cs,vaddr addr) { error_report("function uc32_cpu_get_phys_page_debug not "
target/xtensa/helper.c +0 -6
@@ -305,12 +305,6 @@ bool xtensa_cpu_tlb_fill(CPUState *cs, vaddr address, int size, } } -void tlb_fill (CPUState *cs,target_ulong vaddr,int size, -MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) -{ -xtensa_cpu_tlb_fill (cs, vaddr, size, access_type, mmu_idx, false, retaddr); -} - void xtensa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, unsigned size, MMUAccessType access_type, int mmu_idx, MemTxAttrs attrs,
Signature · 1 line
2.17.1
PATCH v3 26/27 tcg: Remove CPUClass::handle_mmu_fault
In reply to Richard HendersonThis hook is now completely replaced by tlb_fill.
--- include/qom/cpu.h | 3 --- accel/tcg/user-exec.c | 13 +++---------- 2 files changed, 3 insertions(+), 13 deletions(-)
include/qom/cpu.h +0 -3
@@ -117,7 +117,6 @@ struct TranslationBlock;* This always includes at least the program counter; some targets * will need to do more. If this hook is not implemented then the * default is to call @set_pc(tb->pc). -* @handle_mmu_fault: Callback for handling an MMU fault. * @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
@@ -195,8 +194,6 @@ typedef struct CPUClass { Error **errp);void (*set_pc)(CPUState *cpu,vaddr value);void (*synchronize_from_tb)(CPUState *cpu,struct TranslationBlock *tb); -int (*handle_mmu_fault)(CPUState *cpu,vaddr address,int size,int rw, -int mmu_index);bool (*tlb_fill)(CPUState *cpu,vaddr address,int size,MMUAccessType access_type,int mmu_idx,bool probe,uintptr_t retaddr);
accel/tcg/user-exec.c +3 -10
@@ -63,7 +63,6 @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info, {CPUState *cpu = current_cpu;CPUClass *cc; -int ret;unsigned long address = (unsigned long )info->si_addr;MMUAccessType access_type;
@@ -156,15 +155,9 @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info, helper_retaddr =0 ; cc =CPU_GET_CLASS (cpu); -if (cc->tlb_fill) { - access_type = is_write ?MMU_DATA_STORE :MMU_DATA_LOAD ; - cc->tlb_fill (cpu, address,0 , access_type,MMU_USER_IDX , false, pc); -g_assert_not_reached (); - }else { - ret = cc->handle_mmu_fault (cpu, address,0 , is_write,MMU_USER_IDX ); -g_assert (ret >0 ); -cpu_loop_exit_restore (cpu, pc); - } + access_type = is_write ?MMU_DATA_STORE :MMU_DATA_LOAD ; + cc->tlb_fill (cpu, address,0 , access_type,MMU_USER_IDX , false, pc); +g_assert_not_reached (); }#if defined(__i386__)
Signature · 1 line
2.17.1
PATCH v3 27/27 tcg: Use tlb_fill probe from tlb_vaddr_to_host
In reply to Richard HendersonMost of the existing users would continue around a loop which would fault the tlb entry in via a normal load/store.
But for AArch64 SVE we have an existing emulation bug wherein we would mark the first element of a no-fault vector load as faulted (within the FFR, not via exception) just because we did not have its address in the TLB. Now we can properly only mark it as faulted if there really is no valid, readable translation, while still not raising an exception. (Note that beyond the first element of the vector, the hardware may report a fault for any reason whatsoever; with at least one element loaded, forward progress is guaranteed.)
---
v2: Update function docs comment.
--- include/exec/cpu_ldst.h | 50 ++++++----------------------- accel/tcg/cputlb.c | 69 ++++++++++++++++++++++++++++++++++++----- target/arm/sve_helper.c | 6 +--- 3 files changed, 72 insertions(+), 53 deletions(-)
include/exec/cpu_ldst.h +10 -40
@@ -433,50 +433,20 @@ static inline CPUTLBEntry *tlb_entry(CPUArchState *env, uintptr_t mmu_idx,* @mmu_idx: MMU index to use for lookup * * Look up the specified guest virtual index in the TCG softmmu TLB. -* If the TLB contains a host virtual address suitable for direct RAM -* access, then return it. Otherwise (TLB miss, TLB entry is for an -* I/O access, etc) return NULL. -* -* This is the equivalent of the initial fast-path code used by -* TCG backends for guest load and store accesses. +* If we can translate a host virtual address suitable for direct RAM +* access, without causing a guest exception, then return it. +* Otherwise (TLB entry is for an I/O access, guest software +* TLB fill required, etc) return NULL. */ +#ifdef CONFIG_USER_ONLY static inline void *tlb_vaddr_to_host (CPUArchState *env,abi_ptr addr, -int access_type,int mmu_idx) +MMUAccessType access_type,int mmu_idx) { -#if defined(CONFIG_USER_ONLY )return g2h (addr); -#else -CPUTLBEntry *tlbentry =tlb_entry (env, mmu_idx, addr); -abi_ptr tlb_addr; -uintptr_t haddr; - -switch (access_type) { -case 0 : - tlb_addr = tlbentry->addr_read; -break ; -case 1 : - tlb_addr =tlb_addr_write (tlbentry); -break ; -case 2 : - tlb_addr = tlbentry->addr_code; -break ; -default : -g_assert_not_reached (); - } - -if (!tlb_hit (tlb_addr, addr)) { -/* TLB entry is for a different page */ -return NULL ; - } - -if (tlb_addr & ~TARGET_PAGE_MASK ) { -/* IO access */ -return NULL ; - } - - haddr = addr + tlbentry->addend; -return (void *)haddr; -#endif /* defined(CONFIG_USER_ONLY) */ } +#else +void *tlb_vaddr_to_host (CPUArchState *env,abi_ptr addr, +MMUAccessType access_type,int mmu_idx); +#endif #endif /* CPU_LDST_H */
accel/tcg/cputlb.c +61 -8
87 lines not on this page · raw message
target/arm/sve_helper.c +1 -5
@@ -4598,11 +4598,7 @@ static void sve_ldnf1_r(CPUARMState *env, void *vg, const target_ulong addr,* in the real world, obviously.) * * Then there are the annoying special cases with watchpoints... -* -* TODO: Add a form of tlb_fill that does not raise an exception, -* with a form of tlb_vaddr_to_host and a set of loads to match. -* The non_fault_vaddr_to_host would handle everything, usually, -* and the loads would handle the iomem path for watchpoints. +* TODO: Add a form of non-faulting loads using cc->tlb_fill(probe=true). */ host =tlb_vaddr_to_host (env, addr + mem_off,MMU_DATA_LOAD , mmu_idx); split =max_for_page (addr, mem_off, mem_max);
Signature · 1 line
2.17.1