From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K04Da-0005qn-Gp for qemu-devel@nongnu.org; Sat, 24 May 2008 20:36:10 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K04Da-0005pk-2g for qemu-devel@nongnu.org; Sat, 24 May 2008 20:36:10 -0400 Received: from [199.232.76.173] (port=42650 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K04DZ-0005pY-Le for qemu-devel@nongnu.org; Sat, 24 May 2008 20:36:09 -0400 Received: from savannah.gnu.org ([199.232.41.3]:41694 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1K04DZ-0000IZ-IP for qemu-devel@nongnu.org; Sat, 24 May 2008 20:36:09 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1K04DX-0003wi-Mo for qemu-devel@nongnu.org; Sun, 25 May 2008 00:36:08 +0000 Received: from pbrook by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1K04DX-0003wc-2Y for qemu-devel@nongnu.org; Sun, 25 May 2008 00:36:07 +0000 MIME-Version: 1.0 Errors-To: pbrook Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Paul Brook Message-Id: Date: Sun, 25 May 2008 00:36:07 +0000 Subject: [Qemu-devel] [4570] Fix off-by-one unwinding error. 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 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);