* [Qemu-devel] qemu fixup patch sequence. @ 2009-12-17 22:08 Dave Airlie 2009-12-17 22:08 ` [Qemu-devel] [PATCH 1/6] vmware: setup PCI BAR 2 for FIFO as per vmware spec Dave Airlie 0 siblings, 1 reply; 7+ messages in thread From: Dave Airlie @ 2009-12-17 22:08 UTC (permalink / raw) To: qemu-devel First patch adds a second PCI BAR as per the VMware SVGA specification for the fifo instead of using the top of the VRAM BAR. Patches 2-5 are from Anthony and I just rebased them on top of master. Patch6: fixes a crasher in vmware when X starts inside the guest. I've booted these with an F12 LiveCD and all seems to work. Dave. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 1/6] vmware: setup PCI BAR 2 for FIFO as per vmware spec 2009-12-17 22:08 [Qemu-devel] qemu fixup patch sequence Dave Airlie @ 2009-12-17 22:08 ` Dave Airlie 2009-12-17 22:08 ` [Qemu-devel] [PATCH 2/6] Make sure to enable dirty tracking of VBE vram mapping Dave Airlie 0 siblings, 1 reply; 7+ messages in thread From: Dave Airlie @ 2009-12-17 22:08 UTC (permalink / raw) To: qemu-devel From: Dave Airlie <airlied@linux.ie> --- hw/vmware_vga.c | 35 ++++++++++++++++++++++++++++++----- 1 files changed, 30 insertions(+), 5 deletions(-) diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c index f3e3749..28bbc3f 100644 --- a/hw/vmware_vga.c +++ b/hw/vmware_vga.c @@ -67,6 +67,11 @@ struct vmsvga_state_s { int syncing; int fb_size; + ram_addr_t fifo_offset; + uint8_t *fifo_ptr; + unsigned int fifo_size; + target_phys_addr_t fifo_base; + union { uint32_t *fifo; struct __attribute__((__packed__)) { @@ -680,7 +685,7 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address) return 0x0; case SVGA_REG_VRAM_SIZE: - return s->vga.vram_size - SVGA_FIFO_SIZE; + return s->vga.vram_size; case SVGA_REG_FB_SIZE: return s->fb_size; @@ -701,10 +706,10 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address) return caps; case SVGA_REG_MEM_START: - return s->vram_base + s->vga.vram_size - SVGA_FIFO_SIZE; + return s->fifo_base; case SVGA_REG_MEM_SIZE: - return SVGA_FIFO_SIZE; + return s->fifo_size; case SVGA_REG_CONFIG_DONE: return s->config; @@ -790,7 +795,7 @@ static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value) case SVGA_REG_CONFIG_DONE: if (value) { - s->fifo = (uint32_t *) &s->vga.vram_ptr[s->vga.vram_size - SVGA_FIFO_SIZE]; + s->fifo = (uint32_t *) s->fifo_ptr; /* Check range and alignment. */ if ((CMD(min) | CMD(max) | CMD(next_cmd) | CMD(stop)) & 3) @@ -1059,7 +1064,7 @@ static int vmsvga_post_load(void *opaque, int version_id) s->invalidated = 1; if (s->config) - s->fifo = (uint32_t *) &s->vga.vram_ptr[s->vga.vram_size - SVGA_FIFO_SIZE]; + s->fifo = (uint32_t *) s->fifo_ptr; return 0; } @@ -1111,6 +1116,10 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size) vmsvga_reset(s); + s->fifo_size = SVGA_FIFO_SIZE; + s->fifo_offset = qemu_ram_alloc(s->fifo_size); + s->fifo_ptr = qemu_get_ram_ptr(s->fifo_offset); + vga_common_init(&s->vga, vga_ram_size); vga_init(&s->vga); vmstate_register(0, &vmstate_vga_common, &s->vga); @@ -1166,6 +1175,19 @@ static void pci_vmsvga_map_mem(PCIDevice *pci_dev, int region_num, iomemtype); } +static void pci_vmsvga_map_fifo(PCIDevice *pci_dev, int region_num, + pcibus_t addr, pcibus_t size, int type) +{ + struct pci_vmsvga_state_s *d = (struct pci_vmsvga_state_s *) pci_dev; + struct vmsvga_state_s *s = &d->chip; + ram_addr_t iomemtype; + + s->fifo_base = addr; + iomemtype = s->fifo_offset | IO_MEM_RAM; + cpu_register_physical_memory(s->fifo_base, s->fifo_size, + iomemtype); +} + static int pci_vmsvga_initfn(PCIDevice *dev) { struct pci_vmsvga_state_s *s = @@ -1189,6 +1211,9 @@ static int pci_vmsvga_initfn(PCIDevice *dev) pci_register_bar(&s->card, 1, VGA_RAM_SIZE, PCI_BASE_ADDRESS_MEM_PREFETCH, pci_vmsvga_map_mem); + pci_register_bar(&s->card, 2, SVGA_FIFO_SIZE, + PCI_BASE_ADDRESS_MEM_PREFETCH, pci_vmsvga_map_fifo); + vmsvga_init(&s->chip, VGA_RAM_SIZE); return 0; -- 1.6.5.2 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 2/6] Make sure to enable dirty tracking of VBE vram mapping 2009-12-17 22:08 ` [Qemu-devel] [PATCH 1/6] vmware: setup PCI BAR 2 for FIFO as per vmware spec Dave Airlie @ 2009-12-17 22:08 ` Dave Airlie 2009-12-17 22:08 ` [Qemu-devel] [PATCH 3/6] Make sure to enable dirty log tracking for VMware VGA Dave Airlie 0 siblings, 1 reply; 7+ messages in thread From: Dave Airlie @ 2009-12-17 22:08 UTC (permalink / raw) To: qemu-devel From: Anthony Liguori <aliguori@us.ibm.com> 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> Rebased-by: Dave Airlie <airlied@redhat.com> --- hw/vga-isa.c | 6 +----- hw/vga-pci.c | 7 +------ hw/vga.c | 24 ++++++++++++++++++++++++ hw/vga_int.h | 5 +++-- hw/vmware_vga.c | 8 ++------ 5 files changed, 31 insertions(+), 19 deletions(-) diff --git a/hw/vga-isa.c b/hw/vga-isa.c index 5f29904..7937144 100644 --- a/hw/vga-isa.c +++ b/hw/vga-isa.c @@ -42,11 +42,7 @@ int isa_vga_init(void) s->ds = graphic_console_init(s->update, s->invalidate, s->screen_dump, s->text_update, 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 + vga_init_vbe(s); /* ROM BIOS */ rom_add_vga(VGABIOS_FILENAME); return 0; diff --git a/hw/vga-pci.c b/hw/vga-pci.c index e8cc024..eef78ed 100644 --- a/hw/vga-pci.c +++ b/hw/vga-pci.c @@ -106,12 +106,7 @@ static int pci_vga_initfn(PCIDevice *dev) PCI_BASE_ADDRESS_MEM_PREFETCH, vga_map); } -#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 - + vga_init_vbe(s); /* ROM BIOS */ rom_add_vga(VGABIOS_FILENAME); return 0; diff --git a/hw/vga.c b/hw/vga.c index 740fe28..5b0c55e 100644 --- a/hw/vga.c +++ b/hw/vga.c @@ -1581,6 +1581,14 @@ static void vga_sync_dirty_bitmap(VGACommonState *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 + } void vga_dirty_log_start(VGACommonState *s) @@ -1592,6 +1600,13 @@ void vga_dirty_log_start(VGACommonState *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 + } /* @@ -2294,6 +2309,15 @@ void vga_init(VGACommonState *s) qemu_register_coalesced_mmio(isa_mem_base + 0x000a0000, 0x20000); } +void vga_init_vbe(VGACommonState *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 +} /********************************************************/ /* vga screen dump */ diff --git a/hw/vga_int.h b/hw/vga_int.h index c03c220..b5302c1 100644 --- a/hw/vga_int.h +++ b/hw/vga_int.h @@ -71,8 +71,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 #define VGA_STATE_COMMON_BOCHS_VBE @@ -217,6 +217,7 @@ void vga_draw_cursor_line_32(uint8_t *d1, const uint8_t *src1, unsigned int color_xor); int vga_ioport_invalid(VGACommonState *s, uint32_t addr); +void vga_init_vbe(VGACommonState *s); extern const uint8_t sr_mask[8]; extern const uint8_t gr_mask[16]; diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c index 28bbc3f..07befc8 100644 --- a/hw/vmware_vga.c +++ b/hw/vmware_vga.c @@ -1129,12 +1129,8 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size) vmsvga_screen_dump, vmsvga_text_update, s); -#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 - rom_add_vga(VGABIOS_FILENAME); + vga_init_vbe(&s->vga); + rom_add_vga(VGABIOS_FILENAME); } static void pci_vmsvga_map_ioport(PCIDevice *pci_dev, int region_num, -- 1.6.5.2 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 3/6] Make sure to enable dirty log tracking for VMware VGA 2009-12-17 22:08 ` [Qemu-devel] [PATCH 2/6] Make sure to enable dirty tracking of VBE vram mapping Dave Airlie @ 2009-12-17 22:08 ` Dave Airlie 2009-12-17 22:08 ` [Qemu-devel] [PATCH 4/6] Fix VMware VGA depth computation Dave Airlie 0 siblings, 1 reply; 7+ messages in thread From: Dave Airlie @ 2009-12-17 22:08 UTC (permalink / raw) To: qemu-devel From: Anthony Liguori <aliguori@us.ibm.com> This is needed for VMware VGA to work properly under KVM. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> --- hw/vmware_vga.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c index 07befc8..fcb6808 100644 --- a/hw/vmware_vga.c +++ b/hw/vmware_vga.c @@ -1169,6 +1169,10 @@ static void pci_vmsvga_map_mem(PCIDevice *pci_dev, int region_num, #endif cpu_register_physical_memory(s->vram_base, s->vga.vram_size, iomemtype); + + s->vga.map_addr = addr; + s->vga.map_end = addr + s->vga.vram_size; + vga_dirty_log_start(&s->vga); } static void pci_vmsvga_map_fifo(PCIDevice *pci_dev, int region_num, -- 1.6.5.2 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 4/6] Fix VMware VGA depth computation 2009-12-17 22:08 ` [Qemu-devel] [PATCH 3/6] Make sure to enable dirty log tracking for VMware VGA Dave Airlie @ 2009-12-17 22:08 ` Dave Airlie 2009-12-17 22:08 ` [Qemu-devel] [PATCH 5/6] VMware VGA: Only enable dirty log tracking when fifo is disabled Dave Airlie 0 siblings, 1 reply; 7+ messages in thread From: Dave Airlie @ 2009-12-17 22:08 UTC (permalink / raw) To: qemu-devel From: Anthony Liguori <aliguori@us.ibm.com> VMware VGA requires that the depth presented to the guest is the same as the DisplaySurface that it renders to. This is because it performs a very simple memcpy() to blit from one surface to another. We currently hardcode a 24-bit depth. The surface allocator for SDL may, and usually will, allocate a surface with a different depth causing screen corruption. This changes the code to allocate the DisplaySurface before initializing the device which allows the depth of the DisplaySurface to be used instead of hardcoding something. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> --- hw/vmware_vga.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c index fcb6808..ae91327 100644 --- a/hw/vmware_vga.c +++ b/hw/vmware_vga.c @@ -915,8 +915,8 @@ static void vmsvga_reset(struct vmsvga_state_s *s) s->width = -1; s->height = -1; s->svgaid = SVGA_ID; - s->depth = 24; - s->bypp = (s->depth + 7) >> 3; + s->depth = ds_get_bits_per_pixel(s->vga.ds); + s->bypp = ds_get_bytes_per_pixel(s->vga.ds); s->cursor.on = 0; s->redraw_fifo_first = 0; s->redraw_fifo_last = 0; @@ -1114,6 +1114,11 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size) s->scratch_size = SVGA_SCRATCH_SIZE; s->scratch = qemu_malloc(s->scratch_size * 4); + s->vga.ds = graphic_console_init(vmsvga_update_display, + vmsvga_invalidate_display, + vmsvga_screen_dump, + vmsvga_text_update, s); + vmsvga_reset(s); s->fifo_size = SVGA_FIFO_SIZE; @@ -1124,11 +1129,6 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size) vga_init(&s->vga); vmstate_register(0, &vmstate_vga_common, &s->vga); - s->vga.ds = graphic_console_init(vmsvga_update_display, - vmsvga_invalidate_display, - vmsvga_screen_dump, - vmsvga_text_update, s); - vga_init_vbe(&s->vga); rom_add_vga(VGABIOS_FILENAME); } -- 1.6.5.2 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 5/6] VMware VGA: Only enable dirty log tracking when fifo is disabled 2009-12-17 22:08 ` [Qemu-devel] [PATCH 4/6] Fix VMware VGA depth computation Dave Airlie @ 2009-12-17 22:08 ` Dave Airlie 2009-12-17 22:08 ` [Qemu-devel] [PATCH 6/6] vmware: increase cursor buffer size Dave Airlie 0 siblings, 1 reply; 7+ messages in thread From: Dave Airlie @ 2009-12-17 22:08 UTC (permalink / raw) To: qemu-devel From: Anthony Liguori <aliguori@us.ibm.com> This patch enables dirty log tracking whenever it's needed and disables it when it is not. We unconditionally enable dirty log tracking on reset, restart dirty log tracking when PCI IO regions are remapped, and disable/enable it based on commands from the guest. Rebased-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> --- hw/vga.c | 22 ++++++++++++++++++++++ hw/vga_int.h | 2 ++ hw/vmware_vga.c | 16 ++++++++++++---- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/hw/vga.c b/hw/vga.c index 5b0c55e..d05f1f9 100644 --- a/hw/vga.c +++ b/hw/vga.c @@ -1606,7 +1606,29 @@ void vga_dirty_log_start(VGACommonState *s) kvm_log_start(VBE_DISPI_LFB_PHYSICAL_ADDRESS, s->vram_size); } #endif +} + +void vga_dirty_log_stop(VGACommonState *s) +{ + if (kvm_enabled() && s->map_addr) + kvm_log_stop(s->map_addr, s->map_end - s->map_addr); + + if (kvm_enabled() && s->lfb_vram_mapped) { + kvm_log_stop(isa_mem_base + 0xa0000, 0x80000); + kvm_log_stop(isa_mem_base + 0xa8000, 0x80000); + } +#ifdef CONFIG_BOCHS_VBE + if (kvm_enabled() && s->vbe_mapped) { + kvm_log_stop(VBE_DISPI_LFB_PHYSICAL_ADDRESS, s->vram_size); + } +#endif +} + +void vga_dirty_log_restart(VGACommonState *s) +{ + vga_dirty_log_stop(s); + vga_dirty_log_start(s); } /* diff --git a/hw/vga_int.h b/hw/vga_int.h index b5302c1..23a42ef 100644 --- a/hw/vga_int.h +++ b/hw/vga_int.h @@ -194,6 +194,8 @@ void vga_init(VGACommonState *s); void vga_common_reset(VGACommonState *s); void vga_dirty_log_start(VGACommonState *s); +void vga_dirty_log_stop(VGACommonState *s); +void vga_dirty_log_restart(VGACommonState *s); extern const VMStateDescription vmstate_vga_common; uint32_t vga_ioport_read(void *opaque, uint32_t addr); diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c index ae91327..e3d5706 100644 --- a/hw/vmware_vga.c +++ b/hw/vmware_vga.c @@ -771,8 +771,12 @@ static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value) s->height = -1; s->invalidated = 1; s->vga.invalidate(&s->vga); - if (s->enable) - s->fb_size = ((s->depth + 7) >> 3) * s->new_width * s->new_height; + if (s->enable) { + s->fb_size = ((s->depth + 7) >> 3) * s->new_width * s->new_height; + vga_dirty_log_stop(&s->vga); + } else { + vga_dirty_log_start(&s->vga); + } break; case SVGA_REG_WIDTH: @@ -948,6 +952,8 @@ static void vmsvga_reset(struct vmsvga_state_s *s) break; } s->syncing = 0; + + vga_dirty_log_start(&s->vga); } static void vmsvga_invalidate_display(void *opaque) @@ -1119,7 +1125,6 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size) vmsvga_screen_dump, vmsvga_text_update, s); - vmsvga_reset(s); s->fifo_size = SVGA_FIFO_SIZE; s->fifo_offset = qemu_ram_alloc(s->fifo_size); @@ -1130,7 +1135,10 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size) vmstate_register(0, &vmstate_vga_common, &s->vga); vga_init_vbe(&s->vga); + rom_add_vga(VGABIOS_FILENAME); + + vmsvga_reset(s); } static void pci_vmsvga_map_ioport(PCIDevice *pci_dev, int region_num, @@ -1172,7 +1180,7 @@ static void pci_vmsvga_map_mem(PCIDevice *pci_dev, int region_num, s->vga.map_addr = addr; s->vga.map_end = addr + s->vga.vram_size; - vga_dirty_log_start(&s->vga); + vga_dirty_log_restart(&s->vga); } static void pci_vmsvga_map_fifo(PCIDevice *pci_dev, int region_num, -- 1.6.5.2 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 6/6] vmware: increase cursor buffer size. 2009-12-17 22:08 ` [Qemu-devel] [PATCH 5/6] VMware VGA: Only enable dirty log tracking when fifo is disabled Dave Airlie @ 2009-12-17 22:08 ` Dave Airlie 0 siblings, 0 replies; 7+ messages in thread From: Dave Airlie @ 2009-12-17 22:08 UTC (permalink / raw) To: qemu-devel From: Dave Airlie <airlied@linux.ie> The cursor pixmap size we calculate later ends up being 4096 dwords long by the looks of it. This boots an F12 LiveCD now. Signed-off-by: Dave Airlie <airlied@linux.ie> --- hw/vmware_vga.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c index e3d5706..7ab1c79 100644 --- a/hw/vmware_vga.c +++ b/hw/vmware_vga.c @@ -467,7 +467,7 @@ struct vmsvga_cursor_definition_s { int hot_x; int hot_y; uint32_t mask[1024]; - uint32_t image[1024]; + uint32_t image[4096]; }; #define SVGA_BITMAP_SIZE(w, h) ((((w) + 31) >> 5) * (h)) -- 1.6.5.2 ^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-12-17 22:10 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-12-17 22:08 [Qemu-devel] qemu fixup patch sequence Dave Airlie 2009-12-17 22:08 ` [Qemu-devel] [PATCH 1/6] vmware: setup PCI BAR 2 for FIFO as per vmware spec Dave Airlie 2009-12-17 22:08 ` [Qemu-devel] [PATCH 2/6] Make sure to enable dirty tracking of VBE vram mapping Dave Airlie 2009-12-17 22:08 ` [Qemu-devel] [PATCH 3/6] Make sure to enable dirty log tracking for VMware VGA Dave Airlie 2009-12-17 22:08 ` [Qemu-devel] [PATCH 4/6] Fix VMware VGA depth computation Dave Airlie 2009-12-17 22:08 ` [Qemu-devel] [PATCH 5/6] VMware VGA: Only enable dirty log tracking when fifo is disabled Dave Airlie 2009-12-17 22:08 ` [Qemu-devel] [PATCH 6/6] vmware: increase cursor buffer size Dave Airlie
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).