qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Implement division by 0 trap on the Sparc target
@ 2007-03-19 18:59 Aurelien Jarno
  0 siblings, 0 replies; only message in thread
From: Aurelien Jarno @ 2007-03-19 18:59 UTC (permalink / raw)
  To: qemu-devel

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-03-19 19:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-19 18:59 [Qemu-devel] [PATCH] Implement division by 0 trap on the Sparc target Aurelien Jarno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).