From patchwork Thu Dec 17 22:08:07 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 41347 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 73B26B6F04 for ; Fri, 18 Dec 2009 09:13:15 +1100 (EST) Received: from localhost ([127.0.0.1]:41713 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NLOau-0003Gb-7Q for incoming@patchwork.ozlabs.org; Thu, 17 Dec 2009 17:13:12 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NLOYS-0001h5-5q for qemu-devel@nongnu.org; Thu, 17 Dec 2009 17:10:40 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NLOYN-0001dG-RZ for qemu-devel@nongnu.org; Thu, 17 Dec 2009 17:10:39 -0500 Received: from [199.232.76.173] (port=36356 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NLOYN-0001dD-Oa for qemu-devel@nongnu.org; Thu, 17 Dec 2009 17:10:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34635) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NLOYN-0003lL-9u for qemu-devel@nongnu.org; Thu, 17 Dec 2009 17:10:35 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBHMAY9n017421 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 17 Dec 2009 17:10:34 -0500 Received: from localhost.localdomain (dhcp-0-222.bne.redhat.com [10.64.0.222]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBHMAUQC005737 for ; Thu, 17 Dec 2009 17:10:33 -0500 From: Dave Airlie To: qemu-devel@nongnu.org Date: Fri, 18 Dec 2009 08:08:07 +1000 Message-Id: <1261087691-8319-3-git-send-email-airlied@gmail.com> In-Reply-To: <1261087691-8319-2-git-send-email-airlied@gmail.com> References: <1261087691-8319-1-git-send-email-airlied@gmail.com> <1261087691-8319-2-git-send-email-airlied@gmail.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 2/6] Make sure to enable dirty tracking of VBE vram mapping X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Anthony Liguori 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 Rebased-by: Dave Airlie --- 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,