diff mbox

[1/2] Make sure to enable dirty tracking of VBE vram mapping

Message ID 1244497683-14391-1-git-send-email-aliguori@us.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Anthony Liguori June 8, 2009, 9:48 p.m. UTC
Apparently, VBE maps the VGA vram to a fixed physical location.  KVM requires
that all mappings of the VGA vram have dirty tracking enabled on them.  Any
access to the VGA vram through the VBE mapping currently fails to result in
dirty page tracking updates causing a black screen.

This is the true root cause of VMware VGA not working correctly under KVM and
likely also an issue with some of the std-vga black screen issues too.

Cirrus does not enable VBE so it would not be a problem when using Cirrus.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 hw/vga.c        |   35 +++++++++++++++++++++++++----------
 hw/vga_int.h    |    5 ++++-
 hw/vmware_vga.c |    7 +------
 3 files changed, 30 insertions(+), 17 deletions(-)
diff mbox

Patch

diff --git a/hw/vga.c b/hw/vga.c
index 013ff10..cb4b750 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -1577,6 +1577,13 @@  static void vga_sync_dirty_bitmap(VGAState *s)
         cpu_physical_sync_dirty_bitmap(isa_mem_base + 0xa0000, 0xa8000);
         cpu_physical_sync_dirty_bitmap(isa_mem_base + 0xa8000, 0xb0000);
     }
+
+#ifdef CONFIG_BOCHS_VBE
+    if (s->vbe_mapped) {
+        cpu_physical_sync_dirty_bitmap(VBE_DISPI_LFB_PHYSICAL_ADDRESS,
+                                       VBE_DISPI_LFB_PHYSICAL_ADDRESS + s->vram_size);
+    }
+#endif
 }
 
 /*
@@ -2233,6 +2240,12 @@  void vga_dirty_log_start(VGAState *s)
         kvm_log_start(isa_mem_base + 0xa0000, 0x8000);
         kvm_log_start(isa_mem_base + 0xa8000, 0x8000);
     }
+
+#ifdef CONFIG_BOCHS_VBE
+    if (kvm_enabled() && s->vbe_mapped) {
+        kvm_log_start(VBE_DISPI_LFB_PHYSICAL_ADDRESS, s->vram_size);
+    }
+#endif
 }
 
 static void vga_map(PCIDevice *pci_dev, int region_num,
@@ -2428,6 +2441,16 @@  static void vga_mm_init(VGAState *s, target_phys_addr_t vram_base,
     qemu_register_coalesced_mmio(vram_base + 0x000a0000, 0x20000);
 }
 
+void vga_init_vbe(VGAState *s)
+{
+#ifdef CONFIG_BOCHS_VBE
+    /* XXX: use optimized standard vga accesses */
+    cpu_register_physical_memory(VBE_DISPI_LFB_PHYSICAL_ADDRESS,
+                                 VGA_RAM_SIZE, s->vram_offset);
+    s->vbe_mapped = 1;
+#endif
+}
+
 int isa_vga_init(void)
 {
     VGAState *s;
@@ -2439,12 +2462,8 @@  int isa_vga_init(void)
 
     s->ds = graphic_console_init(s->update, s->invalidate,
                                  s->screen_dump, s->text_update, s);
+    vga_init_vbe(s);
 
-#ifdef CONFIG_BOCHS_VBE
-    /* XXX: use optimized standard vga accesses */
-    cpu_register_physical_memory(VBE_DISPI_LFB_PHYSICAL_ADDRESS,
-                                 VGA_RAM_SIZE, s->vram_offset);
-#endif
     return 0;
 }
 
@@ -2460,12 +2479,8 @@  int isa_vga_mm_init(target_phys_addr_t vram_base,
 
     s->ds = graphic_console_init(s->update, s->invalidate,
                                  s->screen_dump, s->text_update, s);
+    vga_init_vbe(s);
 
-#ifdef CONFIG_BOCHS_VBE
-    /* XXX: use optimized standard vga accesses */
-    cpu_register_physical_memory(VBE_DISPI_LFB_PHYSICAL_ADDRESS,
-                                 VGA_RAM_SIZE, s->vram_offset);
-#endif
     return 0;
 }
 
diff --git a/hw/vga_int.h b/hw/vga_int.h
index 631b1b0..0b41254 100644
--- a/hw/vga_int.h
+++ b/hw/vga_int.h
@@ -68,7 +68,8 @@ 
     uint16_t vbe_regs[VBE_DISPI_INDEX_NB];      \
     uint32_t vbe_start_addr;                    \
     uint32_t vbe_line_offset;                   \
-    uint32_t vbe_bank_mask;
+    uint32_t vbe_bank_mask;                     \
+    int vbe_mapped;
 
 #else
 
@@ -193,6 +194,8 @@  void vga_common_init(VGAState *s, int vga_ram_size);
 void vga_init(VGAState *s);
 void vga_reset(void *s);
 
+void vga_init_vbe(VGAState *s);
+
 void vga_dirty_log_start(VGAState *s);
 
 uint32_t vga_mem_readb(void *opaque, target_phys_addr_t addr);
diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index 79da1ff..bb17698 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -1141,12 +1141,7 @@  static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size)
                                      vmsvga_invalidate_display,
                                      vmsvga_screen_dump,
                                      vmsvga_text_update, &s->vga);
-
-#ifdef CONFIG_BOCHS_VBE
-    /* XXX: use optimized standard vga accesses */
-    cpu_register_physical_memory(VBE_DISPI_LFB_PHYSICAL_ADDRESS,
-                                 vga_ram_size, s->vga.vram_offset);
-#endif
+    vga_init_vbe((VGAState *)s);
 }
 
 static void pci_vmsvga_save(QEMUFile *f, void *opaque)