Blame SOURCES/kvm-cirrus-handle-negative-pitch-in-cirrus_invalidate_re.patch

4f5da8
From 1d7bdd730d1537f931a95897b14fdb6c5754ea2c Mon Sep 17 00:00:00 2001
4f5da8
From: Gerd Hoffmann <kraxel@redhat.com>
4f5da8
Date: Tue, 7 Feb 2017 10:07:49 +0100
4f5da8
Subject: [PATCH 5/8] cirrus: handle negative pitch in
4f5da8
 cirrus_invalidate_region()
4f5da8
4f5da8
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
4f5da8
Message-id: <1486462072-32174-5-git-send-email-kraxel@redhat.com>
4f5da8
Patchwork-id: 73566
4f5da8
O-Subject: [RHEL-7.4 qemu-kvm PATCH 4/7] cirrus: handle negative pitch in cirrus_invalidate_region()
4f5da8
Bugzilla: 1418232
4f5da8
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
4f5da8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
4f5da8
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
4f5da8
4f5da8
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
4f5da8
4f5da8
cirrus_invalidate_region() calls memory_region_set_dirty()
4f5da8
on a per-line basis, always ranging from off_begin to
4f5da8
off_begin+bytesperline. With a negative pitch off_begin
4f5da8
marks the top most used address and thus we need to do an
4f5da8
initial shift backwards by a line for negative pitches of
4f5da8
backward blits, otherwise the first iteration covers the
4f5da8
line going from the start offset forwards instead of
4f5da8
backwards.
4f5da8
Additionally since the start address is inclusive, if we
4f5da8
shift by a full `bytesperline` we move to the first address
4f5da8
*not* included in the blit, so we only shift by one less
4f5da8
than bytesperline.
4f5da8
4f5da8
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4f5da8
Message-id: 1485352137-29367-1-git-send-email-w.bumiller@proxmox.com
4f5da8
4f5da8
[ kraxel: codestyle fixes ]
4f5da8
4f5da8
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
4f5da8
(cherry picked from commit f153b563f8cf121aebf5a2fff5f0110faf58ccb3)
4f5da8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4f5da8
---
4f5da8
 hw/display/cirrus_vga.c | 5 +++++
4f5da8
 1 file changed, 5 insertions(+)
4f5da8
4f5da8
diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
4f5da8
index c8f2f26..e09076a 100644
4f5da8
--- a/hw/display/cirrus_vga.c
4f5da8
+++ b/hw/display/cirrus_vga.c
4f5da8
@@ -656,9 +656,14 @@ static void cirrus_invalidate_region(CirrusVGAState * s, int off_begin,
4f5da8
     int off_cur;
4f5da8
     int off_cur_end;
4f5da8
 
4f5da8
+    if (off_pitch < 0) {
4f5da8
+        off_begin -= bytesperline - 1;
4f5da8
+    }
4f5da8
+
4f5da8
     for (y = 0; y < lines; y++) {
4f5da8
 	off_cur = off_begin;
4f5da8
 	off_cur_end = (off_cur + bytesperline) & s->cirrus_addr_mask;
4f5da8
+        assert(off_cur_end >= off_cur);
4f5da8
         memory_region_set_dirty(&s->vga.vram, off_cur, off_cur_end - off_cur);
4f5da8
 	off_begin += off_pitch;
4f5da8
     }
4f5da8
-- 
4f5da8
1.8.3.1
4f5da8