Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HTN6p-0002Zv-4K for qemu-devel@nongnu.org; Mon, 19 Mar 2007 15:01:31 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HTN6n-0002Zb-Nu for qemu-devel@nongnu.org; Mon, 19 Mar 2007 15:01:30 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HTN6n-0002ZY-HN for qemu-devel@nongnu.org; Mon, 19 Mar 2007 14:01:29 -0500 Received: from farad.aurel32.net ([82.232.2.251] helo=mail.aurel32.net) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HTN5J-0003hs-8M for qemu-devel@nongnu.org; Mon, 19 Mar 2007 14:59:57 -0400 Received: from amd64.aurel32.net ([2001:618:400:fc13:216:3eff:fe00:1009]) by mail.aurel32.net with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1HTN5D-00005F-B8 for qemu-devel@nongnu.org; Mon, 19 Mar 2007 19:59:51 +0100 Received: from aurel32 by amd64.aurel32.net with local (Exim 4.63) (envelope-from ) id 1HTN5D-00033X-4R for qemu-devel@nongnu.org; Mon, 19 Mar 2007 19:59:51 +0100 Date: Mon, 19 Mar 2007 19:59:51 +0100 From: Aurelien Jarno Message-ID: <20070319185950.GA11742@amd64.aurel32.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Subject: [Qemu-devel] [PATCH] Implement division by 0 trap on the Sparc target 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 all, A division by 0 currently does not generate a trap on the Sparc target, instead it crashes QEMU. The patch below fixes that. Bye, Aurelien Index: target-sparc/op.c =================================================================== RCS file: /sources/qemu/qemu/target-sparc/op.c,v retrieving revision 1.24 diff -u -d -p -r1.24 op.c --- target-sparc/op.c 10 Feb 2007 22:58:02 -0000 1.24 +++ target-sparc/op.c 19 Mar 2007 18:49:20 -0000 @@ -671,6 +671,11 @@ void OPPROTO op_udiv_T1_T0(void) x0 = T0 | ((uint64_t) (env->y) << 32); x1 = T1; + + if (x1 == 0) { + raise_exception(TT_DIV_ZERO); + } + x0 = x0 / x1; if (x0 > 0xffffffff) { T0 = 0xffffffff; @@ -689,6 +694,11 @@ void OPPROTO op_sdiv_T1_T0(void) x0 = T0 | ((int64_t) (env->y) << 32); x1 = T1; + + if (x1 == 0) { + raise_exception(TT_DIV_ZERO); + } + x0 = x0 / x1; if ((int32_t) x0 != x0) { T0 = x0 < 0? 0x80000000: 0x7fffffff; -- .''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' aurel32@debian.org | aurelien@aurel32.net `- people.debian.org/~aurel32 | www.aurel32.net