From nobody Tue Feb 10 14:32:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1488485077775924.6466625667751; Thu, 2 Mar 2017 12:04:37 -0800 (PST) Received: from localhost ([::1]:54319 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjWxn-0007ua-F7 for importer@patchew.org; Thu, 02 Mar 2017 15:04:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59763) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjWnO-00088f-My for qemu-devel@nongnu.org; Thu, 02 Mar 2017 14:53:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cjWnM-0002X8-1o for qemu-devel@nongnu.org; Thu, 02 Mar 2017 14:53:50 -0500 Received: from mail-wr0-x22a.google.com ([2a00:1450:400c:c0c::22a]:36851) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cjWnL-0002Wm-Rt for qemu-devel@nongnu.org; Thu, 02 Mar 2017 14:53:47 -0500 Received: by mail-wr0-x22a.google.com with SMTP id u108so60200391wrb.3 for ; Thu, 02 Mar 2017 11:53:47 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id s26sm12139298wra.66.2017.03.02.11.53.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Mar 2017 11:53:43 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id B71913E09CE; Thu, 2 Mar 2017 19:53:37 +0000 (GMT) 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=8FGZdgizmXDFKV3b+dt0xaa6x9HCoqZQdwSekLyfFVE=; b=gUrYvxkf06rwoRqWx9EChhj7DrTVIkUNLAxOYuKCkPW/ueuON0TQj0i8vgeXL6+zk3 lf8RGdWGZmQ6iiG+HqYZU5gDTuCOp5CYDHuYWJwCL5ZVh9cBTfR/R19eWbqnX1HaTi/O 0keZhOrcwRAwoz5Zs85ALz7WIuZLiwKlDV/UM= 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=8FGZdgizmXDFKV3b+dt0xaa6x9HCoqZQdwSekLyfFVE=; b=p6f1BEJih+vqNCU7ykVZMJqckhVtwdY8l9BxWdvN7G3cC3JUYjL7QJ5wMzcSCcCrce JLI8M4ybf1/sPRPp3j0DdQHX8UgqX4XKmH+HlRf5X9aBFRlIXJI1hjf0JCXYT6oiRCob AAe+dgKUOBbMwgJBD6Yqy60TpWjttjYMHgFNjEzejshtuFehfeGUXnic9xBzZXFsnB95 0x6IJ2/IHW5TRsqThfGS5h6oiPNaHtMSd8oi6i4E1xD3xLSjoQxlMyOTl190O9XLq7xK 7WIWSN3jufDNOWywNix+MNySTnAPaaODv3tS6iGzrsVwXSg0IejQ3YjPsj+oCiY4J4df S50g== X-Gm-Message-State: AMke39mjLexcbvCdCHsYS9FfoyigV3ZT1Ou8gY0DGwIIp1jibXrfFxznutMindxpx+a/aHeg X-Received: by 10.223.155.211 with SMTP id e19mr13319522wrc.74.1488484426679; Thu, 02 Mar 2017 11:53:46 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org, rth@twiddle.net, pbonzini@redhat.com Date: Thu, 2 Mar 2017 19:53:35 +0000 Message-Id: <20170302195337.31558-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170302195337.31558-1-alex.bennee@linaro.org> References: <20170302195337.31558-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22a Subject: [Qemu-devel] [PATCH v2 09/11] target/mips/op_helper: hold BQL before calling cpu_mips_get_count 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, nikunj@linux.vnet.ibm.com, a.rigo@virtualopensystems.com, qemu-devel@nongnu.org, cota@braap.org, Yongbok Kim , bobby.prani@gmail.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno , fred.konrad@greensocs.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 We should hold the BQL before we transition to HW emulation. This is because all HW emulation needs to be serialised under MTTCG conditions. This is picked up by asserts that fire when cpu_mips_get_count triggers and IRQ. Reported-by: Yongbok Kim Signed-off-by: Alex Benn=C3=A9e --- target/mips/op_helper.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/target/mips/op_helper.c b/target/mips/op_helper.c index b683fcb025..38bca03f52 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,13 @@ target_ulong helper_mftc0_tcschefback(CPUMIPSState *en= v) =20 target_ulong helper_mfc0_count(CPUMIPSState *env) { - return (int32_t)cpu_mips_get_count(env); + int32_t count; + + qemu_mutex_lock_iothread(); + count =3D (int32_t)cpu_mips_get_count(env); + qemu_mutex_unlock_iothread(); + + return count; } =20 target_ulong helper_mftc0_entryhi(CPUMIPSState *env) @@ -2296,12 +2303,16 @@ target_ulong helper_rdhwr_synci_step(CPUMIPSState *= env) =20 target_ulong helper_rdhwr_cc(CPUMIPSState *env) { + int32_t count; check_hwrena(env, 2, GETPC()); #ifdef CONFIG_USER_ONLY - return env->CP0_Count; + count =3D env->CP0_Count; #else - return (int32_t)cpu_mips_get_count(env); + qemu_mutex_lock_iothread(); + count =3D (int32_t)cpu_mips_get_count(env); + qemu_mutex_unlock_iothread(); #endif + return count; } =20 target_ulong helper_rdhwr_ccres(CPUMIPSState *env) --=20 2.11.0