qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: "Kay, Allen M" <allen.m.kay@intel.com>
Cc: "Ruan, Shuai" <shuai.ruan@intel.com>,
	"ehabkost@redhat.com" <ehabkost@redhat.com>,
	"stefano.stabellini@eu.citrix.com"
	<stefano.stabellini@eu.citrix.com>,
	"mst@redhat.com" <mst@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	"rth@twiddle.net" <rth@twiddle.net>
Subject: Re: [Qemu-devel] [v10][PATCH 03/10] piix: create host bridge to passthrough
Date: Wed, 10 Feb 2016 23:07:12 -0700	[thread overview]
Message-ID: <20160210230712.41d447c3@t450s.home> (raw)
In-Reply-To: <003AAFE53969E14CB1F09B6FD68C3CD47BB7722A@ORSMSX106.amr.corp.intel.com>

On Thu, 11 Feb 2016 02:25:51 +0000
"Kay, Allen M" <allen.m.kay@intel.com> wrote:

> > -----Original Message-----
> > From: Alex Williamson [mailto:alex.williamson@redhat.com]
> > Sent: Tuesday, February 09, 2016 10:01 PM
> > To: Kay, Allen M <allen.m.kay@intel.com>
> > Cc: ehabkost@redhat.com; mst@redhat.com;
> > stefano.stabellini@eu.citrix.com; qemu-devel@nongnu.org;
> > pbonzini@redhat.com; rth@twiddle.net; Ruan, Shuai
> > <shuai.ruan@intel.com>
> > Subject: Re: [Qemu-devel] [v10][PATCH 03/10] piix: create host bridge to
> > passthrough
> > 
> > I can run that system as either primary or secondary.  On both systems I'm
> > using pci-stub to keep i915 from interfering on the host, on the SNB laptop I
> > also use video=efifb:off since it's configured for UEFI boot, I'm not sure if
> > that play any role in why it's not working.
> >   
> 
> Hi Alex,
> 
> My understand if that your IVB system is a desktop running legacy mode BIOS and your SNB is a laptop running EFI mode BIOS, correct?  I'm curious how does your SNB system getting hold of VBT table, which is needed for lighting up local display.
> 
> There are two ways the driver can get VBT table:  1) VGA 0xc0000 memory,  2) OpRegion
> 
> On your IVB system, the guest driver would try to get VBT from 0xc0000 memory if IGD is configured as primary controller in the guest, assuming KVM/QEMU copies VGA 0xc0000 memory from host to guest 0xc0000 area.   If IGD is configured as secondary controller, the driver would get VBT from OpRegion.  Given IGD works in both configurations on IVB, this mean guest driver can successfully read VBT from both 0xc0000 area and OpRegion.
> 
> On your SNB system that is running in EFI mode on the host, 0xc0000 memory does not contain VBIOS/VBT.  This means if you configure IGD as primary controller in the guest, the driver cannot get to VBT at 0xc0000 memory even if KVM/QEMU copies 0xc0000 memory from host to guest.  If you configure IGD as secondary controller in the guest, and guest driver should be able to read VBT from the OpRegion.  You might want to trace i915 to see how does the  guest driver get to VBT via OpRegion in this configuration.

Hi Allen,

Success!  We don't directly pass 0xc0000 from the host, but we can use
PCI option ROMs loaded via files into QEMU.  For the IVB system I
haven't been bothering with this, even in primary mode I've just been
letting the display initialize later in the guest boot.  I also haven't
been enabling VGA mode access in that case.  With the SNB laptop, if I
extract the ROM from sysfs, modify the device ID and fix the checksum,
the panel lights up, with or without VGA mode access (though of course
I only see a flash of SeaBIOS when VGA mode is enabled).  So it seems
that either the user is going to need to hack their own ROM file or I'm
going to need to make vfio do this automatically and pretend that the
ROM is actually implemented as a BAR on IGD.  The latter seems far more
accessible.  Lacking an actual ROM BAR, we'll also of course only be
able to do that when IGD is primary graphics on the host.

I'm not sure how we can do secondary mode in the VM with this config
though since only the primary graphics gets the coveted 0xc0000
location.  FWIW, to make this work I added 'romfile=igd.rom' to the
vfio-pci device with igd.rom being the modified copy retrieved from
sysfs.  Then I used '-vga none' to disable the QEMU primary VGA device
(-nodefaults is probably an option too).  I then added 'addr=2.0' to
the vfio-pci device to make it be the primary graphics from SeaBIOS'
perspective and added '-device secondary-vga,addr=3.0 -vnc :1', which
predominantly gives me a VNC connection where I can interact with the
VM via mouse and keyboard.

