vga: make display updates thread safe.
commitfec5e8c92becad223df9d972770522f64aafdb72
authorGerd Hoffmann <kraxel@redhat.com>
Fri, 21 Apr 2017 09:16:27 +0000 (21 11:16 +0200)
committerGerd Hoffmann <kraxel@redhat.com>
Mon, 24 Apr 2017 08:12:28 +0000 (24 10:12 +0200)
tree004929ca50deead19525ab056701a4b628cd70cb
parentf3289f6f0f9781d1fe77b4cfc3f18a6336eaed72
vga: make display updates thread safe.

The vga code clears the dirty bits *after* reading the framebuffer
memory.  So if the guest framebuffer updates hits the race window
between vga reading the framebuffer and vga clearing the dirty bits
vga will miss that update

Fix it by using the new memory_region_copy_and_clear_dirty()
memory_region_copy_get_dirty() functions.  That way we clear the
dirty bitmap before reading the framebuffer.  Any guest display
updates happening in parallel will be properly tracked in the
dirty bitmap then and the next display refresh will pick them up.

Problem triggers with mttcg only.  Before mttcg was merged tcg
never ran in parallel to vga emulation.  Using kvm will hide the
problem too, due to qemu operating on a userspace copy of the
kernel's dirty bitmap.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20170421091632.30900-5-kraxel@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/display/vga.c