From patchwork Thu Mar 9 11:17:11 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: 95104 Delivered-To: patch@linaro.org Received: by 10.140.82.71 with SMTP id g65csp311425qgd; Thu, 9 Mar 2017 03:24:43 -0800 (PST) X-Received: by 10.200.50.42 with SMTP id x39mr14039726qta.180.1489058683723; Thu, 09 Mar 2017 03:24:43 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id g31si5432470qtd.131.2017.03.09.03.24.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 09 Mar 2017 03:24:43 -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]:33317 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clwBV-0001mA-93 for patch@linaro.org; Thu, 09 Mar 2017 06:24:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54468) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clw4J-0005BO-Qo for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clw4I-0006X3-6N for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:15 -0500 Received: from mail-wr0-x233.google.com ([2a00:1450:400c:c0c::233]:34500) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1clw4I-0006Wj-0r for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:14 -0500 Received: by mail-wr0-x233.google.com with SMTP id l37so42725835wrc.1 for ; Thu, 09 Mar 2017 03:17:13 -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=lqIJRrk/MiAeLGXU0QWeBzmVS+Q5JNcluDWHVR4aeBE=; b=c6DGpJCdgKHTjEwlcy09Z5YYEgSjR4qB5rOALqowteJCRrL98poxq6O5Ykw7jOmqAY /SbBTKnsPfE/mnnbV/GRvz62vkM8b23Rl5zWMazOh6h+KzbnVhE64W0bsa9Nfpz5o2DZ jV2UDKy2kZaSwjGnJFS877ypQpL8ToJkrZvvw= 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=lqIJRrk/MiAeLGXU0QWeBzmVS+Q5JNcluDWHVR4aeBE=; b=rvT1FUvA/jPDeE0ZxVfgF8zbmVMuhrb0T/YaoYwtkfM1+BPUUsnyCHW9yxvzst+bpY feGEjnSeEFhfAsOuAtAjmd8rzsWMXMh3n0hg7bDWPveYzKs2mcEEb/Dg05yz7RWENOU3 vEaAsBcmuxgE1gdZjiE7gakuLFzXzKNvevJyQb0PY3ggbYd0VJAX/kc/+8c2BQFWdfCg IqJm7yTZEZxSsXp7sWUXRlC9o2QxhoX6Jj4yfZeEO2joNMG9zkyjyzWUQMB6MiR+/bjk xcuePGSjTqdevpZWHqnb83FoQ6ZmtoAjv7lbl/LBTMOsjYDN/nUek2afldaM9BtAHHZ5 6Dug== X-Gm-Message-State: AMke39kFLfLTE5ebptUehc1s4eZKb1w7EwLQI4hDeNe6UBGuhDcDHnLrZKDNdInOk5N4Mj4D X-Received: by 10.223.155.17 with SMTP id b17mr9709927wrc.181.1489058232943; Thu, 09 Mar 2017 03:17:12 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id k8sm7786345wre.19.2017.03.09.03.17.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Mar 2017 03:17:10 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id AAA993E3839; Thu, 9 Mar 2017 11:17:15 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Thu, 9 Mar 2017 11:17:11 +0000 Message-Id: <20170309111714.20394-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170309111714.20394-1-alex.bennee@linaro.org> References: <20170309111714.20394-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::233 Subject: [Qemu-devel] [PULL 08/11] target/mips: hold BQL for timer interrupts 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: Yongbok Kim , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Aurelien Jarno Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Yongbok Kim Hold BQL when accessing timer which can cause interrupts Signed-off-by: Yongbok Kim Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Alex Bennée --- target/mips/op_helper.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) -- 2.11.0 diff --git a/target/mips/op_helper.c b/target/mips/op_helper.c index b683fcb025..e5f3ea4042 100644 --- a/target/mips/op_helper.c +++ b/target/mips/op_helper.c @@ -17,6 +17,7 @@ * License along with this library; if not, see . */ #include "qemu/osdep.h" +#include "qemu/main-loop.h" #include "cpu.h" #include "qemu/host-utils.h" #include "exec/helper-proto.h" @@ -827,7 +828,11 @@ target_ulong helper_mftc0_tcschefback(CPUMIPSState *env) target_ulong helper_mfc0_count(CPUMIPSState *env) { - return (int32_t)cpu_mips_get_count(env); + int32_t count; + qemu_mutex_lock_iothread(); + count = (int32_t) cpu_mips_get_count(env); + qemu_mutex_unlock_iothread(); + return count; } target_ulong helper_mftc0_entryhi(CPUMIPSState *env) @@ -1375,7 +1380,9 @@ void helper_mtc0_hwrena(CPUMIPSState *env, target_ulong arg1) void helper_mtc0_count(CPUMIPSState *env, target_ulong arg1) { + qemu_mutex_lock_iothread(); cpu_mips_store_count(env, arg1); + qemu_mutex_unlock_iothread(); } void helper_mtc0_entryhi(CPUMIPSState *env, target_ulong arg1) @@ -1424,7 +1431,9 @@ void helper_mttc0_entryhi(CPUMIPSState *env, target_ulong arg1) void helper_mtc0_compare(CPUMIPSState *env, target_ulong arg1) { + qemu_mutex_lock_iothread(); cpu_mips_store_compare(env, arg1); + qemu_mutex_unlock_iothread(); } void helper_mtc0_status(CPUMIPSState *env, target_ulong arg1) @@ -1475,7 +1484,9 @@ void helper_mtc0_srsctl(CPUMIPSState *env, target_ulong arg1) void helper_mtc0_cause(CPUMIPSState *env, target_ulong arg1) { + qemu_mutex_lock_iothread(); cpu_mips_store_cause(env, arg1); + qemu_mutex_unlock_iothread(); } void helper_mttc0_cause(CPUMIPSState *env, target_ulong arg1) @@ -2296,12 +2307,16 @@ target_ulong helper_rdhwr_synci_step(CPUMIPSState *env) target_ulong helper_rdhwr_cc(CPUMIPSState *env) { + int32_t count; check_hwrena(env, 2, GETPC()); #ifdef CONFIG_USER_ONLY - return env->CP0_Count; + count = env->CP0_Count; #else - return (int32_t)cpu_mips_get_count(env); + qemu_mutex_lock_iothread(); + count = (int32_t)cpu_mips_get_count(env); + qemu_mutex_unlock_iothread(); #endif + return count; } target_ulong helper_rdhwr_ccres(CPUMIPSState *env)