From nobody Mon May 6 14:55:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1490857062244946.5001703368092; Wed, 29 Mar 2017 23:57:42 -0700 (PDT) Received: from localhost ([::1]:34006 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctU1c-000722-RH for importer@patchew.org; Thu, 30 Mar 2017 02:57:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52656) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctU02-0005ni-N0 for qemu-devel@nongnu.org; Thu, 30 Mar 2017 02:56:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctTzy-0005cq-Pb for qemu-devel@nongnu.org; Thu, 30 Mar 2017 02:56:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34308) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ctTzy-0005ao-6W for qemu-devel@nongnu.org; Thu, 30 Mar 2017 02:55:58 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 60D1067EAC; Thu, 30 Mar 2017 06:55:56 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-80.ams2.redhat.com [10.36.116.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id 395595C6CA; Thu, 30 Mar 2017 06:55:54 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id CD0E380BC9; Thu, 30 Mar 2017 08:55:52 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 60D1067EAC Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 60D1067EAC From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 30 Mar 2017 08:55:28 +0200 Message-Id: <1490856931-21732-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1490856931-21732-1-git-send-email-kraxel@redhat.com> References: <1490856931-21732-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 30 Mar 2017 06:55:56 +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] [RfC PATCH 1/4] vga: add vga_scanline_invalidated helper 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add vga_scanline_invalidated helper to check whenever a scanline was invalidated. Add a sanity check to fix OOB read access for display heights larger than 2048. Only cirrus uses this, for hardware cursor rendering, so having this work properly for the first 2048 scanlines only shouldn't be a problem as the cirrus can't handle large resolutions anyway. Also changing the invalidated_y_table size would break live migration. Signed-off-by: Gerd Hoffmann --- hw/display/vga.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/hw/display/vga.c b/hw/display/vga.c index 69c3e1d..f320946 100644 --- a/hw/display/vga.c +++ b/hw/display/vga.c @@ -1434,6 +1434,14 @@ void vga_invalidate_scanlines(VGACommonState *s, int= y1, int y2) } } =20 +static bool vga_scanline_invalidated(VGACommonState *s, int y) +{ + if (y >=3D VGA_MAX_HEIGHT) { + return false; + } + return s->invalidated_y_table[y >> 5] |=3D 1 << (y & 0x1f); +} + void vga_sync_dirty_bitmap(VGACommonState *s) { memory_region_sync_dirty_bitmap(&s->vram); @@ -1638,8 +1646,8 @@ static void vga_draw_graphic(VGACommonState *s, int f= ull_update) page1 =3D addr + bwidth - 1; update |=3D memory_region_get_dirty(&s->vram, page0, page1 - page0, DIRTY_MEMORY_VGA); - /* explicit invalidation for the hardware cursor */ - update |=3D (s->invalidated_y_table[y >> 5] >> (y & 0x1f)) & 1; + /* explicit invalidation for the hardware cursor (cirrus only) */ + update |=3D vga_scanline_invalidated(s, y); if (update) { if (y_start < 0) y_start =3D y; @@ -1686,7 +1694,7 @@ static void vga_draw_graphic(VGACommonState *s, int f= ull_update) page_max - page_min, DIRTY_MEMORY_VGA); } - memset(s->invalidated_y_table, 0, ((height + 31) >> 5) * 4); + memset(s->invalidated_y_table, 0, sizeof(s->invalidated_y_table)); } =20 static void vga_draw_blank(VGACommonState *s, int full_update) --=20 1.8.3.1 From nobody Mon May 6 14:55:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14908570648681020.1206487274326; Wed, 29 Mar 2017 23:57:44 -0700 (PDT) Received: from localhost ([::1]:34007 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctU1f-000749-KR for importer@patchew.org; Thu, 30 Mar 2017 02:57:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52659) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctU02-0005nl-My for qemu-devel@nongnu.org; Thu, 30 Mar 2017 02:56:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctTzy-0005d1-Rq for qemu-devel@nongnu.org; Thu, 30 Mar 2017 02:56:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58872) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ctTzy-0005b0-Hg for qemu-devel@nongnu.org; Thu, 30 Mar 2017 02:55:58 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 997D0C056791; Thu, 30 Mar 2017 06:55:56 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-80.ams2.redhat.com [10.36.116.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3223418136; Thu, 30 Mar 2017 06:55:54 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id EAFFE80FD6; Thu, 30 Mar 2017 08:55:52 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 997D0C056791 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 997D0C056791 From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 30 Mar 2017 08:55:29 +0200 Message-Id: <1490856931-21732-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1490856931-21732-1-git-send-email-kraxel@redhat.com> References: <1490856931-21732-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 30 Mar 2017 06:55:56 +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] [RfC PATCH 2/4] memory: add support getting and using a dirty bitmap copy. 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 , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Gerd Hoffmann , Peter Crosthwaite Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch adds support for getting and using a local copy of the dirty bitmap. memory_region_copy_and_clear_dirty() will create a copy of the dirty bitmap for the specified range, clear the dirty bitmap and return the copy. The returned bitmap can be a bit larger than requested, the range is expanded so the code can copy unsigned longs from the bitmap and avoid atomic bit update operations. memory_region_copy_get_dirty() will return the dirty status of pages, pretty much like memory_region_get_dirty(), but using the copy returned by memory_region_copy_and_clear_dirty(). Signed-off-by: Gerd Hoffmann --- exec.c | 79 +++++++++++++++++++++++++++++++++++++++++++++= ++++ include/exec/memory.h | 13 ++++++++ include/exec/ram_addr.h | 8 +++++ include/qemu/typedefs.h | 1 + memory.c | 15 ++++++++++ 5 files changed, 116 insertions(+) diff --git a/exec.c b/exec.c index e57a8a2..57c5bc9 100644 --- a/exec.c +++ b/exec.c @@ -223,6 +223,12 @@ struct CPUAddressSpace { MemoryListener tcg_as_listener; }; =20 +struct DirtyCopy { + ram_addr_t start; + ram_addr_t end; + unsigned long dirty[]; +}; + #endif =20 #if !defined(CONFIG_USER_ONLY) @@ -1061,6 +1067,79 @@ bool cpu_physical_memory_test_and_clear_dirty(ram_ad= dr_t start, return dirty; } =20 +DirtyCopy *cpu_physical_memory_copy_and_clear_dirty(ram_addr_t start, + ram_addr_t length, + unsigned client) +{ + DirtyMemoryBlocks *blocks; + unsigned long align =3D 1 << (TARGET_PAGE_BITS + BITS_PER_LEVEL); + ram_addr_t first =3D QEMU_ALIGN_DOWN(start, align); + ram_addr_t last =3D QEMU_ALIGN_UP(start + length, align); + DirtyCopy *copy; + unsigned long page, end, dest; + + copy =3D g_malloc0(sizeof(*copy) + + ((last - first) >> (TARGET_PAGE_BITS + 3))); + copy->start =3D first; + copy->end =3D last; + + page =3D first >> TARGET_PAGE_BITS; + end =3D last >> TARGET_PAGE_BITS; + dest =3D 0; + + rcu_read_lock(); + + blocks =3D atomic_rcu_read(&ram_list.dirty_memory[client]); + + while (page < end) { + unsigned long idx =3D page / DIRTY_MEMORY_BLOCK_SIZE; + unsigned long offset =3D page % DIRTY_MEMORY_BLOCK_SIZE; + unsigned long num =3D MIN(end - page, DIRTY_MEMORY_BLOCK_SIZE - of= fset); + + assert(QEMU_IS_ALIGNED(offset, (1 << BITS_PER_LEVEL))); + assert(QEMU_IS_ALIGNED(num, (1 << BITS_PER_LEVEL))); + offset >>=3D BITS_PER_LEVEL; + + bitmap_copy(copy->dirty + dest, + blocks->blocks[idx] + (offset >> BITS_PER_LEVEL), + num); + bitmap_zero(blocks->blocks[idx] + (offset >> BITS_PER_LEVEL), + num); + + page +=3D num; + dest +=3D num >> BITS_PER_LEVEL; + } + + rcu_read_unlock(); + + if (tcg_enabled()) { + tlb_reset_dirty_range_all(start, length); + } + + return copy; +} + +bool cpu_physical_memory_copy_get_dirty(DirtyCopy *copy, + ram_addr_t start, + ram_addr_t length) +{ + unsigned long page, end; + + assert(start > copy->start); + assert(start + length < copy->end); + + end =3D TARGET_PAGE_ALIGN(start + length - copy->start) >> TARGET_PAGE= _BITS; + page =3D (start - copy->start) >> TARGET_PAGE_BITS; + + while (page < end) { + if (test_bit(page, copy->dirty)) { + return true; + } + page++; + } + return false; +} + /* Called from RCU critical section */ hwaddr memory_region_section_get_iotlb(CPUState *cpu, MemoryRegionSection *section, diff --git a/include/exec/memory.h b/include/exec/memory.h index e39256a..f89cfa7 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -871,6 +871,19 @@ void memory_region_set_dirty(MemoryRegion *mr, hwaddr = addr, */ bool memory_region_test_and_clear_dirty(MemoryRegion *mr, hwaddr addr, hwaddr size, unsigned client); + +/** + * memory_region_copy_and_clear_dirty: TODO + */ +DirtyCopy *memory_region_copy_and_clear_dirty(MemoryRegion *mr, hwaddr add= r, + hwaddr size, unsigned client= ); + +/** + * memory_region_copy_get_dirty: TODO + */ +bool memory_region_copy_get_dirty(MemoryRegion *mr, DirtyCopy *copy, + hwaddr addr, hwaddr size); + /** * memory_region_sync_dirty_bitmap: Synchronize a region's dirty bitmap wi= th * any external TLBs (e.g. kvm) diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index b05dc84..3886f0a 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -343,6 +343,14 @@ bool cpu_physical_memory_test_and_clear_dirty(ram_addr= _t start, ram_addr_t length, unsigned client); =20 +DirtyCopy *cpu_physical_memory_copy_and_clear_dirty(ram_addr_t start, + ram_addr_t length, + unsigned client); + +bool cpu_physical_memory_copy_get_dirty(DirtyCopy *copy, + ram_addr_t start, + ram_addr_t length); + static inline void cpu_physical_memory_clear_dirty_range(ram_addr_t start, ram_addr_t length) { diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index e95f28c..5344aee 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -23,6 +23,7 @@ typedef struct CPUAddressSpace CPUAddressSpace; typedef struct CPUState CPUState; typedef struct DeviceListener DeviceListener; typedef struct DeviceState DeviceState; +typedef struct DirtyCopy DirtyCopy; typedef struct DisplayChangeListener DisplayChangeListener; typedef struct DisplayState DisplayState; typedef struct DisplaySurface DisplaySurface; diff --git a/memory.c b/memory.c index 4c95aaf..7d75ca6 100644 --- a/memory.c +++ b/memory.c @@ -1716,6 +1716,21 @@ bool memory_region_test_and_clear_dirty(MemoryRegion= *mr, hwaddr addr, memory_region_get_ram_addr(mr) + addr, size, client); } =20 +DirtyCopy *memory_region_copy_and_clear_dirty(MemoryRegion *mr, hwaddr add= r, + hwaddr size, unsigned client) +{ + assert(mr->ram_block); + return cpu_physical_memory_copy_and_clear_dirty( + memory_region_get_ram_addr(mr) + addr, size, client); +} + +bool memory_region_copy_get_dirty(MemoryRegion *mr, DirtyCopy *copy, + hwaddr addr, hwaddr size) +{ + assert(mr->ram_block); + return cpu_physical_memory_copy_get_dirty(copy, + memory_region_get_ram_addr(mr) + addr, size); +} =20 void memory_region_sync_dirty_bitmap(MemoryRegion *mr) { --=20 1.8.3.1 From nobody Mon May 6 14:55:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1490857060687153.19011195626058; Wed, 29 Mar 2017 23:57:40 -0700 (PDT) Received: from localhost ([::1]:34005 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctU1b-00070d-7i for importer@patchew.org; Thu, 30 Mar 2017 02:57:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52661) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctU02-0005nm-NK for qemu-devel@nongnu.org; Thu, 30 Mar 2017 02:56:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctTzy-0005cp-PC for qemu-devel@nongnu.org; Thu, 30 Mar 2017 02:56:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49052) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ctTzy-0005av-6e for qemu-devel@nongnu.org; Thu, 30 Mar 2017 02:55:58 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7357180478; Thu, 30 Mar 2017 06:55:56 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-80.ams2.redhat.com [10.36.116.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id 37428783E4; Thu, 30 Mar 2017 06:55:54 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 074E480FD7; Thu, 30 Mar 2017 08:55:53 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7357180478 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7357180478 From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 30 Mar 2017 08:55:30 +0200 Message-Id: <1490856931-21732-4-git-send-email-kraxel@redhat.com> In-Reply-To: <1490856931-21732-1-git-send-email-kraxel@redhat.com> References: <1490856931-21732-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 30 Mar 2017 06:55:56 +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] [RfC PATCH 3/4] vga: make display updates thread safe. 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The vga code clears the dirty bits *after* reading the framebuffer memory. So if the guest framebuffer updates hits the race window between vga reading the framebuffer and vga clearing the dirty bits vga will miss that update Fix it by using the new memory_region_copy_and_clear_dirty() memory_region_copy_get_dirty() functions. That way we clear the dirty bitmap before reading the framebuffer. Any guest display updates happening in parallel will be properly tracked in the dirty bitmap then and the next display refresh will pick them up. Problem triggers with mttcg only. Before mttcg was merged tcg never ran in parallel to vga emulation. Using kvm will hide the problem too, due to qemu operating on a userspace copy of the kernel's dirty bitmap. Signed-off-by: Gerd Hoffmann --- hw/display/vga.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/hw/display/vga.c b/hw/display/vga.c index f320946..7daccb8 100644 --- a/hw/display/vga.c +++ b/hw/display/vga.c @@ -1465,7 +1465,8 @@ static void vga_draw_graphic(VGACommonState *s, int f= ull_update) DisplaySurface *surface =3D qemu_console_surface(s->con); int y1, y, update, linesize, y_start, double_scan, mask, depth; int width, height, shift_control, line_offset, bwidth, bits; - ram_addr_t page0, page1, page_min, page_max; + ram_addr_t page0, page1; + DirtyCopy *copy =3D NULL; int disp_width, multi_scan, multi_run; uint8_t *d; uint32_t v, addr1, addr; @@ -1480,9 +1481,6 @@ static void vga_draw_graphic(VGACommonState *s, int f= ull_update) =20 full_update |=3D update_basic_params(s); =20 - if (!full_update) - vga_sync_dirty_bitmap(s); - s->get_resolution(s, &width, &height); disp_width =3D width; =20 @@ -1625,11 +1623,17 @@ static void vga_draw_graphic(VGACommonState *s, int= full_update) addr1 =3D (s->start_addr * 4); bwidth =3D (width * bits + 7) / 8; y_start =3D -1; - page_min =3D -1; - page_max =3D 0; d =3D surface_data(surface); linesize =3D surface_stride(surface); y1 =3D 0; + + if (!full_update) { + vga_sync_dirty_bitmap(s); + copy =3D memory_region_copy_and_clear_dirty(&s->vram, addr1, + bwidth * height, + DIRTY_MEMORY_VGA); + } + for(y =3D 0; y < height; y++) { addr =3D addr1; if (!(s->cr[VGA_CRTC_MODE] & 1)) { @@ -1644,17 +1648,17 @@ static void vga_draw_graphic(VGACommonState *s, int= full_update) update =3D full_update; page0 =3D addr; page1 =3D addr + bwidth - 1; - update |=3D memory_region_get_dirty(&s->vram, page0, page1 - page0, - DIRTY_MEMORY_VGA); + if (full_update) { + update =3D 1; + } else { + update =3D memory_region_copy_get_dirty(&s->vram, copy, + page0, page1 - page0); + } /* explicit invalidation for the hardware cursor (cirrus only) */ update |=3D vga_scanline_invalidated(s, y); if (update) { if (y_start < 0) y_start =3D y; - if (page0 < page_min) - page_min =3D page0; - if (page1 > page_max) - page_max =3D page1; if (!(is_buffer_shared(surface))) { vga_draw_line(s, d, s->vram_ptr + addr, width); if (s->cursor_draw_line) @@ -1687,13 +1691,7 @@ static void vga_draw_graphic(VGACommonState *s, int = full_update) dpy_gfx_update(s->con, 0, y_start, disp_width, y - y_start); } - /* reset modified pages */ - if (page_max >=3D page_min) { - memory_region_reset_dirty(&s->vram, - page_min, - page_max - page_min, - DIRTY_MEMORY_VGA); - } + g_free(copy); memset(s->invalidated_y_table, 0, sizeof(s->invalidated_y_table)); } =20 --=20 1.8.3.1 From nobody Mon May 6 14:55:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1490857109997880.3742673228991; Wed, 29 Mar 2017 23:58:29 -0700 (PDT) Received: from localhost ([::1]:34008 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctU2O-0007hU-O0 for importer@patchew.org; Thu, 30 Mar 2017 02:58:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52667) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctU02-0005nn-OK for qemu-devel@nongnu.org; Thu, 30 Mar 2017 02:56:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctTzy-0005ca-PN for qemu-devel@nongnu.org; Thu, 30 Mar 2017 02:56:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28424) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ctTzy-0005ah-6b for qemu-devel@nongnu.org; Thu, 30 Mar 2017 02:55:58 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 209BE3D958; Thu, 30 Mar 2017 06:55:56 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-80.ams2.redhat.com [10.36.116.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2F86C783DB; Thu, 30 Mar 2017 06:55:54 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 15CEE80FCB; Thu, 30 Mar 2017 08:55:53 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 209BE3D958 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 209BE3D958 From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 30 Mar 2017 08:55:31 +0200 Message-Id: <1490856931-21732-5-git-send-email-kraxel@redhat.com> In-Reply-To: <1490856931-21732-1-git-send-email-kraxel@redhat.com> References: <1490856931-21732-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 30 Mar 2017 06:55:56 +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] [RfC PATCH 4/4] [testing] console: remove do_safe_dpy_refresh 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Drop the temporary workaround for the broken display updates. TODO: before actually merging this we have to fix all the non-vga display adapters too ... Signed-off-by: Gerd Hoffmann --- ui/console.c | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/ui/console.c b/ui/console.c index 419b098..4c70d8b 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1575,36 +1575,13 @@ bool dpy_gfx_check_format(QemuConsole *con, return true; } =20 -/* - * Safe DPY refresh for TCG guests. We use the exclusive mechanism to - * ensure 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(DisplayChangeListener *dcl) -{ - qemu_mutex_unlock_iothread(); - start_exclusive(); - qemu_mutex_lock_iothread(); - dcl->ops->dpy_refresh(dcl); - qemu_mutex_unlock_iothread(); - end_exclusive(); - qemu_mutex_lock_iothread(); -} - static void dpy_refresh(DisplayState *s) { DisplayChangeListener *dcl; =20 QLIST_FOREACH(dcl, &s->listeners, next) { if (dcl->ops->dpy_refresh) { - if (tcg_enabled()) { - do_safe_dpy_refresh(dcl); - } else { - dcl->ops->dpy_refresh(dcl); - } + dcl->ops->dpy_refresh(dcl); } } } --=20 1.8.3.1