From patchwork Wed Jan 25 12:12:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfgang Bumiller X-Patchwork-Id: 9536981 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 F387E6046A for ; Wed, 25 Jan 2017 12:14:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E532527F89 for ; Wed, 25 Jan 2017 12:14:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA4D427F94; Wed, 25 Jan 2017 12:14:51 +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 D3AEA27F89 for ; Wed, 25 Jan 2017 12:14:50 +0000 (UTC) Received: from localhost ([::1]:59447 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWMTR-0007tl-Vc for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Jan 2017 07:14:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38776) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWMRR-00070W-NF for qemu-devel@nongnu.org; Wed, 25 Jan 2017 07:12:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cWMRN-0003C9-OK for qemu-devel@nongnu.org; Wed, 25 Jan 2017 07:12:45 -0500 Received: from proxmox.maurer-it.com ([212.186.127.180]:53680) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cWMRN-0003AP-Gv for qemu-devel@nongnu.org; Wed, 25 Jan 2017 07:12:41 -0500 Received: from proxmox.maurer-it.com (localhost [127.0.0.1]) by proxmox.maurer-it.com (Proxmox) with ESMTP id 78F8210A7639; Wed, 25 Jan 2017 13:12:38 +0100 (CET) From: Wolfgang Bumiller To: qemu-devel@nongnu.org Date: Wed, 25 Jan 2017 13:12:33 +0100 Message-Id: <1485346353-23814-1-git-send-email-w.bumiller@proxmox.com> X-Mailer: git-send-email 2.1.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 212.186.127.180 Subject: [Qemu-devel] [PATCH] cirrus: handle negative pitch in cirrus_invalidate_region() 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: Laszlo Ersek , Li Qiang , Gerd Hoffmann Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP cirrus_invalidate_region() calls memory_region_set_dirty() on a per-line basis, always ranging from off_begin to off_begin+bytesperline. With a negative pitch off_begin marks the top most used address and thus we need to do an initial shift backwards by bytesperline for negative pitches of backward blits, otherwise the first iteration covers the line going from the start offset forwards instead of backwards. Signed-off-by: Wolfgang Bumiller --- I bumped the patch context to 4 lines to get it to include the memory_region_set_dirty() call which takes an unsigned length (`hwaddr size`) because I'm also not too happy about the masking going on there since it means off_cur_end may be less than off_cur, but if the range checks are finnaly correct I don't think this case could happen anymore? (A check shouldn't hurt though, or maybe an assert()?) hw/display/cirrus_vga.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c index b1a0773..af61981 100644 --- a/hw/display/cirrus_vga.c +++ b/hw/display/cirrus_vga.c @@ -669,8 +669,12 @@ static void cirrus_invalidate_region(CirrusVGAState * s, int off_begin, int y; int off_cur; int off_cur_end; + if (off_pitch < 0) { + off_begin -= bytesperline; + } + for (y = 0; y < lines; y++) { off_cur = off_begin; off_cur_end = (off_cur + bytesperline) & s->cirrus_addr_mask; memory_region_set_dirty(&s->vga.vram, off_cur, off_cur_end - off_cur);