At the same time, remove use of the global ENV from user-exec.c. Signed-off-by: Richard Henderson <r...@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 4afddfe..2c9eb0b 100644 --- a/Makefile.target +++ b/Makefile.target @@ -116,11 +116,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 be6bc4f..826731f 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(uintptr_t 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(uintptr_t 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(uintptr_t 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