Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FWusF-0007xy-Rw for qemu-devel@nongnu.org; Fri, 21 Apr 2006 08:36:35 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FWusC-0007wx-Vo for qemu-devel@nongnu.org; Fri, 21 Apr 2006 08:36:35 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FWusC-0007wu-QZ for qemu-devel@nongnu.org; Fri, 21 Apr 2006 08:36:32 -0400 Received: from [194.84.254.251] (helo=mx.globalone.ru) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1FWutk-0001ie-Qy for qemu-devel@nongnu.org; Fri, 21 Apr 2006 08:38:09 -0400 Received: from mx.globalone.ru (localhost [127.0.0.1]) by mx.globalone.ru (8.13.1/8.13.1) with ESMTP id k3LCaMPB030839 for ; Fri, 21 Apr 2006 16:36:22 +0400 Received: from smtp.globalone.ru (smtp.globalone.ru [172.16.38.5]) by mx.globalone.ru (8.13.1/8.13.1) with ESMTP id k3LCa4eH030812 for ; Fri, 21 Apr 2006 16:36:04 +0400 Received: from voropaya ([172.16.38.7]) by smtp.globalone.ru (Netscape Messaging Server 4.15) with SMTP id IY2OC300.6T7 for ; Fri, 21 Apr 2006 16:36:03 +0400 Message-ID: <3bc401c66540$2738bd20$e90d11ac@spb.in.rosprint.ru> From: "Alexander Voropay" References: <154e01c66453$111e4f20$e90d11ac@spb.in.rosprint.ru><20060420102851.GE30806@networkno.de><363201c66469$f9bd8a50$e90d11ac@spb.in.rosprint.ru> <36f901c66474$b40d6b00$e90d11ac@spb.in.rosprint.ru> Subject: Re: [Qemu-devel] CP0 after reset bug (Was: Add MIPS ELF loader) Date: Fri, 21 Apr 2006 16:35:59 +0400 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit Reply-To: Alexander Voropay , 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 "Alexander Voropay" wrote: > Another issue: > > IN: > 0xbfc00424: mtc0 zero,$13 > 0x0001: raise_exception 0x11 The problem is a code *before* this : ========== mfc0 v0,C0_SR and v0,SR_SR # preserve Soft Reset or v0,SR_BEV # set Boot Exceptions mtc0 v0,C0_SR # 32 bit, kernel mode, bootstrap mtc0 zero,C0_CAUSE # <-- TRAP there !!! ========== This code is a cut'n'paste from the "See MIPS Run" p.338 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). -- -=AV=-