[4450] CRIS: Improve TLB management and handle delayslots at page boundaries.
Revision: 4450
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4450 Author: edgar_igl Date: 2008-05-13 10:59:14 +0000 (Tue, 13 May 2008)
Log Message:
-----------
CRIS: Improve TLB management and handle delayslots at page boundaries.
* Dont flush the entire qemu tlb when the $pid changes. Instead we go through the guests TLB and choose entries that need to be flushed.
* Add env->dslot and handle delayslots at pageboundaries.
* Remove some unused code.
Modified Paths:
--------------
trunk/cpu-exec.c
trunk/target-cris/cpu.h
trunk/target-cris/helper.c
trunk/target-cris/helper.h
trunk/target-cris/mmu.c
trunk/target-cris/mmu.h
trunk/target-cris/op_helper.c
trunk/target-cris/translate.c
Modified: trunk/cpu-exec.c
===================================================================
cpu-exec.c +1 -0
@@ -261,6 +261,7 @@ pc = env->pc;#elif defined(TARGET_CRIS ) flags = env->pregs[PR_CCS ] &U_FLAG ; + flags |= env->dslot; cs_base =0 ; pc = env->pc;#else
Modified: trunk/target-cris/cpu.h
===================================================================
target-cris/cpu.h +3 -13
@@ -107,11 +107,10 @@/* Pseudo register for the kernel stack. */ uint32_t ksp; -/* These are setup up by the guest code just before transfering the -control back to the host. */ -int jmp; -uint32_t btarget; +/* Branch. */ +int dslot;int btaken; +uint32_t btarget;/* Condition flag tracking. */ uint32_t cc_op;
@@ -119,10 +118,8 @@uint32_t cc_dest;uint32_t cc_src;uint32_t cc_result; -/* size of the operation, 1 = byte, 2 = word, 4 = dword. */ int cc_size; -/* Extended arithmetics. */ int cc_x_live;int cc_x;
@@ -137,13 +134,6 @@uint32_t debug2;uint32_t debug3; -struct - { -int exec_insns; -int exec_loads; -int exec_stores; - } stats; -/* FIXME: add a check in the translator to avoid writing to support register sets beyond the 4th. The ISA allows up to 256! but in practice there is no core that implements more than 4.
Modified: trunk/target-cris/helper.c
===================================================================
target-cris/helper.c +13 -6
@@ -97,9 +97,10 @@ r =tlb_set_page (env, address, phy, prot, mmu_idx, is_softmmu); }if (r >0 ) -D (fprintf (logfile,"%s returns %d irqreq=%x addr=%x ismmu=%d vec=%x\n" , - __func__, r, env->interrupt_request, - address, is_softmmu, res.bf_vec)); +D (fprintf (logfile,"%s returns %d irqreq=%x addr=%x" +" phy=%x ismmu=%d vec=%x pc=%x\n" , + __func__, r, env->interrupt_request, + address, res.phy, is_softmmu, res.bf_vec, env->pc));return r; }
@@ -138,13 +139,19 @@break ; } -if ((env->pregs[PR_CCS ] &U_FLAG )) { -D (fprintf (logfile,"excp isr=%x PC=%x SP=%x ERP=%x pid=%x ccs=%x cc=%d %x\n" , - ex_vec, env->pc, +if (env->dslot) { +D (fprintf (logfile,"excp isr=%x PC=%x ds=%d SP=%x" +" ERP=%x pid=%x ccs=%x cc=%d %x\n" , + ex_vec, env->pc, env->dslot, env->regs[R_SP ], env->pregs[PR_ERP ], env->pregs[PR_PID ], env->pregs[PR_CCS ], env->cc_op, env->cc_mask)); +/* We loose the btarget, btaken state here so rexec the +branch. */ + env->pregs[PR_ERP ] -= env->dslot; +/* Exception starts with dslot cleared. */ + env->dslot =0 ; } env->pc =ldl_code (env->pregs[PR_EBP ] + ex_vec *4 );
Modified: trunk/target-cris/helper.h
===================================================================
target-cris/helper.h +1 -0
@@ -1,6 +1,7 @@#define TCG_HELPER_PROTO void TCG_HELPER_PROTO helper_raise_exception(uint32_t index); +void TCG_HELPER_PROTO helper_tlb_flush_pid(uint32_t pid); void TCG_HELPER_PROTO helper_tlb_flush(void); void TCG_HELPER_PROTO helper_dump(uint32_t a0, uint32_t a1, uint32_t a2); void TCG_HELPER_PROTO helper_dummy(void);
Modified: trunk/target-cris/mmu.c
===================================================================
target-cris/mmu.c +36 -15
72 lines not on this page · raw message
Modified: trunk/target-cris/mmu.h
===================================================================
target-cris/mmu.h +1 -1
@@ -11,7 +11,7 @@int bf_vec; }; -target_ulong cris_mmu_tlb_latest_update (CPUState *env); +void cris_mmu_flush_pid (CPUState *env,uint32_t pid);int cris_mmu_translate (struct cris_mmu_result_t *res,CPUState *env,uint32_t vaddr,int rw,int mmu_idx);
Modified: trunk/target-cris/op_helper.c
===================================================================
target-cris/op_helper.c +23 -4
@@ -85,6 +85,13 @@cpu_loop_exit (); } +void helper_tlb_flush_pid (uint32_t pid) +{ +#if !defined(CONFIG_USER_ONLY ) +cris_mmu_flush_pid (env, pid); +#endif +} +void helper_tlb_flush (void ) {tlb_flush (env,1 );
@@ -100,6 +107,10 @@ } +/* Used by the tlb decoder. */ +#define EXTRACT_FIELD (src, start, end) \ + (((src) >> start) & ((1 << (end - start + 1)) - 1)) +void helper_movl_sreg_reg (uint32_t sreg,uint32_t reg) {uint32_t srs;
@@ -120,11 +131,8 @@uint32_t idx;uint32_t lo, hi;uint32_t vaddr; +int tlb_v; - vaddr =cris_mmu_tlb_latest_update (env); -D (fprintf (logfile,"tlb flush vaddr=%x\n" , vaddr)); -tlb_flush_page (env, vaddr); - idx = set = env->sregs[SFR_RW_MM_TLB_SEL ]; set >>=4 ; set &=3 ;
@@ -134,8 +142,19 @@ lo = env->sregs[SFR_RW_MM_TLB_LO ];/* Writes are done via r_mm_cause. */ hi = env->sregs[SFR_R_MM_CAUSE ]; + + vaddr =EXTRACT_FIELD (env->tlbsets[srs-1 ][set][idx].hi, +13 ,31 ); + vaddr <<=TARGET_PAGE_BITS ; + tlb_v =EXTRACT_FIELD (env->tlbsets[srs-1 ][set][idx].lo, +3 ,3 ); env->tlbsets[srs -1 ][set][idx].lo = lo; env->tlbsets[srs -1 ][set][idx].hi = hi; + +D (fprintf (logfile, +"tlb flush vaddr=%x v=%d pc=%x\n" , + vaddr, tlb_v, env->pc)); + tlb_flush_page(env, vaddr); } }#endif
Modified: trunk/target-cris/translate.c
===================================================================
target-cris/translate.c +116 -99
503 lines not on this page · raw message