diff mbox

issue with vgabios lfb and virtio vga

Message ID 1386836240.19301.6.camel@nilsson.home.kraxel.org
State New
Headers show

Commit Message

Gerd Hoffmann Dec. 12, 2013, 8:17 a.m. UTC
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

Comments

Dave Airlie Dec. 13, 2013, 1:58 a.m. UTC | #1
On Thu, Dec 12, 2013 at 6:17 PM, Gerd Hoffmann <kraxel@redhat.com> wrote:
> 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.
>
Oh do we generate the VGABIOS from seabios now or are we going to?

I've been using the vgabios url from the pc-bios/README file

Dave.
Gerd Hoffmann Dec. 13, 2013, 7:06 a.m. UTC | #2
On Fr, 2013-12-13 at 11:58 +1000, Dave Airlie wrote:
> On Thu, Dec 12, 2013 at 6:17 PM, Gerd Hoffmann <kraxel@redhat.com> wrote:
> > 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.
> >
> Oh do we generate the VGABIOS from seabios now or are we going to?

master is switched to seavgabios, 1.7 still at the old one.

"git submodule init" will fetch firmware subtrees.
the Makefile in roms/ has targets to build vgabioses.

cheers,
  Gerd
diff mbox

Patch

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