From patchwork Thu Jan 19 17:05:01 2017 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: 92008 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp393351qgi; Thu, 19 Jan 2017 09:40:24 -0800 (PST) X-Received: by 10.55.105.129 with SMTP id e123mr9167600qkc.229.1484847624316; Thu, 19 Jan 2017 09:40:24 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i189si3055649qka.126.2017.01.19.09.40.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 19 Jan 2017 09:40:24 -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 sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49987 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cUGhB-0004Cn-Mf for patch@linaro.org; Thu, 19 Jan 2017 12:40:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40605) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cUGGV-0005UN-6a for qemu-devel@nongnu.org; Thu, 19 Jan 2017 12:12:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cUGGU-0001gN-CM for qemu-devel@nongnu.org; Thu, 19 Jan 2017 12:12:47 -0500 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]:37080) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cUGGU-0001fz-6c for qemu-devel@nongnu.org; Thu, 19 Jan 2017 12:12:46 -0500 Received: by mail-wm0-x22c.google.com with SMTP id c206so3175169wme.0 for ; Thu, 19 Jan 2017 09:12:46 -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=FwMtHdEOSWBffOP2J8mEVf16VlZ7mHcr63zNUoylWPE=; b=VFrtX3KaSxdUjI3YMxtEwSTXpoCs99chuqBm6N9IaywQ/gR6+m/K16Noy/CpfE5O2i buof6IlPNVJ+GcSmdmk0Z9vqiqdJsx7QqUnKKJ9iOBmPZBg5Zw1Gbqnghi5AZ0xNdQfb TOOFRVo6EZ5OJyNun6ZZbkg/kT4Y+py9STjEc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FwMtHdEOSWBffOP2J8mEVf16VlZ7mHcr63zNUoylWPE=; b=SMz92h0mCR2TSAGhAawH6TPLzAqlLWfqTcQmmBhgIahHXt4IsXG+B3otTJiThLs8MA BPcWyLlU6w3WIqSpYZ/E5mi2J36CF7D7qJj8Gnigfznh5jRGC6lFFI+loByI2NX/nSpA p2ls5UKDgmTr8VOP9T6k8nOc7L4hrRXW72dGxojbXGKoiIHKEsV8a72r2VQe9vRKi/Yg TMVb0cYZZs08D1yJf+hOA7fBs2ADSJm/fLbMDCOwwm+9VLAiJooQMHXK1O+e/gxaW3IY nmggJ+twVp7m3uHFo5J0ZrTwL00zoFoNg9gCruVEZ8uxZ1CK6WYjN7PMnluArObfbWCD YXzQ== X-Gm-Message-State: AIkVDXJx0gxdr11+XRBJGVGUVnouaVjQ7teo7t/uTbihi8blUQQ/kogzs1puGKFUTjRqzuO0 X-Received: by 10.223.169.112 with SMTP id u103mr8321501wrc.166.1484845965183; Thu, 19 Jan 2017 09:12:45 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id d64sm54553544wmh.3.2017.01.19.09.12.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jan 2017 09:12:42 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 4B79C3E2A3F; Thu, 19 Jan 2017 17:05:09 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: mttcg@listserver.greensocs.com, qemu-devel@nongnu.org, fred.konrad@greensocs.com, a.rigo@virtualopensystems.com, cota@braap.org, bobby.prani@gmail.com, nikunj@linux.vnet.ibm.com Date: Thu, 19 Jan 2017 17:05:01 +0000 Message-Id: <20170119170507.16185-22-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170119170507.16185-1-alex.bennee@linaro.org> References: <20170119170507.16185-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::22c Subject: [Qemu-devel] [PATCH v7 21/27] 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: peter.maydell@linaro.org, claudio.fontana@huawei.com, jan.kiszka@siemens.com, mark.burton@greensocs.com, "open list:ARM" , serge.fdrv@gmail.com, pbonzini@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= , bamvor.zhangjian@linaro.org, rth@twiddle.net 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 Reviewed-by: Richard Henderson --- target/arm/helper.c | 6 ++++++ target/arm/op_helper.c | 4 ++++ 2 files changed, 10 insertions(+) -- 2.11.0 diff --git a/target/arm/helper.c b/target/arm/helper.c index b3875c7c6e..87809562b9 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6672,6 +6672,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 1348789760..e1a883c595 100644 --- a/target/arm/op_helper.c +++ b/target/arm/op_helper.c @@ -488,7 +488,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. */ @@ -1020,7 +1022,9 @@ void HELPER(exception_return)(CPUARMState *env) cur_el, new_el, env->pc); } + qemu_mutex_lock_iothread(); arm_call_el_change_hook(arm_env_get_cpu(env)); + qemu_mutex_unlock_iothread(); return;