From patchwork Wed Nov 9 14:57:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 81529 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp252535qge; Wed, 9 Nov 2016 07:24:19 -0800 (PST) X-Received: by 10.202.95.85 with SMTP id t82mr160978oib.66.1478705059353; Wed, 09 Nov 2016 07:24:19 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d37si71301otd.63.2016.11.09.07.24.19 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 09 Nov 2016 07:24:19 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40567 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c4Uja-0005V8-JT for patch@linaro.org; Wed, 09 Nov 2016 10:24:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41298) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c4UKO-0000lW-El for qemu-devel@nongnu.org; Wed, 09 Nov 2016 09:58:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c4UKN-0002No-MI for qemu-devel@nongnu.org; Wed, 09 Nov 2016 09:58:16 -0500 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]:35383) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c4UKN-0002Mz-F0 for qemu-devel@nongnu.org; Wed, 09 Nov 2016 09:58:15 -0500 Received: by mail-wm0-x22b.google.com with SMTP id a197so312256556wmd.0 for ; Wed, 09 Nov 2016 06:58:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WSanSCOOlkXTBGzdRsOdv00mzV/fOuMjfm72Y+Izevo=; b=fzJNf5tatqpMFuQFdzyIgNoCZLRsdWGMm5SZMeP5xDEEqItHAgIAIoOwbR2KmKbNtk a+5PPE6oJZ5bwX5PgRlxsqLGccGhUUHSiUgMFJoOPyEouby1J7+4sVNa3oKDcCJTfhkk wiYPq3gYurBom66BQ1OQkvB9Y7jQA6C8+f4Fo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WSanSCOOlkXTBGzdRsOdv00mzV/fOuMjfm72Y+Izevo=; b=d3pOwNsAh7PhBHoj8BUmgp1DeTmeVxsU4BrmLaR+u2S2uzmuBX4bWmtaJi5oD0NU3Q BPk4+Hu9U9PUXuHnHPhs91+Xs/1yjgRfBGEYZF4Dvr2kA9XFNAH5x9JRNLnIo4smFwSQ oZ5Sr0rVtmwt9CMMLwPstcvl/KUGEeazM9HH3FrfiRJ9ROwK7KHdNlUVawMWi858zDPS zbZVi0NNe8y5G3TgdV92duQ/XFZY0hQOkWZumnQ4q5RpIB7K/7ytZf0qOMtJr8acK+Nd f9TfsgrBPX4jNOyJ+6NunXVFtsLSsTWz+or0MyhzuGZgQlPb41cHgGPtzllKre5TVSe8 JuxA== X-Gm-Message-State: ABUngvckGowIprl+k79wcAdK8FRxzIM4wPePuRhS66BUd97OuSlHCpgkrG/hDSHQESiKO1hW X-Received: by 10.194.93.234 with SMTP id cx10mr9584wjb.140.1478703494149; Wed, 09 Nov 2016 06:58:14 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id g142sm7447941wmd.2.2016.11.09.06.58.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Nov 2016 06:58:10 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 1A6B13E04A6; Wed, 9 Nov 2016 14:57:58 +0000 (GMT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: pbonzini@redhat.com Date: Wed, 9 Nov 2016 14:57:46 +0000 Message-Id: <20161109145748.27282-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161109145748.27282-1-alex.bennee@linaro.org> References: <20161109145748.27282-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::22b Subject: [Qemu-devel] [PATCH v6 17/19] target-arm: helpers which may affect global state need the BQL X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mttcg@listserver.greensocs.com, peter.maydell@linaro.org, claudio.fontana@huawei.com, nikunj@linux.vnet.ibm.com, jan.kiszka@siemens.com, mark.burton@greensocs.com, a.rigo@virtualopensystems.com, qemu-devel@nongnu.org, cota@braap.org, "open list:ARM" , serge.fdrv@gmail.com, bobby.prani@gmail.com, rth@twiddle.net, =?UTF-8?q?Alex=20Benn=C3=A9e?= , fred.konrad@greensocs.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" As the arm_call_el_change_hook may affect global state (for example with updating the global GIC state) we need to assert/take the BQL. Signed-off-by: Alex Bennée --- target-arm/helper.c | 6 ++++++ target-arm/op_helper.c | 4 ++++ 2 files changed, 10 insertions(+) -- 2.10.1 Reviewed-by: Richard Henderson diff --git a/target-arm/helper.c b/target-arm/helper.c index b5b65ca..3f47fa7 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -6669,6 +6669,12 @@ void arm_cpu_do_interrupt(CPUState *cs) arm_cpu_do_interrupt_aarch32(cs); } + /* Hooks may change global state so BQL should be held, also the + * BQL needs to be held for any modification of + * cs->interrupt_request. + */ + g_assert(qemu_mutex_iothread_locked()); + arm_call_el_change_hook(cpu); if (!kvm_enabled()) { diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c index 4f0c754..41beabc 100644 --- a/target-arm/op_helper.c +++ b/target-arm/op_helper.c @@ -487,7 +487,9 @@ void HELPER(cpsr_write_eret)(CPUARMState *env, uint32_t val) */ env->regs[15] &= (env->thumb ? ~1 : ~3); + qemu_mutex_lock_iothread(); arm_call_el_change_hook(arm_env_get_cpu(env)); + qemu_mutex_unlock_iothread(); } /* Access to user mode registers from privileged modes. */ @@ -1013,7 +1015,9 @@ void HELPER(exception_return)(CPUARMState *env) env->pc = env->elr_el[cur_el]; } + qemu_mutex_lock_iothread(); arm_call_el_change_hook(arm_env_get_cpu(env)); + qemu_mutex_unlock_iothread(); return;