From patchwork Mon Mar 20 08:54:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 9633207 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F07DC60327 for ; Mon, 20 Mar 2017 08:55:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E27B328112 for ; Mon, 20 Mar 2017 08:55:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D755F28174; Mon, 20 Mar 2017 08:55:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id DBC9F2811C for ; Mon, 20 Mar 2017 08:55:09 +0000 (UTC) Received: from localhost ([::1]:59892 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cpt5o-0003Cq-K9 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 20 Mar 2017 04:55:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35969) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cpt5W-0003Cd-Eo for qemu-devel@nongnu.org; Mon, 20 Mar 2017 04:54:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cpt5T-0000Gj-Al for qemu-devel@nongnu.org; Mon, 20 Mar 2017 04:54:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11228) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cpt5T-0000GQ-2I for qemu-devel@nongnu.org; Mon, 20 Mar 2017 04:54:47 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BF89D3710C9; Mon, 20 Mar 2017 08:54:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BF89D3710C9 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BF89D3710C9 Received: from nilsson.home.kraxel.org (ovpn-116-104.ams2.redhat.com [10.36.116.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id 183A218654; Mon, 20 Mar 2017 08:54:42 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 1FC3B807C6; Mon, 20 Mar 2017 09:54:40 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 20 Mar 2017 09:54:36 +0100 Message-Id: <1490000078-31202-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1490000078-31202-1-git-send-email-kraxel@redhat.com> References: <1490000078-31202-1-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 20 Mar 2017 08:54:46 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-2.9 1/3] ui/console: ensure graphic updates don't race with TCG vCPUs 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: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Alex Bennée Commit 8d04fb55.. tcg: drop global lock during TCG code execution ..broke the assumption that updates to the GUI couldn't happen at the same time as TCG vCPUs where running. As a result the TCG vCPU could still be updating a directly mapped frame-buffer while the display side was updating. This would cause artefacts to appear when the update code assumed that memory block hadn't changed. The simplest solution is to ensure the two things can't happen at the same time like the old BQL locking scheme. Here we use the solution introduced for MTTCG and schedule the update as async_safe_work when we know no vCPUs can be running. Reported-by: Mark Cave-Ayland Signed-off-by: Alex Bennée Message-id: 20170315144825.3108-1-alex.bennee@linaro.org Cc: BALATON Zoltan Cc: Gerd Hoffmann Cc: Paolo Bonzini Signed-off-by: Alex Bennée [ kraxel: updated comment clarifying the display adapters are buggy and this is a temporary workaround ] Signed-off-by: Gerd Hoffmann --- ui/console.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/ui/console.c b/ui/console.c index 4c70d8b..937c950 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1575,13 +1575,32 @@ bool dpy_gfx_check_format(QemuConsole *con, return true; } +/* + * Safe DPY refresh for TCG guests. This runs when the TCG vCPUs are + * quiescent so we can avoid races between dirty page tracking for + * direct frame-buffer access by the guest. + * + * This is a temporary stopgap until we've fixed the dirty tracking + * races in display adapters. + */ +static void do_safe_dpy_refresh(CPUState *cpu, run_on_cpu_data opaque) +{ + DisplayChangeListener *dcl = opaque.host_ptr; + dcl->ops->dpy_refresh(dcl); +} + static void dpy_refresh(DisplayState *s) { DisplayChangeListener *dcl; QLIST_FOREACH(dcl, &s->listeners, next) { if (dcl->ops->dpy_refresh) { - dcl->ops->dpy_refresh(dcl); + if (tcg_enabled()) { + async_safe_run_on_cpu(first_cpu, do_safe_dpy_refresh, + RUN_ON_CPU_HOST_PTR(dcl)); + } else { + dcl->ops->dpy_refresh(dcl); + } } } }