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: 4857 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 62BD723DEF for ; Thu, 27 Oct 2011 11:37:58 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 597FCA18459 for ; Thu, 27 Oct 2011 11:37:58 +0000 (UTC) Received: by mail-fx0-f52.google.com with SMTP id n26so3650440faa.11 for ; Thu, 27 Oct 2011 04:37:58 -0700 (PDT) Received: by 10.223.15.10 with SMTP id i10mr66183006faa.17.1319715478238; Thu, 27 Oct 2011 04:37:58 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.1.71 with SMTP id 7cs42371lak; Thu, 27 Oct 2011 04:37:57 -0700 (PDT) Received: by 10.227.60.143 with SMTP id p15mr15866717wbh.28.1319715476886; Thu, 27 Oct 2011 04:37:56 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [81.2.115.146]) by mx.google.com with ESMTPS id gh14si3777535wbb.128.2011.10.27.04.37.56 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Oct 2011 04:37:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) smtp.mail=pm215@archaic.org.uk 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 Cc: patches@linaro.org, Paolo Bonzini , "Dr. David Alan Gilbert" , Jan Kiszka , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [PATCH v2 3/3] Make cpu_single_env thread-local 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> 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. */