From patchwork Thu Apr 19 13:33:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 153776 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 18543B7006 for ; Fri, 20 Apr 2012 00:18:13 +1000 (EST) Received: from localhost ([::1]:44401 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKrVb-0006Tf-4z for incoming@patchwork.ozlabs.org; Thu, 19 Apr 2012 09:34:51 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49261) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKrUh-0004RW-G9 for qemu-devel@nongnu.org; Thu, 19 Apr 2012 09:34:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SKrUY-00007U-E8 for qemu-devel@nongnu.org; Thu, 19 Apr 2012 09:33:55 -0400 Received: from mail-yx0-f173.google.com ([209.85.213.173]:45157) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKrUY-00006V-82 for qemu-devel@nongnu.org; Thu, 19 Apr 2012 09:33:46 -0400 Received: by mail-yx0-f173.google.com with SMTP id r5so5702289yen.4 for ; Thu, 19 Apr 2012 06:33:45 -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=LThM4lnhqbms75CtLhtGIOPj84O+CPYI7N5Qva53GCg=; b=dpLXtJrPk5dB4IHtDi/oqTNiUa/1CEG9aQe8HICiGy+yUVepnjCbmPmgpxdwHDTACM 4OFONWZoLIjioywoX9+fq4DqxGgahERc+96bSno+5ekGWztFCz4y2r68IxpWC36OgLAU hWa5RcSd0KgttbRI5stdhCHLMEVbSvD7p1olm3wFBlLCbfHfs4SL5EndY7BgL0p5bts6 N4xIEPPS3ctwmna9sNd7SMrza3BK1MK9IAFPqeN4WQkBd3siDAiKLi2bUEeVOZekgjzu V9QHgUUdpF27Lj51bUOIaeRBuhzqgI6qr0VaKtbp9jpINDfueasOGzY4G7xVWeBVEJrm 0iZg== Received: by 10.50.104.166 with SMTP id gf6mr2013261igb.35.1334842425435; Thu, 19 Apr 2012 06:33:45 -0700 (PDT) Received: from pebble.com ([12.236.175.36]) by mx.google.com with ESMTPS id b11sm6529633igq.7.2012.04.19.06.33.44 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 19 Apr 2012 06:33:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 19 Apr 2012 08:33:08 -0500 Message-Id: <1334842395-31819-8-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1334842395-31819-1-git-send-email-rth@twiddle.net> References: <1334842395-31819-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.173 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 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;