From patchwork Thu Mar 2 19:53:34 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: 734785 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vZ33P3N14z9s1h for ; Fri, 3 Mar 2017 06:56:17 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Bn7yZGsh"; dkim-atps=neutral Received: from localhost ([::1]:54275 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjWpi-0001Gm-WE for incoming@patchwork.ozlabs.org; Thu, 02 Mar 2017 14:56:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59699) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjWnL-00083H-2J for qemu-devel@nongnu.org; Thu, 02 Mar 2017 14:53:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cjWnK-0002Vz-7p for qemu-devel@nongnu.org; Thu, 02 Mar 2017 14:53:47 -0500 Received: from mail-wr0-x231.google.com ([2a00:1450:400c:c0c::231]:34528) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cjWnK-0002VZ-1w for qemu-devel@nongnu.org; Thu, 02 Mar 2017 14:53:46 -0500 Received: by mail-wr0-x231.google.com with SMTP id l37so60263338wrc.1 for ; Thu, 02 Mar 2017 11:53:45 -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=9rzbWDgHCcpb6723uLOqFuMOmTeT/3yN4F5tIjX81xA=; b=Bn7yZGsh171GFjD5EJ+3GUfhFOXS6DzuGfousaoJkRoP2S6ySCIZMYMTSSvSyKo/RO pCWaqmhqnn/kaWOtAkGRVIQGTyR7i7d9C6XHmGStWimHAouUbQX1mAhs/M5lSRYtyf/j 0XAN8qUNtiZY3DHwwa29nu46ZBb6VlEOQ+yNs= 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=9rzbWDgHCcpb6723uLOqFuMOmTeT/3yN4F5tIjX81xA=; b=YGdKAQDv3e6BzejO1FRXOnunwW726uDQfLbvSk3CBjgkEpgr/kU5jtvlQEvDm8ZTCO 77ckL58SApbFt8DOnO6kv3xbfdiFEaiZEeF6HDmrGKNKMSyTvctP9mUfI/0U6hUk1LGt P8ByBbHiscuyA6BPCLJB3dbDHBHk/qeK6zXRRGGOMa9VSq6CaS3cf+898WuRgF/VdAGC oAFUPUAGPOXWiIzkUHvAO0Fti24YuwcvHj2WXV/D7wna4i+VSX8KLwrpOPZ1FgN5SXqA CRHLLZxrf2rNQ70IWwwnCHsFazQht1orKxuDUPGvDUwtr/7CLnevq9Wrzh4+dKScjl8I 638Q== X-Gm-Message-State: AMke39k6jefmvhbq9dkGW+lw1HezmQEv3taIsy4ycU8vbnVuXXgCxtVCR1FVGEf39iuGsgQ8 X-Received: by 10.223.145.45 with SMTP id j42mr15307580wrj.141.1488484424860; Thu, 02 Mar 2017 11:53:44 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id z88sm12167405wrb.26.2017.03.02.11.53.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Mar 2017 11:53:40 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id A64A53E08FC; Thu, 2 Mar 2017 19:53:37 +0000 (GMT) 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:34 +0000 Message-Id: <20170302195337.31558-9-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 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::231 Subject: [Qemu-devel] [PATCH v2 08/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: mttcg@listserver.greensocs.com, nikunj@linux.vnet.ibm.com, a.rigo@virtualopensystems.com, qemu-devel@nongnu.org, Max Filippov , cota@braap.org, bobby.prani@gmail.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , fred.konrad@greensocs.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.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(+) 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)