From patchwork Thu Oct 27 11:37:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 122117 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8FFA6B6F89 for ; Thu, 27 Oct 2011 22:38:10 +1100 (EST) Received: from localhost ([::1]:44068 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJOHe-0002Fo-9Z for incoming@patchwork.ozlabs.org; Thu, 27 Oct 2011 07:38:06 -0400 Received: from eggs.gnu.org ([140.186.70.92]:46252) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJOHY-0002Fb-C8 for qemu-devel@nongnu.org; Thu, 27 Oct 2011 07:38:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RJOHX-0007Jj-AI for qemu-devel@nongnu.org; Thu, 27 Oct 2011 07:38:00 -0400 Received: from mnementh.archaic.org.uk ([81.2.115.146]:54657) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJOHX-0007In-1a for qemu-devel@nongnu.org; Thu, 27 Oct 2011 07:37:59 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1RJOHR-0004FD-1U; Thu, 27 Oct 2011 12:37:53 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 27 Oct 2011 12:37:52 +0100 Message-Id: <1319715472-16286-4-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1319715472-16286-1-git-send-email-peter.maydell@linaro.org> References: <1319715472-16286-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 81.2.115.146 Cc: Paolo Bonzini , "Dr. David Alan Gilbert" , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Jan Kiszka , patches@linaro.org Subject: [Qemu-devel] [PATCH v2 3/3] Make cpu_single_env thread-local 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 From: Paolo Bonzini Make cpu_single_env thread-local. This fixes a regression in handling of multi-threaded programs in linux-user mode (bug 823902). Signed-off-by: Paolo Bonzini [Peter Maydell: rename tls_cpu_single_env to cpu_single_env] Signed-off-by: Peter Maydell Reviewed-by: Andreas Färber --- cpu-all.h | 4 +++- exec.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cpu-all.h b/cpu-all.h index 42a5fa0..5f47ab8 100644 --- a/cpu-all.h +++ b/cpu-all.h @@ -20,6 +20,7 @@ #define CPU_ALL_H #include "qemu-common.h" +#include "qemu-tls.h" #include "cpu-common.h" /* some important defines: @@ -334,7 +335,8 @@ void cpu_dump_statistics(CPUState *env, FILE *f, fprintf_function cpu_fprintf, void QEMU_NORETURN cpu_abort(CPUState *env, const char *fmt, ...) GCC_FMT_ATTR(2, 3); extern CPUState *first_cpu; -extern CPUState *cpu_single_env; +DECLARE_TLS(CPUState *,cpu_single_env); +#define cpu_single_env get_tls(cpu_single_env) /* Flags for use in ENV->INTERRUPT_PENDING. diff --git a/exec.c b/exec.c index 9dc4edb..18e26cb 100644 --- a/exec.c +++ b/exec.c @@ -120,7 +120,7 @@ static MemoryRegion *system_io; CPUState *first_cpu; /* current CPU in the current thread. It is only valid inside cpu_exec() */ -CPUState *cpu_single_env; +DEFINE_TLS(CPUState *,cpu_single_env); /* 0 = Do not count executed instructions. 1 = Precise instruction counting. 2 = Adaptive rate instruction counting. */