From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FU6vE-000172-Uv for qemu-devel@nongnu.org; Thu, 13 Apr 2006 14:52:05 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FU6vB-00014l-Ak for qemu-devel@nongnu.org; Thu, 13 Apr 2006 14:52:03 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FU6vA-00014e-QD for qemu-devel@nongnu.org; Thu, 13 Apr 2006 14:52:00 -0400 Received: from [212.227.126.187] (helo=moutng.kundenserver.de) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FU70X-00047p-Jf for qemu-devel@nongnu.org; Thu, 13 Apr 2006 14:57:33 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) by flubber.weilnetz.de (Postfix) with ESMTP id 7C7C3F2C46 for ; Thu, 13 Apr 2006 20:49:20 +0200 (CEST) Message-ID: <443E9D2F.5050807@mail.berlios.de> Date: Thu, 13 Apr 2006 20:49:19 +0200 From: Stefan Weil MIME-Version: 1.0 Subject: [Qemu-devel] [PATCH] Fix overflow conditions for MIPS add / subtract Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit 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 Hi, I had problems with MIPS system emulation (AR7 based DSL router) which were caused by wrong overflow exceptions. With the patch given below emulation works. See this link for first results: http://forum.openwrt.org/viewtopic.php?id=4381 In user mode emulation, the MIPS emulation currently ignores exceptions. So the bug might have an effect on emulation speed but not on functionality for user mode emulation. Regards Stefan Weil PS. Please include this and also my last MIPS patch in CVS HEAD. Index: target-mips/op.c =================================================================== RCS file: /sources/qemu/qemu/target-mips/op.c,v retrieving revision 1.5 diff -u -b -B -r1.5 op.c --- target-mips/op.c 5 Dec 2005 19:59:36 -0000 1.5 +++ target-mips/op.c 13 Apr 2006 18:38:19 -0000 @@ -206,7 +206,8 @@ tmp = T0; T0 += T1; - if ((T0 >> 31) ^ (T1 >> 31) ^ (tmp >> 31)) { + if (((tmp ^ T1 ^ (-1)) & (T0 ^ T1)) >> 31) { + /* operands of same sign, result different sign */ CALL_FROM_TB1(do_raise_exception_direct, EXCP_OVERFLOW); } RETURN(); @@ -224,7 +225,8 @@ tmp = T0; T0 = (int32_t)T0 - (int32_t)T1; - if (!((T0 >> 31) ^ (T1 >> 31) ^ (tmp >> 31))) { + if (((tmp ^ T1) & (tmp ^ T0)) >> 31) { + /* operands of different sign, first operand and result different sign */ CALL_FROM_TB1(do_raise_exception_direct, EXCP_OVERFLOW); } RETURN();