From patchwork Fri Mar 18 16:18:51 2016 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: 8621671 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 544C09F6E1 for ; Fri, 18 Mar 2016 16:19:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 956A5202BE for ; Fri, 18 Mar 2016 16:19:30 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DD1472026F for ; Fri, 18 Mar 2016 16:19:29 +0000 (UTC) Received: from localhost ([::1]:44775 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agx7Z-0000l2-5H for patchwork-qemu-devel@patchwork.kernel.org; Fri, 18 Mar 2016 12:19:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56969) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agx7E-0000Y0-BV for qemu-devel@nongnu.org; Fri, 18 Mar 2016 12:19:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1agx7D-0002yi-BJ for qemu-devel@nongnu.org; Fri, 18 Mar 2016 12:19:08 -0400 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]:37534) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agx7D-0002ya-1S for qemu-devel@nongnu.org; Fri, 18 Mar 2016 12:19:07 -0400 Received: by mail-wm0-x22d.google.com with SMTP id p65so44382067wmp.0 for ; Fri, 18 Mar 2016 09:19:06 -0700 (PDT) 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=fSWSYj163nmdZtY0R0WAD/uPKqOLi8o+T46eydV801s=; b=a+ONxqBjrhYImnPfijAV0olrmuueoqkcQAYn3S3xjkphIWO4NmVUzzGKBAXwVYwWy0 VobU37OMbhlt9Ioh0RPLsnJvvAgiOxowTHvoLQy0FxZInmqI024q71t1TIdf9YhjOyin pqP+9YXkEwvlggGAfJXNv+k7hlIL3ciwOUciQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fSWSYj163nmdZtY0R0WAD/uPKqOLi8o+T46eydV801s=; b=Fv7AXZ7M0EDH8t551kJnQutm+JI/YtzirAzJcpwuhBJjiTMWWTayrdZclouVki1Lk5 IYYHG5Y+tCEyQ9j4iOnF4od/+vcXBZKKvGmTn36wT3C/ln3nDsWayXYToQy2DRVV2VC/ us8DhKNos7wWzqgjbZF7deka6GKRQTtYMd/dohVPg/bj5cWglN4dQU3FnPeTWOU1RB2C A1Sdx8eLrQ3KNN87QWtmemTmwfV+9chfWxrOYjzDcsEiQJA98KZWn7SLnE93oOPNUVvk xaG6Ksdo0LYscuYb6JCihNT562BF0wffts9HMuS3V8TL8MyRqFzpV89uPVU4z6myBTaV gHgQ== X-Gm-Message-State: AD7BkJJUQOU+n5WUxb1P+l/K9w3W/CuHeK7xDhC9+3y5Whv1SWrqkswB8T99IVYGng+ATNua X-Received: by 10.28.138.198 with SMTP id m189mr212347wmd.19.1458317946477; Fri, 18 Mar 2016 09:19:06 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id gg7sm12878315wjd.10.2016.03.18.09.18.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Mar 2016 09:19:00 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 727203E0535; Fri, 18 Mar 2016 16:18:56 +0000 (GMT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: mttcg@listserver.greensocs.com, fred.konrad@greensocs.com, a.rigo@virtualopensystems.com, serge.fdrv@gmail.com, cota@braap.org Date: Fri, 18 Mar 2016 16:18:51 +0000 Message-Id: <1458317932-1875-11-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1458317932-1875-1-git-send-email-alex.bennee@linaro.org> References: <1458317932-1875-1-git-send-email-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::22d Cc: Peter Crosthwaite , mark.burton@greensocs.com, qemu-devel@nongnu.org, pbonzini@redhat.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Richard Henderson Subject: [Qemu-devel] [RFC v1 10/11] tcg: grab iothread lock in cpu-exec interrupt handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Signed-off-by: Alex Bennée --- v1 (ajb) - pulled from emilio/mttcg series --- cpu-exec.c | 33 +++++++++++++++++++++++++++------ include/qom/cpu.h | 1 + 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index 76891fd..6acaf25 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -351,6 +351,29 @@ static void cpu_handle_debug_exception(CPUState *cpu) cc->debug_excp_handler(cpu); } +#ifdef CONFIG_SOFTMMU +static inline void cpu_exit_loop_lock(CPUState *cpu) +{ + qemu_mutex_lock_iothread(); + cpu->cpu_loop_exit_locked = true; +} + +static inline void cpu_exit_loop_lock_reset(CPUState *cpu) +{ + if (cpu->cpu_loop_exit_locked) { + cpu->cpu_loop_exit_locked = false; + qemu_mutex_unlock_iothread(); + } +} + +#else +static inline void cpu_exit_loop_lock(CPUState *cpu) +{ } + +static inline void cpu_exit_loop_lock_reset(CPUState *cpu) +{ } +#endif + /* main execution loop */ int cpu_exec(CPUState *cpu) @@ -450,12 +473,7 @@ int cpu_exec(CPUState *cpu) for(;;) { interrupt_request = cpu->interrupt_request; if (unlikely(interrupt_request)) { - /* FIXME: this needs to take the iothread lock. - * For this we need to find all places in - * cc->cpu_exec_interrupt that can call cpu_loop_exit, - * and call qemu_unlock_iothread_mutex() there. Else, - * add a flag telling cpu_loop_exit() to unlock it. - */ + cpu_exit_loop_lock(cpu); if (unlikely(cpu->singlestep_enabled & SSTEP_NOIRQ)) { /* Mask out external interrupts for this step. */ @@ -510,6 +528,8 @@ int cpu_exec(CPUState *cpu) next_tb = 0; } + cpu_exit_loop_lock_reset(cpu); + } if (unlikely(cpu->exit_request || replay_has_interrupt())) { @@ -630,6 +650,7 @@ int cpu_exec(CPUState *cpu) cpu->can_do_io = 1; tb_lock_reset(); + cpu_exit_loop_lock_reset(cpu); } } /* for(;;) */ diff --git a/include/qom/cpu.h b/include/qom/cpu.h index d6cb7b8..954d97d 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -295,6 +295,7 @@ struct CPUState { bool crash_occurred; bool exit_request; bool tb_invalidated_flag; + bool cpu_loop_exit_locked; uint32_t interrupt_request; int singlestep_enabled; int64_t icount_extra;