From patchwork Thu Mar 9 11:17:09 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: 95099 Delivered-To: patch@linaro.org Received: by 10.140.82.71 with SMTP id g65csp310112qgd; Thu, 9 Mar 2017 03:20:56 -0800 (PST) X-Received: by 10.200.44.57 with SMTP id d54mr14120564qta.59.1489058456578; Thu, 09 Mar 2017 03:20:56 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t127si5399628qkf.315.2017.03.09.03.20.56 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 09 Mar 2017 03:20:56 -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]:33293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clw7q-0007El-3S for patch@linaro.org; Thu, 09 Mar 2017 06:20:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clw4I-0005AY-9o for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clw4G-0006Uq-3m for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:14 -0500 Received: from mail-wr0-x235.google.com ([2a00:1450:400c:c0c::235]:35041) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1clw4F-0006U7-TP for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:12 -0500 Received: by mail-wr0-x235.google.com with SMTP id g10so42711830wrg.2 for ; Thu, 09 Mar 2017 03:17:11 -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=8lpWRwy8UPmdlWUz+lQvEwbITj3/HElyc7FbfuzGx+A=; b=kqINzQelatHYgsxL0kB/hoHGEA+QTmiU3BNqwqJJ99SW8rxZrSfPo9tvJQWxyxLL/d eSQ5OPCSDiATPrHlnwGMReR8gY0ihkdCbFHHxFjPSFNIkMay2q9yPUPHTLTCXO/RSY81 Rihx2IqgSdphC9Et834TKwpF7j0q7svcIaV1A= 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=8lpWRwy8UPmdlWUz+lQvEwbITj3/HElyc7FbfuzGx+A=; b=A/ro3NKD9hX4GKEljf+h+P9xGf3Tw0uGNguHIYTH1oYczGi3PXPnLD+cCyf6xN6unD cx8ltmbqiSdlgTbfdBXW3BTWCfA7EIfEFQYfYob7RFDNvKdgwdSKSlpSoElOHujNZVNE RzHhzeEjCfAuxdCULGmHrsKha2ko/C5lD0k2eyCnj0kuYlEo9QoxNCL8ZooJLZmC4pU+ /5NBs+NjE64ZC81TSq7twlfwZjzx+ZfhKJ5FRFG569SoArYteHRDUuDnbamHBu6dD7KH blvHHlcdCI03xg8y8jtfhhynQAZ3MPP8UG+Lot/D4hQmGEOdozQqd0sKSaTWKXn757Dk o93w== X-Gm-Message-State: AMke39lYsP9rADNspW8nua0nFtxoMedhdQoIYp0ZiUZFkrdtW6uWux+rqXnENrTilFZNjV8X X-Received: by 10.223.164.16 with SMTP id d16mr9764242wra.47.1489058230818; Thu, 09 Mar 2017 03:17:10 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id t103sm7865007wrc.43.2017.03.09.03.17.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Mar 2017 03:17:05 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 7E1483E380B; 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:09 +0000 Message-Id: <20170309111714.20394-7-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::235 Subject: [Qemu-devel] [PULL 06/11] target/xtensa: hold BQL for interrupt processing 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: Max Filippov , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Make sure we have the BQL held when processing interrupts. Reported-by: Thomas Huth Signed-off-by: Alex Bennée Acked-by: Max Filippov --- target/xtensa/helper.c | 1 + target/xtensa/op_helper.c | 7 +++++++ 2 files changed, 8 insertions(+) -- 2.11.0 diff --git a/target/xtensa/helper.c b/target/xtensa/helper.c index c67d715c4b..bcd0b7738d 100644 --- a/target/xtensa/helper.c +++ b/target/xtensa/helper.c @@ -217,6 +217,7 @@ static void handle_interrupt(CPUXtensaState *env) } } +/* Called from cpu_handle_interrupt with BQL held */ void xtensa_cpu_do_interrupt(CPUState *cs) { XtensaCPU *cpu = XTENSA_CPU(cs); diff --git a/target/xtensa/op_helper.c b/target/xtensa/op_helper.c index af2723445d..519fbeddd6 100644 --- a/target/xtensa/op_helper.c +++ b/target/xtensa/op_helper.c @@ -26,6 +26,7 @@ */ #include "qemu/osdep.h" +#include "qemu/main-loop.h" #include "cpu.h" #include "exec/helper-proto.h" #include "qemu/host-utils.h" @@ -381,7 +382,11 @@ void HELPER(waiti)(CPUXtensaState *env, uint32_t pc, uint32_t intlevel) env->pc = pc; env->sregs[PS] = (env->sregs[PS] & ~PS_INTLEVEL) | (intlevel << PS_INTLEVEL_SHIFT); + + qemu_mutex_lock_iothread(); check_interrupts(env); + qemu_mutex_unlock_iothread(); + if (env->pending_irq_level) { cpu_loop_exit(CPU(xtensa_env_get_cpu(env))); return; @@ -426,7 +431,9 @@ void HELPER(update_ccompare)(CPUXtensaState *env, uint32_t i) void HELPER(check_interrupts)(CPUXtensaState *env) { + qemu_mutex_lock_iothread(); check_interrupts(env); + qemu_mutex_unlock_iothread(); } void HELPER(itlb_hit_test)(CPUXtensaState *env, uint32_t vaddr)