From: Paolo Bonzini <bonzini@gnu.org>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH 0/2] simplify global register save/restore
Date: Sat, 13 Feb 2010 21:26:42 +0100 [thread overview]
Message-ID: <4B770B02.4030409@gnu.org> (raw)
In-Reply-To: <f43fc5581002130958q17edaf68tf3d66c319059b617@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 472 bytes --]
On 02/13/2010 06:58 PM, Blue Swirl wrote:
> V9 ABI gives more registers to application use.
Except that glibc uses those---in theory, as I see it, it should be
compiled with fixed g2 and g3 to leave them to the application. I get
it now.
It may be possible to make the workaround a big less ugly (I'm thinking
of avoiding #undef/#define by using assembly). I made a patch (see
attachment, just FYI), maybe sometime I'll try it using self-virtualized
qemu.
Paolo
[-- Attachment #2: sparc --]
[-- Type: text/plain, Size: 2730 bytes --]
commit 59ca12838278bed97ce5cc311f90ddfec7953047
Author: Paolo Bonzini <pbonzini@redhat.com>
Date: Sat Feb 13 21:13:12 2010 +0100
make sparc workaround less ugly
Not-quite-signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
diff --git a/cpu-exec.c b/cpu-exec.c
index badd5d7..01b7143 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -39,9 +39,14 @@
#endif
#if defined(__sparc__) && !defined(CONFIG_SOLARIS)
-// Work around ugly bugs in glibc that mangle global register contents
-#undef env
+/* glibc will mangle global register contents. To work around this,
+ * we avoid using the global register in this file, and place back
+ * cpu_single_env in AREG0 before giving control to target-* routines.
+ */
+#define export_env() asm ("mov %0, %%" AREG0 : : "r" (cpu_single_env) : AREG0);
#define env cpu_single_env
+#else
+#define export_env()
#endif
int tb_invalidated_flag;
@@ -257,11 +262,7 @@ int cpu_exec(CPUState *env1)
/* prepare setjmp context for exception handling */
for(;;) {
if (setjmp(env->jmp_env) == 0) {
-#if defined(__sparc__) && !defined(CONFIG_SOLARIS)
-#undef env
- env = cpu_single_env;
-#define env cpu_single_env
-#endif
+ export_env();
/* if an exception is pending, we execute it here */
if (env->exception_index >= 0) {
if (env->exception_index >= EXCP_INTERRUPT) {
@@ -387,11 +388,7 @@ int cpu_exec(CPUState *env1)
env->interrupt_request &= ~(CPU_INTERRUPT_HARD | CPU_INTERRUPT_VIRQ);
intno = cpu_get_pic_interrupt(env);
qemu_log_mask(CPU_LOG_TB_IN_ASM, "Servicing hardware INT=0x%02x\n", intno);
-#if defined(__sparc__) && !defined(CONFIG_SOLARIS)
-#undef env
- env = cpu_single_env;
-#define env cpu_single_env
-#endif
+ export_env();
do_interrupt(intno, 0, 0, 0, 1);
/* ensure that no TB jump will be modified as
the program flow was changed */
@@ -603,12 +600,8 @@ int cpu_exec(CPUState *env1)
if (!unlikely (env->exit_request)) {
env->current_tb = tb;
tc_ptr = tb->tc_ptr;
- /* execute the generated code */
-#if defined(__sparc__) && !defined(CONFIG_SOLARIS)
-#undef env
- env = cpu_single_env;
-#define env cpu_single_env
-#endif
+ /* execute the generated code */
+ export_env();
next_tb = tcg_qemu_tb_exec(tc_ptr);
env->current_tb = NULL;
if ((next_tb & 3) == 2) {
next prev parent reply other threads:[~2010-02-13 20:26 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-10 23:26 [Qemu-devel] [PATCH 0/2] simplify global register save/restore Paolo Bonzini
2010-02-10 23:26 ` [Qemu-devel] [PATCH 1/2] remove dead m68k global register definitions Paolo Bonzini
2010-02-10 23:26 ` [Qemu-devel] [PATCH 2/2] get rid of hostregs_helper.h Paolo Bonzini
2010-02-18 19:07 ` Blue Swirl
2010-02-18 20:25 ` [Qemu-devel] [PATCH v2 1/2] remove dead m68k definitions Paolo Bonzini
2010-02-18 20:25 ` [Qemu-devel] [PATCH v2 2/2] get rid of hostregs_helper.h Paolo Bonzini
2010-02-18 21:28 ` [Qemu-devel] " Blue Swirl
2010-02-25 11:40 ` Michael S. Tsirkin
2010-02-25 12:50 ` Paolo Bonzini
2010-02-25 13:04 ` Michael S. Tsirkin
2010-02-25 13:11 ` Paolo Bonzini
2010-02-13 17:58 ` [Qemu-devel] [PATCH 0/2] simplify global register save/restore Blue Swirl
2010-02-13 20:26 ` Paolo Bonzini [this message]
2010-02-13 20:57 ` [Qemu-devel] " Blue Swirl
2010-02-13 20:58 ` Paolo Bonzini
2010-02-26 11:30 ` [Qemu-devel] " Paul Brook
2010-02-26 13:05 ` Paolo Bonzini
2010-02-26 18:32 ` Paul Brook
2010-03-01 12:30 ` Paolo Bonzini
2010-03-01 14:02 ` Paul Brook
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=4B770B02.4030409@gnu.org \
--to=bonzini@gnu.org \
--cc=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).