diff mbox

[1.1] vga: Initialise VRAM with 0

Message ID 1337806454-4084-1-git-send-email-sw@weilnetz.de
State Under Review
Headers show

Commit Message

Stefan Weil May 23, 2012, 8:54 p.m. UTC
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.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 hw/vga.c |    1 +
 1 file changed, 1 insertion(+)

Comments

Stefano Stabellini May 24, 2012, 11:18 a.m. UTC | #1
On Wed, 23 May 2012, Stefan Weil wrote:
> 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



> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>  hw/vga.c |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/vga.c b/hw/vga.c
> index 1469680..80b8ec3 100644
> --- a/hw/vga.c
> +++ b/hw/vga.c
> @@ -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);
>  }
>  
> -- 
> 1.7.10
> 
>
diff mbox

Patch

diff --git a/hw/vga.c b/hw/vga.c
index 1469680..80b8ec3 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -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);
 }