Skip to contentSkip to conversation

vga: Initialise VRAM with 0

PATCH In review Stefan Weil 2 participants 2 messages May 23, 2012 – May 24, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vga: Initialise VRAM with 0

The VNC code reads this memory before it is written by BIOS or other code. Avoid random values by setting the VRAM to 0.

This bug was reported by Valgrind.

---
 hw/vga.c |    1 +
 1 file changed, 1 insertion(+)
hw/vga.c +1 -0
index 1469680..80b8ec3 100644
@@ -2283,6 +2283,7 @@ void vga_common_init(VGACommonState *s, int vga_ram_size)
         s->update_retrace_info = vga_precise_update_retrace_info;
         break;
     }
+    memset(s->vram_ptr, 0, s->vram_size);
     vga_dirty_log_start(s);
 }
 
Signature · 1 line
1.7.10
#1 lore raw
Quoted 4 lines · Stefan Weil

The VNC code reads this memory before it is written by BIOS or other code. Avoid random values by setting the VRAM to 0.

This bug was reported by Valgrind.

Please do not apply this patch: it breaks VGA restore on Xen: the videoram is saved and restored by the hypervisor as part of the main memory of the VM, so at this point at restore time we would be resetting useful data (the current state of the videoram).

Can we ignore the Valgrind warning? Or can we add:

if (not_migrate)
memset

instead? Or if worst comes to worst:

if (not_xen)
memset

Quoted 21 lines
---
 hw/vga.c |    1 +
 1 file changed, 1 insertion(+)
hw/vga.c +1 -0
index 1469680..80b8ec3 100644
@@ -2283,6 +2283,7 @@ void vga_common_init(VGACommonState *s, int vga_ram_size)
         s->update_retrace_info = vga_precise_update_retrace_info;
         break;
     }
+    memset(s->vram_ptr, 0, s->vram_size);
     vga_dirty_log_start(s);
 }
 
Signature · 1 line
1.7.10