qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paul Brook <paul@nowt.org>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [4570] Fix off-by-one unwinding error.
Date: Sun, 25 May 2008 00:36:07 +0000	[thread overview]
Message-ID: <E1K04DX-0003wc-2Y@cvs.savannah.gnu.org> (raw)

Revision: 4570
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4570
Author:   pbrook
Date:     2008-05-25 00:36:06 +0000 (Sun, 25 May 2008)

Log Message:
-----------
Fix off-by-one unwinding error.

Modified Paths:
--------------
    trunk/dyngen-exec.h
    trunk/target-alpha/op_helper.c
    trunk/target-arm/op_helper.c
    trunk/target-cris/op_helper.c
    trunk/target-i386/helper.c
    trunk/target-m68k/op_helper.c
    trunk/target-mips/op_helper.c
    trunk/target-ppc/op_helper.c
    trunk/target-sh4/op_helper.c
    trunk/target-sparc/op_helper.c
    trunk/tcg/arm/tcg-target.c

Modified: trunk/dyngen-exec.h
===================================================================
--- trunk/dyngen-exec.h	2008-05-25 00:14:34 UTC (rev 4569)
+++ trunk/dyngen-exec.h	2008-05-25 00:36:06 UTC (rev 4570)
@@ -287,4 +287,16 @@
 #error unsupported CPU
 #endif
 
+/* The return address may point to the start of the next instruction.
+   Subtracting one gets us the call instruction itself.  */
+#if defined(__s390__)
+# define GETPC() ((void*)(((unsigned long)__builtin_return_address(0) & 0x7fffffffUL) - 1))
+#elif defined(__arm__)
+/* Thumb return addresses have the low bit set, so we need to subtract two.
+   This is still safe in ARM mode because instructions are 4 bytes.  */
+# define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 2))
+#else
+# define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 1))
+#endif
+
 #endif /* !defined(__DYNGEN_EXEC_H__) */

Modified: trunk/target-alpha/op_helper.c
===================================================================
--- trunk/target-alpha/op_helper.c	2008-05-25 00:14:34 UTC (rev 4569)
+++ trunk/target-alpha/op_helper.c	2008-05-25 00:36:06 UTC (rev 4570)
@@ -1093,12 +1093,6 @@
 /* Softmmu support */
 #if !defined (CONFIG_USER_ONLY)
 
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
-
 /* XXX: the two following helpers are pure hacks.
  *      Hopefully, we emulate the PALcode, then we should never see
  *      HW_LD / HW_ST instructions.

Modified: trunk/target-arm/op_helper.c
===================================================================
--- trunk/target-arm/op_helper.c	2008-05-25 00:14:34 UTC (rev 4569)
+++ trunk/target-arm/op_helper.c	2008-05-25 00:36:06 UTC (rev 4570)
@@ -68,11 +68,6 @@
 #if !defined(CONFIG_USER_ONLY)
 
 #define MMUSUFFIX _mmu
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
 
 #define SHIFT 0
 #include "softmmu_template.h"

Modified: trunk/target-cris/op_helper.c
===================================================================
--- trunk/target-cris/op_helper.c	2008-05-25 00:14:34 UTC (rev 4569)
+++ trunk/target-cris/op_helper.c	2008-05-25 00:36:06 UTC (rev 4570)
@@ -24,11 +24,6 @@
 #include "mmu.h"
 
 #define MMUSUFFIX _mmu
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
 
 #define SHIFT 0
 #include "softmmu_template.h"

Modified: trunk/target-i386/helper.c
===================================================================
--- trunk/target-i386/helper.c	2008-05-25 00:14:34 UTC (rev 4569)
+++ trunk/target-i386/helper.c	2008-05-25 00:36:06 UTC (rev 4570)
@@ -4663,11 +4663,6 @@
 #if !defined(CONFIG_USER_ONLY)
 
 #define MMUSUFFIX _mmu
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
 
 #define SHIFT 0
 #include "softmmu_template.h"

Modified: trunk/target-m68k/op_helper.c
===================================================================
--- trunk/target-m68k/op_helper.c	2008-05-25 00:14:34 UTC (rev 4569)
+++ trunk/target-m68k/op_helper.c	2008-05-25 00:36:06 UTC (rev 4570)
@@ -32,11 +32,6 @@
 extern int semihosting_enabled;
 
 #define MMUSUFFIX _mmu
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
 
 #define SHIFT 0
 #include "softmmu_template.h"

Modified: trunk/target-mips/op_helper.c
===================================================================
--- trunk/target-mips/op_helper.c	2008-05-25 00:14:34 UTC (rev 4569)
+++ trunk/target-mips/op_helper.c	2008-05-25 00:36:06 UTC (rev 4570)
@@ -22,12 +22,6 @@
 
 #include "host-utils.h"
 
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
-
 /*****************************************************************************/
 /* Exceptions processing helpers */
 

Modified: trunk/target-ppc/op_helper.c
===================================================================
--- trunk/target-ppc/op_helper.c	2008-05-25 00:14:34 UTC (rev 4569)
+++ trunk/target-ppc/op_helper.c	2008-05-25 00:36:06 UTC (rev 4570)
@@ -2612,11 +2612,6 @@
 #if !defined (CONFIG_USER_ONLY)
 
 #define MMUSUFFIX _mmu
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
 
 #define SHIFT 0
 #include "softmmu_template.h"

Modified: trunk/target-sh4/op_helper.c
===================================================================
--- trunk/target-sh4/op_helper.c	2008-05-25 00:14:34 UTC (rev 4569)
+++ trunk/target-sh4/op_helper.c	2008-05-25 00:36:06 UTC (rev 4570)
@@ -28,11 +28,6 @@
 #ifndef CONFIG_USER_ONLY
 
 #define MMUSUFFIX _mmu
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
 
 #define SHIFT 0
 #include "softmmu_template.h"

Modified: trunk/target-sparc/op_helper.c
===================================================================
--- trunk/target-sparc/op_helper.c	2008-05-25 00:14:34 UTC (rev 4569)
+++ trunk/target-sparc/op_helper.c	2008-05-25 00:36:06 UTC (rev 4570)
@@ -2871,12 +2871,6 @@
 
 #define MMUSUFFIX _mmu
 #define ALIGNED_ONLY
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & \
-                          0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
 
 #define SHIFT 0
 #include "softmmu_template.h"

Modified: trunk/tcg/arm/tcg-target.c
===================================================================
--- trunk/tcg/arm/tcg-target.c	2008-05-25 00:14:34 UTC (rev 4569)
+++ trunk/tcg/arm/tcg-target.c	2008-05-25 00:36:06 UTC (rev 4570)
@@ -1180,7 +1180,6 @@
 
     tcg_out_bl(s, cond, (tcg_target_long) qemu_st_helpers[s_bits] -
                     (tcg_target_long) s->code_ptr);
-
 # if TARGET_LONG_BITS == 64
     if (opc == 3)
         tcg_out_dat_imm(s, cond, ARITH_ADD, 13, 13, 0x10);

                 reply	other threads:[~2008-05-25  0:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=E1K04DX-0003wc-2Y@cvs.savannah.gnu.org \
    --to=paul@nowt.org \
    --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).