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: 95479 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp840147qgd; Mon, 20 Mar 2017 01:55:57 -0700 (PDT) X-Received: by 10.55.135.66 with SMTP id j63mr19999065qkd.310.1490000157648; Mon, 20 Mar 2017 01:55:57 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 19si12415935qkk.44.2017.03.20.01.55.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 20 Mar 2017 01:55:57 -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; 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 Received: from localhost ([::1]:59892 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cpt6b-0003Cq-5K for patch@linaro.org; Mon, 20 Mar 2017 04:55:57 -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_Benn=C3=A9e?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 1.8.3.1 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); + } } } }