From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FWv7k-0000Ey-Mw for qemu-devel@nongnu.org; Fri, 21 Apr 2006 08:52:36 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FWv7i-0000Em-WB for qemu-devel@nongnu.org; Fri, 21 Apr 2006 08:52:36 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FWv7i-0000Ej-To for qemu-devel@nongnu.org; Fri, 21 Apr 2006 08:52:34 -0400 Received: from [193.7.176.20] (helo=bender.bawue.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.52) id 1FWv9H-0003Hh-Aq for qemu-devel@nongnu.org; Fri, 21 Apr 2006 08:54:11 -0400 Date: Fri, 21 Apr 2006 13:51:55 +0100 Subject: Re: [Qemu-devel] CP0 after reset bug (Was: Add MIPS ELF loader) Message-ID: <20060421125154.GK10665@networkno.de> References: <36f901c66474$b40d6b00$e90d11ac@spb.in.rosprint.ru> <3bc401c66540$2738bd20$e90d11ac@spb.in.rosprint.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3bc401c66540$2738bd20$e90d11ac@spb.in.rosprint.ru> From: Thiemo Seufer Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Voropay , qemu-devel@nongnu.org Alexander Voropay wrote: [snip] > Unfortunately, this code clears CU0 bits in the CP0(SR). > It makes CP0 unusable for program and causes an exception 11 : > Coprocessor Unusable on the next CP0 access. > > The Qemu has a bug there. The "See MIPS Run" p.51 states: > > CU0 - Coprocessor 0 usable; Set 1 to be able to use some nominally > priveleged instructions in the user mode. You don't want to do this. > The CPU control instructions encoded as coprocessor 0 type are > always usable in kernel mode, regardless of the setting of this bit. > > Qemu does simply check: > ./target-mips/translate.c:1181 > =================== > if (!(ctx->CP0_Status & (1 << CP0St_CU0)) && > !(ctx->hflags & MIPS_HFLAG_UM) && > !(ctx->hflags & MIPS_HFLAG_ERL) && > !(ctx->hflags & MIPS_HFLAG_EXL)) { > if (loglevel & CPU_LOG_TB_IN_ASM) { > fprintf(logfile, "CP0 is not usable\n"); > } > generate_exception_err (ctx, EXCP_CpU, 0); > return; > =================== > > This check is not enought to emulate a Coprocessor Unusable > situation on Reset (when CPU is in the kernel mode). A patch which doesn't negate the HFLAGS_UM check fixes this and was posted here a while ago. Thiemo