I'll need to do some further investigation to see what we're really
getting with the OpRegion.  Prior to adding the ROM, the Xorg log file
sure seems like it knew the LVDS panel was 1920x1080, but it might be
seeing more modes now that it has a video BIOS.  I'll also try to prune
the registers copied into the virtual host bridge and ISA bridge config
space to the minimum we need.

> Another potential problem to watch out for with laptop vs. desktop has to do FLR timeout.  If you are working with a laptop with LCD panel attached (the usual case), FLR will take much longer than 100ms to finish.  The reason is the devices needs to power down the LCD panel before it can finish FLR. I have seen it takes more than 500ms for FLR to finish.  As a work around, I have increase FLR time out in Linux PCI driver to 1000ms when working with LCD panels.   Given that you have seen evidences that IGD HW is working, this might not be your issue.   I would focus tracing how does i915 get VBT from the OpRegion when IGD is configured as secondary controller in the guest.

Ok, I did see evidence of this.  In my case the VM would always fail to
start on the first try with errors in dmesg indicating that vfio was
reading back -1 from config space of the device.  Presumably it was
only the first attempt in my case since previously I was never getting
the panel turned back on and subsequent resets were faster.  I also
notice that I see DMAR faults on the first reset that seem to be
accesses to the host stolen memory region pointed to by the BDSM.  I
don't see this if I reset the device from sysfs before trying to use it
with the VM, so maybe vfio should try to do a reset on probing IGD,
before it gets placed in an IOMMU domain that blocks access to that
host stolen memory.  Of course the next question is whether we can
easily determine whether an IGD has an LCD panel so we know which
timeout to use.  I suppose we could use a 1000ms timeout for all Intel
VGA class devices, but handling it with a quirk only for panel attached
configs would probably be preferable.  Thanks,

Alex

  reply	other threads:[~2016-02-11  6:07 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-15  5:37 [Qemu-devel] [v10][PATCH 00/10] xen: add Intel IGD passthrough Tiejun Chen
2015-07-15  5:37 ` [Qemu-devel] [v10][PATCH 01/10] i440fx: make types configurable at run-time Tiejun Chen
2015-07-15  5:37 ` [Qemu-devel] [v10][PATCH 02/10] pc_init1: pass parameters just with types Tiejun Chen
2015-07-15  5:37 ` [Qemu-devel] [v10][PATCH 03/10] piix: create host bridge to passthrough Tiejun Chen
2016-02-09  3:32   ` Alex Williamson
2016-02-09 17:43     ` Alex Williamson
2016-02-09 17:56       ` Paolo Bonzini
2016-02-09 19:47       ` Kay, Allen M
2016-02-09 21:32         ` Alex Williamson
2016-02-10  3:40           ` Kay, Allen M
2016-02-10  6:00             ` Alex Williamson
2016-02-11  2:25               ` Kay, Allen M
2016-02-11  6:07                 ` Alex Williamson [this message]
2016-02-15 11:28           ` Gerd Hoffmann
2015-07-15  5:37 ` [Qemu-devel] [v10][PATCH 04/10] hw/pci-assign: split pci-assign.c Tiejun Chen
2015-07-15  5:37 ` [Qemu-devel] [v10][PATCH 05/10] xen, gfx passthrough: basic graphics passthrough support Tiejun Chen
2015-07-15  5:37 ` [Qemu-devel] [v10][PATCH 06/10] xen, gfx passthrough: retrieve VGA BIOS to work Tiejun Chen
2015-07-15  5:37 ` [Qemu-devel] [v10][PATCH 07/10] igd gfx passthrough: create a isa bridge Tiejun Chen
2015-07-15  5:37 ` [Qemu-devel] [v10][PATCH 08/10] xen, gfx passthrough: register " Tiejun Chen
2015-07-15  5:37 ` [Qemu-devel] [v10][PATCH 09/10] xen, gfx passthrough: register host bridge specific to passthrough Tiejun Chen
2015-07-15  5:37 ` [Qemu-devel] [v10][PATCH 10/10] xen, gfx passthrough: add opregion mapping Tiejun Chen
2015-07-15 11:46 ` [Qemu-devel] [v10][PATCH 00/10] xen: add Intel IGD passthrough Stefano Stabellini
2015-07-15 12:01   ` Michael S. Tsirkin
2015-07-15 12:38     ` Stefano Stabellini
2015-07-15 13:27       ` Chen, Tiejun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160210230712.41d447c3@t450s.home \
    --to=alex.williamson@redhat.com \
    --cc=allen.m.kay@intel.com \
    --cc=ehabkost@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=shuai.ruan@intel.com \
    --cc=stefano.stabellini@eu.citrix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).