From patchwork Tue Mar 28 08:36:20 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: 96113 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp1601307qgd; Tue, 28 Mar 2017 01:38:06 -0700 (PDT) X-Received: by 10.55.16.3 with SMTP id a3mr11198728qkh.81.1490690286270; Tue, 28 Mar 2017 01:38:06 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n185si2915629qkf.137.2017.03.28.01.38.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 28 Mar 2017 01:38:06 -0700 (PDT) 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]:51566 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csmdh-0000m7-S4 for patch@linaro.org; Tue, 28 Mar 2017 04:38:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34166) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csmc9-0008GO-9j for qemu-devel@nongnu.org; Tue, 28 Mar 2017 04:36:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csmc8-00015D-EU for qemu-devel@nongnu.org; Tue, 28 Mar 2017 04:36:29 -0400 Received: from mail-wr0-x230.google.com ([2a00:1450:400c:c0c::230]:35170) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1csmc8-00014S-7n for qemu-devel@nongnu.org; Tue, 28 Mar 2017 04:36:28 -0400 Received: by mail-wr0-x230.google.com with SMTP id u1so92922063wra.2 for ; Tue, 28 Mar 2017 01:36:28 -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=JCQcVoB9U4xa6DiRX5jw8lbZ+YKJQ8uMF2rGlsezMmQ=; b=C+EGTTBnuNdemLCQMsHZIph8DAq1v/uiHxa3f5SWXOqJl+zh3cdERc3VcLjl/gSnAK ru71q48HtMNtRjlnH9gcp7vdfBLwg/71vzyQ3vNuN7NdoDYVCJAFDG9pCH1ay76+uwat 6qpERKdkwWF267fX8JKgeXkUHJrKOxb4A7Z5s= 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=JCQcVoB9U4xa6DiRX5jw8lbZ+YKJQ8uMF2rGlsezMmQ=; b=fj4v0J4/R/4Mpt8JQkXd1tBJx+q//fiMXBK9yDdimmYgWCz9sXE1dFf5H7XWDx4XmN eIweltVO1cv062Zs2A6i6az3XuVmnBfHLDWULSAmSX0rXDaHZcQxhhRmptw2GZvcR1md dvtF5p3Pk+zPyjEGxC3VMfseP59e6JPal705G0jSvdps3JS1J93MnuH28QhFuBoBXzdU np310cmcsjFJowlgleOie2L0Q2lavFZBeoDIW5kf/bn4Ogt7OYYKF9PRCMTC7kJYPEQ7 W0xc9V6CBj7ezYtssZKkYaBpv/wHVbgrww1YAGyp7xSSlBG/w9aQzuItshG8V4c839y1 ohWQ== X-Gm-Message-State: AFeK/H1z2kyldhW+Gv1ontDWkytYGGVhLPGXWpuXkDa/oWkuBNHHxaabXXRxDW6OYkKwpQCH X-Received: by 10.223.171.79 with SMTP id r15mr14031222wrc.148.1490690187199; Tue, 28 Mar 2017 01:36:27 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id v108sm3867130wrc.41.2017.03.28.01.36.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Mar 2017 01:36:25 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 630E73E0600; Tue, 28 Mar 2017 09:36:23 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org, rth@twiddle.net, pbonzini@redhat.com, kraxel@redhat.com Date: Tue, 28 Mar 2017 09:36:20 +0100 Message-Id: <20170328083623.10396-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170328083623.10396-1-alex.bennee@linaro.org> References: <20170328083623.10396-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::230 Subject: [Qemu-devel] [PATCH v2 3/6] ui/console: ensure do_safe_dpy_refresh holds BQL 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, Peter Crosthwaite , a.rigo@virtualopensystems.com, qemu-devel@nongnu.org, cota@braap.org, bobby.prani@gmail.com, =?utf-8?q?Alex_Benn=C3=A9e?= , fred.konrad@greensocs.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" I missed the fact that when an exclusive work item runs it drops the BQL to ensure all no vCPUs are stuck waiting for it, hence causing a deadlock. However the actual helper needs to take the BQL especially as we'll be messing with device emulation bits during the update which all assume BQL is held. We make a minor cpu_reloading_memory_map which must try and unlock the RCU if we are actually outside the running context. Reported-by: Laurent Desnogues CC: Gerd Hoffmann CC: Paolo Bonzini Signed-off-by: Alex Bennée --- cpu-exec-common.c | 2 +- ui/console.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) -- 2.11.0 diff --git a/cpu-exec-common.c b/cpu-exec-common.c index 0504a9457b..e81da276bb 100644 --- a/cpu-exec-common.c +++ b/cpu-exec-common.c @@ -35,7 +35,7 @@ void cpu_loop_exit_noexc(CPUState *cpu) #if defined(CONFIG_SOFTMMU) void cpu_reloading_memory_map(void) { - if (qemu_in_vcpu_thread()) { + if (qemu_in_vcpu_thread() && current_cpu->running) { /* The guest can in theory prolong the RCU critical section as long * as it feels like. The major problem with this is that because it * can do multiple reconfigurations of the memory map within the diff --git a/ui/console.c b/ui/console.c index 937c950840..dd27c9501b 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1586,7 +1586,9 @@ bool dpy_gfx_check_format(QemuConsole *con, static void do_safe_dpy_refresh(CPUState *cpu, run_on_cpu_data opaque) { DisplayChangeListener *dcl = opaque.host_ptr; + qemu_mutex_lock_iothread(); dcl->ops->dpy_refresh(dcl); + qemu_mutex_unlock_iothread(); } static void dpy_refresh(DisplayState *s)