From patchwork Fri Oct 28 09:52:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 4869 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 B759B23DEF for ; Fri, 28 Oct 2011 09:52:52 +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 AAE99A18562 for ; Fri, 28 Oct 2011 09:52:52 +0000 (UTC) Received: by mail-fx0-f52.google.com with SMTP id n26so5172404faa.11 for ; Fri, 28 Oct 2011 02:52:52 -0700 (PDT) Received: by 10.223.77.6 with SMTP id e6mr4884751fak.32.1319795572559; Fri, 28 Oct 2011 02:52:52 -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 7cs5326lak; Fri, 28 Oct 2011 02:52:52 -0700 (PDT) Received: by 10.68.38.228 with SMTP id j4mr3366195pbk.80.1319795570165; Fri, 28 Oct 2011 02:52:50 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [81.2.115.146]) by mx.google.com with ESMTPS id d6si9202293pbw.115.2011.10.28.02.52.47 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 28 Oct 2011 02:52:49 -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 1RJj7C-0004iK-Vi; Fri, 28 Oct 2011 10:52:42 +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 v3 3/3] Make cpu_single_env thread-local Date: Fri, 28 Oct 2011 10:52:42 +0100 Message-Id: <1319795562-18091-4-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1319795562-18091-1-git-send-email-peter.maydell@linaro.org> References: <1319795562-18091-1-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 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. */