Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kev6m-0002v6-65 for qemu-devel@nongnu.org; Sun, 14 Sep 2008 13:10:00 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kev6l-0002uY-IQ for qemu-devel@nongnu.org; Sun, 14 Sep 2008 13:09:59 -0400 Received: from [199.232.76.173] (port=52820 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kev6l-0002uT-88 for qemu-devel@nongnu.org; Sun, 14 Sep 2008 13:09:59 -0400 Received: from hall.aurel32.net ([91.121.138.14]:55752) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Kev6k-0004fq-OW for qemu-devel@nongnu.org; Sun, 14 Sep 2008 13:09:58 -0400 Received: from volta.aurel32.net ([2002:52e8:2fb:1:21e:8cff:feb0:693b]) by hall.aurel32.net with esmtpsa (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1Kev6j-00081S-DQ for qemu-devel@nongnu.org; Sun, 14 Sep 2008 19:09:57 +0200 Received: from aurel32 by volta.aurel32.net with local (Exim 4.69) (envelope-from ) id 1Kev6i-0002XT-M4 for qemu-devel@nongnu.org; Sun, 14 Sep 2008 19:09:56 +0200 Date: Sun, 14 Sep 2008 19:09:56 +0200 From: Aurelien Jarno Subject: Re: [Qemu-devel] [PATCH] MIPS: Fix tlbwi/tlbwr Message-ID: <20080914170956.GG22422@volta.aurel32.net> References: <48C43B8B.1050407@reactos.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <48C43B8B.1050407@reactos.org> 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 On Sun, Sep 07, 2008 at 10:37:31PM +0200, Hervé Poussineau wrote: > Hi, > > In CP0 Index register, bit 31 means 'Probe Failure', while lowest bits > contain the TLB index. > In tlbwi and tlbwr instructions, this Probe Failure bit must be ignored > when reading the TLB index. > Attached patch fixes it. Applied, thanks. > Hervé > Index: target-mips/op_helper.c > =================================================================== > --- target-mips/op_helper.c (revision 5162) > +++ target-mips/op_helper.c (working copy) > @@ -1572,13 +1572,17 @@ > > void r4k_do_tlbwi (void) > { > + int idx; > + > + idx = (env->CP0_Index & ~0x80000000) % env->tlb->nb_tlb; > + > /* Discard cached TLB entries. We could avoid doing this if the > tlbwi is just upgrading access permissions on the current entry; > that might be a further win. */ > r4k_mips_tlb_flush_extra (env, env->tlb->nb_tlb); > > - r4k_invalidate_tlb(env, env->CP0_Index % env->tlb->nb_tlb, 0); > - r4k_fill_tlb(env->CP0_Index % env->tlb->nb_tlb); > + r4k_invalidate_tlb(env, idx, 0); > + r4k_fill_tlb(idx); > } > > void r4k_do_tlbwr (void) > @@ -1635,9 +1639,11 @@ > { > r4k_tlb_t *tlb; > uint8_t ASID; > + int idx; > > ASID = env->CP0_EntryHi & 0xFF; > - tlb = &env->tlb->mmu.r4k.tlb[env->CP0_Index % env->tlb->nb_tlb]; > + idx = (env->CP0_Index & ~0x80000000) % env->tlb->nb_tlb; > + tlb = &env->tlb->mmu.r4k.tlb[idx]; > > /* If this will change the current ASID, flush qemu's TLB. */ > if (ASID != tlb->ASID) -- .''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' aurel32@debian.org | aurelien@aurel32.net `- people.debian.org/~aurel32 | www.aurel32.net