From: Blue Swirl <blauwirbel@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [4465] Improved workaround for the annoying glibc global register mangling bug
Date: Sat, 17 May 2008 07:38:17 +0000 [thread overview]
Message-ID: <E1JxGzh-0001ty-9e@cvs.savannah.gnu.org> (raw)
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 <sys/ucontext.h>
#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 <features.h>
-#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() */
reply other threads:[~2008-05-17 7:38 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=E1JxGzh-0001ty-9e@cvs.savannah.gnu.org \
--to=blauwirbel@gmail.com \
--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).