From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43296) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vr1Sf-00019S-1U for qemu-devel@nongnu.org; Thu, 12 Dec 2013 03:17:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vr1SW-0000T3-61 for qemu-devel@nongnu.org; Thu, 12 Dec 2013 03:17:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:62098) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vr1SV-0000Sr-TE for qemu-devel@nongnu.org; Thu, 12 Dec 2013 03:17:24 -0500 Message-ID: <1386836240.19301.6.camel@nilsson.home.kraxel.org> From: Gerd Hoffmann Date: Thu, 12 Dec 2013 09:17:20 +0100 In-Reply-To: References: Content-Type: multipart/mixed; boundary="=-i2ZUBVOltMYTO22Cw6L/" Mime-Version: 1.0 Subject: Re: [Qemu-devel] issue with vgabios lfb and virtio vga List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Dave Airlie Cc: "qemu-devel@nongnu.org" --=-i2ZUBVOltMYTO22Cw6L/ Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit On Do, 2013-12-12 at 09:51 +1000, Dave Airlie wrote: > Now the vgabios.c does a check of bar 0 and bar 1 to see if they are > 0xfff1 masked, this protects against the the i/o bar but fails to > protect against the LFB one as PCI BARs don't encode the size just the > base address, and a 4k BAR can be aligned to a larger size. > Any ideas? I seem to remember vgabios.c had a hack in the past for > vmware, but I'm not sure. The fallback to bar #1 *is* the vmware hack ;) Something like the attached patch should do the trick. cheers, Gerd --=-i2ZUBVOltMYTO22Cw6L/ Content-Disposition: attachment; filename="fix" Content-Type: text/x-patch; name="fix"; charset="UTF-8" Content-Transfer-Encoding: 7bit diff --git a/vgasrc/bochsvga.c b/vgasrc/bochsvga.c index 6da9d5d..7325059 100644 --- a/vgasrc/bochsvga.c +++ b/vgasrc/bochsvga.c @@ -402,12 +402,17 @@ bochsvga_setup(void) u32 lfb_addr = VBE_DISPI_LFB_PHYSICAL_ADDRESS; int bdf = GET_GLOBAL(VgaBDF); if (CONFIG_VGA_PCI && bdf >= 0) { + u16 vendor = pci_config_readw(bdf, PCI_VENDOR_ID); int barid = 0; - u32 bar = pci_config_readl(bdf, PCI_BASE_ADDRESS_0); - if ((bar & PCI_BASE_ADDRESS_SPACE) != PCI_BASE_ADDRESS_SPACE_MEMORY) { - barid = 1; - bar = pci_config_readl(bdf, PCI_BASE_ADDRESS_1); + switch (vendor) { + case 0x15ad: /* qemu vmware vga */ + int barid = 1; + break; + case 0xFIXME: /* virtio-vga */ + int barid = 2; + break; } + u32 bar = pci_config_readl(bdf, PCI_BASE_ADDRESS_0); lfb_addr = bar & PCI_BASE_ADDRESS_MEM_MASK; dprintf(1, "VBE DISPI: bdf %02x:%02x.%x, bar %d\n", pci_bdf_to_bus(bdf) , pci_bdf_to_dev(bdf), pci_bdf_to_fn(bdf), barid); --=-i2ZUBVOltMYTO22Cw6L/--