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

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);

Reply via email to