From patchwork Wed Mar 28 00:32:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149070 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id EA1C9B6EF4 for ; Wed, 28 Mar 2012 12:18:10 +1100 (EST) Received: from localhost ([::1]:48463 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCgp3-0006ig-8R for incoming@patchwork.ozlabs.org; Tue, 27 Mar 2012 20:33:09 -0400 Received: from eggs.gnu.org ([208.118.235.92]:32994) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCgod-0006LS-Ub for qemu-devel@nongnu.org; Tue, 27 Mar 2012 20:32:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SCgoa-0008TT-OP for qemu-devel@nongnu.org; Tue, 27 Mar 2012 20:32:43 -0400 Received: from mail-yw0-f45.google.com ([209.85.213.45]:40660) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCgoa-0008Sw-Hy for qemu-devel@nongnu.org; Tue, 27 Mar 2012 20:32:40 -0400 Received: by yhoo21 with SMTP id o21so512543yho.4 for ; Tue, 27 Mar 2012 17:32:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=xUtreB2Tt9p3sMlMlNvawjV8Dxosdwjblu1VGHNL2pE=; b=ru9L//ki01VPVTyX9cyXFY+12o1P9p8oV4RrN2m+KmYqPBF972h+g94JTODsCsfidW 5tIkp67sDPyBO6yOa5VC1urXwsdfKuKhXFEpI7c1Bm+GEdve4pcQ0cAE9DyW0/MeSDF5 n3K4S7WGqqHlIZrlWSQj4b8tx0VnOQWLkaf2xUXdIIFvrInWQs3p+RBbcWKEgbQJ/JBt mxn5boDmDTb+HeIl7ArQsllcel/BMbxyBCYw1QKqy6AoWNgc8ek3GuQt2im1823hMjqT JDf1I84dZ6IXN36rxB8J+fDsCX5nW0UXHOP86EgSrN6bkRz/C7pnnEu8AIU5hhAgwdkL X6ww== Received: by 10.68.132.6 with SMTP id oq6mr41881165pbb.66.1332894758670; Tue, 27 Mar 2012 17:32:38 -0700 (PDT) Received: from anchor.twiddle.home.com ([173.160.232.49]) by mx.google.com with ESMTPS id f5sm1418749pbe.26.2012.03.27.17.32.37 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 27 Mar 2012 17:32:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 27 Mar 2012 17:32:16 -0700 Message-Id: <1332894743-27418-8-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1332894743-27418-1-git-send-email-rth@twiddle.net> References: <1332894743-27418-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.213.45 Cc: blauwirbel@gmail.com Subject: [Qemu-devel] [PATCH 07/14] Avoid declaring the env variable at all if CONFIG_TCG_PASS_AREG0. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org At the same time, remove use of the global ENV from user-exec.c. Signed-off-by: Richard Henderson --- 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;