All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] issue with vgabios lfb and virtio vga
@ 2013-12-11 23:51 Dave Airlie
  2013-12-12  8:17 ` Gerd Hoffmann
  0 siblings, 1 reply; 4+ messages in thread
From: Dave Airlie @ 2013-12-11 23:51 UTC (permalink / raw)
  To: qemu-devel, Gerd Hoffmann

Hi Gerd,

so I have a bit of a conflict I'm not sure how best to handle between
how vgabios.c locates its LFB and how virtio requires the BAR get laid
out.

So virtio-pci requires the BARs are laid out for MSI support with the
config i/o ports at BAR 0, and MSI BAR at BAR 1.

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.

So even if I expand the vgabios.c current code to check for a
potential BAR2 it'll fail if the BAR1 gets aligned to something better
than the 4k is requires.

The correct way to size BARs is to store the old value, write
0xffffffff and see how many bits stick, then write back the old value.

Any ideas? I seem to remember vgabios.c had a hack in the past for
vmware, but I'm not sure.

Dave.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] issue with vgabios lfb and virtio vga
  2013-12-11 23:51 [Qemu-devel] issue with vgabios lfb and virtio vga Dave Airlie
@ 2013-12-12  8:17 ` Gerd Hoffmann
  2013-12-13  1:58   ` Dave Airlie
  0 siblings, 1 reply; 4+ messages in thread
From: Gerd Hoffmann @ 2013-12-12  8:17 UTC (permalink / raw)
  To: Dave Airlie; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 546 bytes --]

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


[-- Attachment #2: fix --]
[-- Type: text/x-patch, Size: 1092 bytes --]

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] issue with vgabios lfb and virtio vga
  2013-12-12  8:17 ` Gerd Hoffmann
@ 2013-12-13  1:58   ` Dave Airlie
  2013-12-13  7:06     ` Gerd Hoffmann
  0 siblings, 1 reply; 4+ messages in thread
From: Dave Airlie @ 2013-12-13  1:58 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] issue with vgabios lfb and virtio vga
  2013-12-13  1:58   ` Dave Airlie
@ 2013-12-13  7:06     ` Gerd Hoffmann
  0 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2013-12-13  7:06 UTC (permalink / raw)
  To: Dave Airlie; +Cc: qemu-devel

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-12-13  7:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-11 23:51 [Qemu-devel] issue with vgabios lfb and virtio vga Dave Airlie
2013-12-12  8:17 ` Gerd Hoffmann
2013-12-13  1:58   ` Dave Airlie
2013-12-13  7:06     ` Gerd Hoffmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.