From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JxGzo-0008S1-1i for qemu-devel@nongnu.org; Sat, 17 May 2008 03:38:24 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JxGzm-0008Rp-Hg for qemu-devel@nongnu.org; Sat, 17 May 2008 03:38:22 -0400 Received: from [199.232.76.173] (port=54816 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JxGzm-0008Rm-CQ for qemu-devel@nongnu.org; Sat, 17 May 2008 03:38:22 -0400 Received: from savannah.gnu.org ([199.232.41.3]:43717 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 1JxGzl-0007lQ-U6 for qemu-devel@nongnu.org; Sat, 17 May 2008 03:38:22 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1JxGzj-0001uA-Dh for qemu-devel@nongnu.org; Sat, 17 May 2008 07:38:19 +0000 Received: from blueswir1 by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1JxGzh-0001ty-9e for qemu-devel@nongnu.org; Sat, 17 May 2008 07:38:18 +0000 MIME-Version: 1.0 Errors-To: blueswir1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Blue Swirl Message-Id: Date: Sat, 17 May 2008 07:38:17 +0000 Subject: [Qemu-devel] [4465] Improved workaround for the annoying glibc global register mangling bug 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: 4465 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4465 Author: blueswir1 Date: 2008-05-17 07:38:10 +0000 (Sat, 17 May 2008) Log Message: ----------- Improved workaround for the annoying glibc global register mangling bug Modified Paths: -------------- trunk/cpu-exec.c Modified: trunk/cpu-exec.c =================================================================== --- trunk/cpu-exec.c 2008-05-17 06:08:15 UTC (rev 4464) +++ trunk/cpu-exec.c 2008-05-17 07:38:10 UTC (rev 4465) @@ -37,53 +37,18 @@ #include #endif +#if defined(__sparc__) && !defined(HOST_SOLARIS) +// Work around ugly bugs in glibc that mangle global register contents +#undef env +#define env cpu_single_env +#endif + int tb_invalidated_flag; static unsigned long next_tb; //#define DEBUG_EXEC //#define DEBUG_SIGNAL -#define SAVE_GLOBALS() -#define RESTORE_GLOBALS() - -#if defined(__sparc__) && !defined(HOST_SOLARIS) -#include -#if defined(__GLIBC__) && ((__GLIBC__ < 2) || \ - ((__GLIBC__ == 2) && (__GLIBC_MINOR__ <= 90))) -// Work around ugly bugs in glibc that mangle global register contents - -static volatile void *saved_env; -#undef SAVE_GLOBALS -#define SAVE_GLOBALS() do { \ - saved_env = env; \ - } while(0) - -#undef RESTORE_GLOBALS -#define RESTORE_GLOBALS() do { \ - env = (void *)saved_env; \ - } while(0) - -static int sparc_setjmp(jmp_buf buf) -{ - int ret; - - SAVE_GLOBALS(); - ret = setjmp(buf); - RESTORE_GLOBALS(); - return ret; -} -#undef setjmp -#define setjmp(jmp_buf) sparc_setjmp(jmp_buf) - -static void sparc_longjmp(jmp_buf buf, int val) -{ - SAVE_GLOBALS(); - longjmp(buf, val); -} -#define longjmp(jmp_buf, val) sparc_longjmp(jmp_buf, val) -#endif -#endif - void cpu_loop_exit(void) { /* NOTE: the register at this point must be saved by hand because @@ -176,9 +141,7 @@ tb->tc_ptr = tc_ptr; tb->cs_base = cs_base; tb->flags = flags; - SAVE_GLOBALS(); cpu_gen_code(env, tb, &code_gen_size); - RESTORE_GLOBALS(); code_gen_ptr = (void *)(((unsigned long)code_gen_ptr + code_gen_size + CODE_GEN_ALIGN - 1) & ~(CODE_GEN_ALIGN - 1)); /* check next page if needed */ @@ -302,7 +265,6 @@ #define SAVE_HOST_REGS 1 #include "hostregs_helper.h" env = env1; - SAVE_GLOBALS(); env_to_regs(); #if defined(TARGET_I386) @@ -414,7 +376,6 @@ next_tb = 0; /* force lookup of first TB */ for(;;) { - SAVE_GLOBALS(); interrupt_request = env->interrupt_request; if (__builtin_expect(interrupt_request, 0) #if defined(TARGET_I386) @@ -633,7 +594,6 @@ lookup_symbol(tb->pc)); } #endif - RESTORE_GLOBALS(); /* see if we can patch the calling TB. When the TB spans two pages, we cannot safely do a direct jump. */ @@ -651,6 +611,11 @@ tc_ptr = tb->tc_ptr; env->current_tb = tb; /* execute the generated code */ +#if defined(__sparc__) && !defined(HOST_SOLARIS) +#undef env + env = cpu_single_env; +#define env cpu_single_env +#endif next_tb = tcg_qemu_tb_exec(tc_ptr); env->current_tb = NULL; /* reset soft MMU for next block (it can currently @@ -701,7 +666,6 @@ #endif /* restore global registers */ - RESTORE_GLOBALS(); #include "hostregs_helper.h" /* fail safe : never use cpu_single_env outside cpu_exec() */