From: Alex Williamson <alex.williamson@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: seabios@seabios.org, qemu-devel@nongnu.org, kraxel@redhat.com
Subject: Re: [Qemu-devel] [SeaBIOS] [RFC PATCH v2] fw/pci: Add support for mapping Intel IGD OpRegion via QEMU
Date: Thu, 4 Feb 2016 22:44:57 -0700 [thread overview]
Message-ID: <20160204224457.02de4d2f@t450s.home> (raw)
In-Reply-To: <20160204175823.75cc7e25@nial.brq.redhat.com>
On Thu, 4 Feb 2016 17:58:23 +0100
Igor Mammedov <imammedo@redhat.com> wrote:
> On Tue, 02 Feb 2016 13:10:37 -0700
> Alex Williamson <alex.williamson@redhat.com> wrote:
>
> > When assigning Intel IGD graphics via QEMU/vfio, the OpRegion for
> > the device may be exposed as a fw_cfg file. Allocate space for
> > this, copy the contents and write the ASL Storage register (0xFC)
> > to point to this buffer. NB, it's possible for QEMU to use the
> > write to the ASL Storage register to map access to the host
> > OpRegion overlapping the allocated buffer, but we shouldn't care if
> > it does.
> >
> > References:
> > kernel vfio opregion support:
> > https://lkml.org/lkml/2016/2/1/884
> > QEMU vfio opregion support (revised v2 of 7/7 adds fw_cfg):
> > https://lists.gnu.org/archive/html/qemu-devel/2016-02/msg00202.html
> > Gerd's IGD assignment series:
> > https://lists.gnu.org/archive/html/qemu-devel/2016-01/msg00244.html
> >
> > Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> > ---
> > src/fw/pciinit.c | 30 ++++++++++++++++++++++++++++++
> > 1 file changed, 30 insertions(+)
> >
> > diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c
> > index c31c2fa..92170d5 100644
> > --- a/src/fw/pciinit.c
> > +++ b/src/fw/pciinit.c
> > @@ -257,6 +257,32 @@ static void ich9_smbus_setup(struct pci_device
> > *dev, void *arg) pci_config_writeb(bdf, ICH9_SMB_HOSTC,
> > ICH9_SMB_HOSTC_HST_EN); }
> >
> > +static void intel_igd_opregion_setup(struct pci_device *dev, void
> > *arg) +{
> > + struct romfile_s *file = romfile_find("etc/igd-opregion");
> > + void *opregion;
> > + u16 bdf = dev->bdf;
> > +
> > + if (!file || !file->size)
> > + return;
> > +
> > + opregion = memalign_high(PAGE_SIZE, file->size);
> > + if (!opregion) {
> > + warn_noalloc();
> > + return;
> > + }
> > +
> > + if (file->copy(file, opregion, file->size) < 0) {
> Is opregion content on host immutable?
> if not then copying it probably wrong and it should be passed-through.
The content is not immutable, but for the first round of things that
we're interested in, it probably is. It's not clear that we'll ever
move beyond that first level though. Part of the benefit of this
approach is that SeaBIOS allocates the correct size, copies a static
version of the OpRegion data into place, then effectively tells QEMU
that it has done this by writing to the ASL Storage register. At that
point QEMU can simply virtualize the register for the guest or it can
map a live version of the OpRegion over top of the SeaBIOS copy. So we
certainly have the option to go beyond an immutable copy with no
further change to SeaBIOS. Thanks,
Alex
> > + free(opregion);
> > + return;
> > + }
> > +
> > + pci_config_writel(bdf, 0xFC, cpu_to_le32((u32)opregion));
> > +
> > + dprintf(1, "Intel IGD OpRegion enabled on %02x:%02x.%x\n",
> > + pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf),
> > pci_bdf_to_fn(bdf)); +}
> > +
> > static const struct pci_device_id pci_device_tbl[] = {
> > /* PIIX3/PIIX4 PCI to ISA bridge */
> > PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371SB_0,
> > @@ -290,6 +316,10 @@ static const struct pci_device_id
> > pci_device_tbl[] = { PCI_DEVICE_CLASS(PCI_VENDOR_ID_APPLE, 0x0017,
> > 0xff00, apple_macio_setup), PCI_DEVICE_CLASS(PCI_VENDOR_ID_APPLE,
> > 0x0022, 0xff00, apple_macio_setup),
> > + /* Intel IGD OpRegion setup */
> > + PCI_DEVICE_CLASS(PCI_VENDOR_ID_INTEL, PCI_ANY_ID,
> > PCI_CLASS_DISPLAY_VGA,
> > + intel_igd_opregion_setup),
> > +
> > PCI_DEVICE_END,
> > };
> >
> >
> >
> > _______________________________________________
> > SeaBIOS mailing list
> > SeaBIOS@seabios.org
> > http://www.seabios.org/mailman/listinfo/seabios
>
next prev parent reply other threads:[~2016-02-05 5:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-02 20:10 [Qemu-devel] [RFC PATCH v2] fw/pci: Add support for mapping Intel IGD OpRegion via QEMU Alex Williamson
2016-02-03 9:04 ` [Qemu-devel] [SeaBIOS] " Gerd Hoffmann
2016-02-03 19:43 ` Alex Williamson
2016-02-03 21:38 ` Alex Williamson
2016-02-03 22:09 ` Kevin O'Connor
2016-02-03 23:52 ` Alex Williamson
2016-02-04 7:52 ` Gerd Hoffmann
2016-02-04 16:01 ` Kevin O'Connor
2016-02-04 16:58 ` Igor Mammedov
2016-02-05 5:44 ` Alex Williamson [this message]
2016-02-05 7:58 ` Gerd Hoffmann
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=20160204224457.02de4d2f@t450s.home \
--to=alex.williamson@redhat.com \
--cc=imammedo@redhat.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=seabios@seabios.org \
/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).