qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: blauwirbel@gmail.com
Subject: [Qemu-devel] [PATCH 07/14] Avoid declaring the env variable at all if CONFIG_TCG_PASS_AREG0.
Date: Tue, 27 Mar 2012 17:32:16 -0700	[thread overview]
Message-ID: <1332894743-27418-8-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1332894743-27418-1-git-send-email-rth@twiddle.net>

At the same time, remove use of the global ENV from user-exec.c.

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 Makefile.target |    5 -----
 dyngen-exec.h   |    5 +++++
 user-exec.c     |   17 ++++++-----------
 3 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index aa53e28..81fdf9e 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -110,11 +110,6 @@ $(libobj-y): $(GENERATED_HEADERS)
 ifndef CONFIG_TCG_PASS_AREG0
 op_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
 endif
-user-exec.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
-
-# Note: this is a workaround. The real fix is to avoid compiling
-# cpu_signal_handler() in user-exec.c.
-signal.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
 
 #########################################################
 # Linux user emulator target
diff --git a/dyngen-exec.h b/dyngen-exec.h
index cfeef99..65fcb43 100644
--- a/dyngen-exec.h
+++ b/dyngen-exec.h
@@ -19,6 +19,10 @@
 #if !defined(__DYNGEN_EXEC_H__)
 #define __DYNGEN_EXEC_H__
 
+/* If the target has indicated that it does not need an AREG0,
+   don't declare the env variable at all, much less as a register.  */
+#if !defined(CONFIG_TCG_PASS_AREG0)
+
 #if defined(CONFIG_TCG_INTERPRETER)
 /* The TCG interpreter does not need a special register AREG0,
  * but it is possible to use one by defining AREG0.
@@ -65,4 +69,5 @@ register CPUArchState *env asm(AREG0);
 extern CPUArchState *env;
 #endif
 
+#endif /* !CONFIG_TCG_PASS_AREG0 */
 #endif /* !defined(__DYNGEN_EXEC_H__) */
diff --git a/user-exec.c b/user-exec.c
index cd905ff..9691f09 100644
--- a/user-exec.c
+++ b/user-exec.c
@@ -18,7 +18,6 @@
  */
 #include "config.h"
 #include "cpu.h"
-#include "dyngen-exec.h"
 #include "disas.h"
 #include "tcg.h"
 
@@ -58,8 +57,6 @@ void cpu_resume_from_signal(CPUArchState *env1, void *puc)
     struct sigcontext *uc = puc;
 #endif
 
-    env = env1;
-
     /* XXX: restore cpu registers saved in host registers */
 
     if (puc) {
@@ -74,8 +71,8 @@ void cpu_resume_from_signal(CPUArchState *env1, void *puc)
         sigprocmask(SIG_SETMASK, &uc->sc_mask, NULL);
 #endif
     }
-    env->exception_index = -1;
-    longjmp(env->jmp_env, 1);
+    env1->exception_index = -1;
+    longjmp(env1->jmp_env, 1);
 }
 
 /* 'pc' is the host PC at which the exception was raised. 'address' is
@@ -86,12 +83,10 @@ static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
                                     int is_write, sigset_t *old_set,
                                     void *puc)
 {
+    CPUArchState *env1 = cpu_single_env;
     TranslationBlock *tb;
     int ret;
 
-    if (cpu_single_env) {
-        env = cpu_single_env; /* XXX: find a correct solution for multithread */
-    }
 #if defined(DEBUG_SIGNAL)
     qemu_printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n",
                 pc, address, is_write, *(unsigned long *)old_set);
@@ -102,7 +97,7 @@ static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
     }
 
     /* see if it is an MMU fault */
-    ret = cpu_handle_mmu_fault(env, address, is_write, MMU_USER_IDX);
+    ret = cpu_handle_mmu_fault(env1, address, is_write, MMU_USER_IDX);
     if (ret < 0) {
         return 0; /* not an MMU fault */
     }
@@ -114,13 +109,13 @@ static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
     if (tb) {
         /* the PC is inside the translated code. It means that we have
            a virtual CPU fault */
-        cpu_restore_state(tb, env, pc);
+        cpu_restore_state(tb, env1, pc);
     }
 
     /* we restore the process signal mask as the sigreturn should
        do it (XXX: use sigsetjmp) */
     sigprocmask(SIG_SETMASK, old_set, NULL);
-    exception_action(env);
+    exception_action(env1);
 
     /* never comes here */
     return 1;
-- 
1.7.7.6

  parent reply	other threads:[~2012-03-28  0:32 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-28  0:32 [Qemu-devel] [PATCH 00/14] tcg-sparc improvments, v2 Richard Henderson
2012-03-28  0:32 ` [Qemu-devel] [PATCH 01/14] tcg-sparc: Hack in qemu_ld/st64 for 32-bit Richard Henderson
2012-03-28  0:32 ` [Qemu-devel] [PATCH 02/14] tcg-sparc: Fix ADDX opcode Richard Henderson
2012-03-28  0:32 ` [Qemu-devel] [PATCH 03/14] tcg-sparc: Assume v9 cpu always, i.e. force v8plus in 32-bit mode Richard Henderson
2012-03-29 18:45   ` Blue Swirl
2012-03-29 18:49     ` Richard Henderson
2012-03-28  0:32 ` [Qemu-devel] [PATCH 04/14] tcg-sparc: Fix qemu_ld/st to handle 32-bit host Richard Henderson
2012-03-28  0:32 ` [Qemu-devel] [PATCH 05/14] tcg-sparc: Simplify qemu_ld/st direct memory paths Richard Henderson
2012-03-29 18:47   ` Blue Swirl
2012-03-28  0:32 ` [Qemu-devel] [PATCH 06/14] tcg-sparc: Support GUEST_BASE Richard Henderson
2012-03-28  0:32 ` Richard Henderson [this message]
2012-03-29 18:57   ` [Qemu-devel] [PATCH 07/14] Avoid declaring the env variable at all if CONFIG_TCG_PASS_AREG0 Blue Swirl
2012-03-28  0:32 ` [Qemu-devel] [PATCH 08/14] tcg-sparc: Do not use a global register for AREG0 Richard Henderson
2012-03-28  0:32 ` [Qemu-devel] [PATCH 09/14] tcg-sparc: Change AREG0 in generated code to %i0 Richard Henderson
2012-03-28  0:32 ` [Qemu-devel] [PATCH 10/14] tcg-sparc: Clean up cruft stemming from attempts to use global registers Richard Henderson
2012-03-28  0:32 ` [Qemu-devel] [PATCH 11/14] tcg-sparc: Mask shift immediates to avoid illegal insns Richard Henderson
2012-03-28  0:32 ` [Qemu-devel] [PATCH 12/14] tcg-sparc: Use defines for temporaries Richard Henderson
2012-03-29 18:56   ` Blue Swirl
2012-03-29 19:04     ` Richard Henderson
2012-03-28  0:32 ` [Qemu-devel] [PATCH 13/14] tcg-sparc: Add %g/%o registers to alloc_order Richard Henderson
2012-03-28  0:32 ` [Qemu-devel] [PATCH 14/14] tcg-sparc: Fix and enable direct TB chaining Richard Henderson

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=1332894743-27418-8-git-send-email-rth@twiddle.net \
    --to=rth@twiddle.net \
    --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).