From: Stefan Weil <weil@mail.berlios.de>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] Fix overflow conditions for MIPS add / subtract
Date: Thu, 13 Apr 2006 20:49:19 +0200 [thread overview]
Message-ID: <443E9D2F.5050807@mail.berlios.de> (raw)
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();
next reply other threads:[~2006-04-13 18:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-13 18:49 Stefan Weil [this message]
2006-04-28 13:28 ` [Qemu-devel] [PATCH] Fix overflow conditions for MIPS add / subtract Daniel Jacobowitz
2006-04-28 14:51 ` Dirk Behme
2006-04-28 15:47 ` Daniel Jacobowitz
2006-04-28 15:52 ` Julian Seward
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=443E9D2F.5050807@mail.berlios.de \
--to=weil@mail.berlios.de \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).