From patchwork Thu Oct 27 15:10:29 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: 79739 Delivered-To: patch@linaro.org Received: by 10.80.142.83 with SMTP id 19csp720629edx; Thu, 27 Oct 2016 08:52:58 -0700 (PDT) X-Received: by 10.129.105.196 with SMTP id e187mr6991043ywc.291.1477583578151; Thu, 27 Oct 2016 08:52:58 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 199si2956307ybn.154.2016.10.27.08.52.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 27 Oct 2016 08:52:58 -0700 (PDT) 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]:42431 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzmzB-0004rQ-Ac for patch@linaro.org; Thu, 27 Oct 2016 11:52:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45597) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzmTQ-0003nN-Ge for qemu-devel@nongnu.org; Thu, 27 Oct 2016 11:20:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bzmTN-0004WT-Do for qemu-devel@nongnu.org; Thu, 27 Oct 2016 11:20:08 -0400 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]:38448) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bzmTN-0004Vr-6e for qemu-devel@nongnu.org; Thu, 27 Oct 2016 11:20:05 -0400 Received: by mail-wm0-x231.google.com with SMTP id n67so51142348wme.1 for ; Thu, 27 Oct 2016 08:20:05 -0700 (PDT) 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=ILuPUBptPqCtTJp3FLrukqrNaANcmfpDywdhujdIf3k=; b=Q4RaaaXmaytArcgbGvSO0eRKGZ01T5l2EYyoaVUg5qWou25JwoHCATYFv9WIbfpIJM NOxtooFGwdY3cEGg0EdEYFP8krwHToRb0e/zuV8adcDXy7N2uf/5YT5FEn3wZGOxanJB JWX8vcnJ3j3M4wLcQrUWjYKQ28PkCUHc+eols= 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=ILuPUBptPqCtTJp3FLrukqrNaANcmfpDywdhujdIf3k=; b=GIErQ0/X6ZilmBPtcKpMeFexFKsQOiD3wvVLDxWMx7MiApRj2YLBvzvcNPpqIKljyI 2aJ9NbO6DNm6ztatu1zV+uhMMFVHTzA0UNv33BjUd+S2z6a+t1n0bdMtjV+cQlzzNF1/ XoCJqr1F9i3LzvM6ui1ffwPv/ZAuGj1o9jOPlHuJJlDUTnEMicVFV276XFiIWn9biLOQ joUFYgPnf/ZP6KpUax4533Hhm8sa95uz1LOILJFKHjPyh3qMwxxdy46dN3T/BjmEHcUD uOpeZT4IskJKxfEWsr4gORTpxeXAlQYUAtN4FwHbBMUuKQV7tTVAMY+6lP+NEzMB6JPf R3nQ== X-Gm-Message-State: ABUngveM/B25ttUe3Q2ajCLIvGoVgtoPUs4/qb0hrFG1iXwlADusIvwuA/TchEjyGR2r+8yR X-Received: by 10.194.204.198 with SMTP id la6mr7324238wjc.2.1477581604135; Thu, 27 Oct 2016 08:20:04 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id hb5sm9051580wjc.5.2016.10.27.08.19.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Oct 2016 08:19:59 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 985C73E04DB; Thu, 27 Oct 2016 16:11:01 +0100 (BST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: pbonzini@redhat.com Date: Thu, 27 Oct 2016 16:10:29 +0100 Message-Id: <20161027151030.20863-33-alex.bennee@linaro.org> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161027151030.20863-1-alex.bennee@linaro.org> References: <20161027151030.20863-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::231 Subject: [Qemu-devel] [PATCH v5 32/33] 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 diff --git a/target-arm/helper.c b/target-arm/helper.c index cb83ee2..ad93926 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -6662,6 +6662,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;