Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JtIVS-0000R9-9a for qemu-devel@nongnu.org; Tue, 06 May 2008 04:26:38 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JtIVP-0000P0-SV for qemu-devel@nongnu.org; Tue, 06 May 2008 04:26:35 -0400 Received: from [199.232.76.173] (port=47938 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JtIVO-0000Oc-Qg for qemu-devel@nongnu.org; Tue, 06 May 2008 04:26:35 -0400 Received: from savannah.gnu.org ([199.232.41.3] helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JtIVO-0006uh-Po for qemu-devel@nongnu.org; Tue, 06 May 2008 04:26:34 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1JtIAD-0002J7-Ja for qemu-devel@nongnu.org; Tue, 06 May 2008 08:04:41 +0000 Received: from edgar_igl by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1JtIAD-0002J2-Df for qemu-devel@nongnu.org; Tue, 06 May 2008 08:04:41 +0000 MIME-Version: 1.0 Errors-To: edgar_igl Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: "Edgar E. Iglesias" Message-Id: Date: Tue, 06 May 2008 08:04:41 +0000 Subject: [Qemu-devel] [4349] CRIS MMU Updates Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 4349 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4349 Author: edgar_igl Date: 2008-05-06 08:04:40 +0000 (Tue, 06 May 2008) Log Message: ----------- CRIS MMU Updates * Add support for exec faults and for the k protection bit. * Abort if search_pc causes recursive mmu faults. Modified Paths: -------------- trunk/target-cris/helper.c trunk/target-cris/mmu.c trunk/target-cris/op_helper.c Modified: trunk/target-cris/helper.c =================================================================== --- trunk/target-cris/helper.c 2008-05-05 21:42:19 UTC (rev 4348) +++ trunk/target-cris/helper.c 2008-05-06 08:04:40 UTC (rev 4349) @@ -79,6 +79,12 @@ miss = cris_mmu_translate(&res, env, address, rw, mmu_idx); if (miss) { + if (env->exception_index == EXCP_MMU_FAULT) + cpu_abort(env, + "CRIS: Illegal recursive bus fault." + "addr=%x rw=%d\n", + address, rw); + env->exception_index = EXCP_MMU_FAULT; env->fault_vector = res.bf_vec; r = 1; @@ -101,7 +107,7 @@ { int ex_vec = -1; - D(fprintf (stderr, "exception index=%d interrupt_req=%d\n", + D(fprintf (logfile, "exception index=%d interrupt_req=%d\n", env->exception_index, env->interrupt_request)); @@ -133,8 +139,9 @@ } if ((env->pregs[PR_CCS] & U_FLAG)) { - D(fprintf(logfile, "excp isr=%x PC=%x ERP=%x pid=%x ccs=%x cc=%d %x\n", + D(fprintf(logfile, "excp isr=%x PC=%x SP=%x ERP=%x pid=%x ccs=%x cc=%d %x\n", ex_vec, env->pc, + env->regs[R_SP], env->pregs[PR_ERP], env->pregs[PR_PID], env->pregs[PR_CCS], env->cc_op, env->cc_mask)); Modified: trunk/target-cris/mmu.c =================================================================== --- trunk/target-cris/mmu.c 2008-05-05 21:42:19 UTC (rev 4348) +++ trunk/target-cris/mmu.c 2008-05-06 08:04:40 UTC (rev 4349) @@ -32,12 +32,12 @@ #define D(x) -static int cris_mmu_enabled(uint32_t rw_gc_cfg) +static inline int cris_mmu_enabled(uint32_t rw_gc_cfg) { return (rw_gc_cfg & 12) != 0; } -static int cris_mmu_segmented_addr(int seg, uint32_t rw_mm_cfg) +static inline int cris_mmu_segmented_addr(int seg, uint32_t rw_mm_cfg) { return (1 << seg) & rw_mm_cfg; } @@ -187,17 +187,28 @@ set_exception_vector(0x0a, d_mmu_access); set_exception_vector(0x0b, d_mmu_write); */ - if (!tlb_g + if (!tlb_g && tlb_pid != (env->pregs[PR_PID] & 0xff)) { D(printf ("tlb: wrong pid %x %x pc=%x\n", tlb_pid, env->pregs[PR_PID], env->pc)); match = 0; res->bf_vec = vect_base; + } else if (cfg_k && tlb_k && usermode) { + D(printf ("tlb: kernel protected %x lo=%x pc=%x\n", + vaddr, lo, env->pc)); + match = 0; + res->bf_vec = vect_base + 2; } else if (rw == 1 && cfg_w && !tlb_w) { - D(printf ("tlb: write protected %x lo=%x\n", - vaddr, lo)); + D(printf ("tlb: write protected %x lo=%x pc=%x\n", + vaddr, lo, env->pc)); match = 0; + /* write accesses never go through the I mmu. */ res->bf_vec = vect_base + 3; + } else if (rw == 2 && cfg_x && !tlb_x) { + D(printf ("tlb: exec protected %x lo=%x pc=%x\n", + vaddr, lo, env->pc)); + match = 0; + res->bf_vec = vect_base + 3; } else if (cfg_v && !tlb_v) { D(printf ("tlb: invalid %x\n", vaddr)); set_field(&r_cause, rwcause, 8, 9); Modified: trunk/target-cris/op_helper.c =================================================================== --- trunk/target-cris/op_helper.c 2008-05-05 21:42:19 UTC (rev 4348) +++ trunk/target-cris/op_helper.c 2008-05-06 08:04:40 UTC (rev 4349) @@ -60,8 +60,8 @@ saved_env = env; env = cpu_single_env; - D(fprintf(logfile, "%s ra=%x acr=%x %x\n", __func__, retaddr, - env->regs[R_ACR], saved_env->regs[R_ACR])); + D(fprintf(logfile, "%s pc=%x tpc=%x ra=%x\n", __func__, + env->pc, env->debug1, retaddr)); ret = cpu_cris_handle_mmu_fault(env, addr, is_write, mmu_idx, 1); if (__builtin_expect(ret, 0)) { if (retaddr) { @@ -89,7 +89,7 @@ return; vaddr = cris_mmu_tlb_latest_update(env, T0); - D(printf("flush old_vaddr=%x vaddr=%x T0=%x\n", vaddr, + D(fprintf(logfile, "flush old_vaddr=%x vaddr=%x T0=%x\n", vaddr, env->sregs[SFR_R_MM_CAUSE] & TARGET_PAGE_MASK, T0)); tlb_flush_page(env, vaddr); #endif