qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH][RESEND] Fix vga segfaults or screen corruption with large memory guests
@ 2009-04-27 10:55 Avi Kivity
  2009-04-27 18:02 ` Blue Swirl
  0 siblings, 1 reply; 2+ messages in thread
From: Avi Kivity @ 2009-04-27 10:55 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: qemu-devel

page0 and friends are ram addresses; a smaller size will overflow and
cause a segfault or random corruption.

Change them to ram_addr_t.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 hw/vga.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/hw/vga.c b/hw/vga.c
index 2f122ee..517ce3d 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -1584,8 +1584,9 @@ static void vga_sync_dirty_bitmap(VGAState *s)
  */
 static void vga_draw_graphic(VGAState *s, int full_update)
 {
-    int y1, y, update, page_min, page_max, linesize, y_start, double_scan, mask, depth;
-    int width, height, shift_control, line_offset, page0, page1, bwidth, bits;
+    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;
     int disp_width, multi_scan, multi_run;
     uint8_t *d;
     uint32_t v, addr1, addr;
@@ -1723,8 +1724,8 @@ static void vga_draw_graphic(VGAState *s, int full_update)
     addr1 = (s->start_addr * 4);
     bwidth = (width * bits + 7) / 8;
     y_start = -1;
-    page_min = 0x7fffffff;
-    page_max = -1;
+    page_min = -1;
+    page_max = 0;
     d = ds_get_data(s->ds);
     linesize = ds_get_linesize(s->ds);
     y1 = 0;
@@ -1791,7 +1792,7 @@ static void vga_draw_graphic(VGAState *s, int full_update)
                    disp_width, y - y_start);
     }
     /* reset modified pages */
-    if (page_max != -1) {
+    if (page_max >= page_min) {
         cpu_physical_memory_reset_dirty(page_min, page_max + TARGET_PAGE_SIZE,
                                         VGA_DIRTY_FLAG);
     }
-- 
1.6.1.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH][RESEND] Fix vga segfaults or screen corruption with large memory guests
  2009-04-27 10:55 [Qemu-devel] [PATCH][RESEND] Fix vga segfaults or screen corruption with large memory guests Avi Kivity
@ 2009-04-27 18:02 ` Blue Swirl
  0 siblings, 0 replies; 2+ messages in thread
From: Blue Swirl @ 2009-04-27 18:02 UTC (permalink / raw)
  To: Avi Kivity; +Cc: qemu-devel

On 4/27/09, Avi Kivity <avi@redhat.com> wrote:
> page0 and friends are ram addresses; a smaller size will overflow and
>  cause a segfault or random corruption.
>
>  Change them to ram_addr_t.
>
>  Signed-off-by: Avi Kivity <avi@redhat.com>

Thanks, applied.

At least TCX needs a similar fix.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-04-27 18:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-27 10:55 [Qemu-devel] [PATCH][RESEND] Fix vga segfaults or screen corruption with large memory guests Avi Kivity
2009-04-27 18:02 ` Blue Swirl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).