qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] Implement division by 0 trap on the Sparc target


From: Aurelien Jarno
Subject: [Qemu-devel] [PATCH] Implement division by 0 trap on the Sparc target
Date: Mon, 19 Mar 2007 19:59:51 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

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
 `. `'   address@hidden         | address@hidden
   `-    people.debian.org/~aurel32 | www.aurel32.net




reply via email to

[Prev in Thread] Current Thread [Next in Thread]