From: Alex Williamson <alex.williamson@redhat.com>
To: seabios@seabios.org
Cc: alex.williamson@redhat.com, allen.m.kay@intel.com,
qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: [Qemu-devel] [RFC PATCH v3 3/3] fw/pci: Allocate IGD stolen memory
Date: Fri, 12 Feb 2016 17:23:18 -0700 [thread overview]
Message-ID: <20160213002318.18456.48603.stgit@gimli.home> (raw)
In-Reply-To: <20160213001835.18456.46422.stgit@gimli.home>
Intel IGD makes use of memory allocated and marked reserved by the
BIOS as a stolen memory range. For the most part, guest drivers don't
make use of this, but our achilles heel is the vBIOS. The vBIOS
programs the device to use the host stolen memory range and it's used
in the pre-boot environment. Generally the guest won't have access to
the host stolen memory area, so these accesses either land in VM
memory or unassigned space and generate IOMMU faults. By allocating
this range in SeaBIOS and programming it into the device, QEMU (via
vfio) can make sure this guest allocated stolen memory range is used
instead.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
src/fw/pciinit.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c
index 92170d5..c1ad5d4 100644
--- a/src/fw/pciinit.c
+++ b/src/fw/pciinit.c
@@ -260,7 +260,7 @@ static void ich9_smbus_setup(struct pci_device *dev, void *arg)
static void intel_igd_opregion_setup(struct pci_device *dev, void *arg)
{
struct romfile_s *file = romfile_find("etc/igd-opregion");
- void *opregion;
+ void *opregion, *bdsm;
u16 bdf = dev->bdf;
if (!file || !file->size)
@@ -281,6 +281,17 @@ static void intel_igd_opregion_setup(struct pci_device *dev, void *arg)
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));
+
+ bdsm = memalign_high(1024 * 1024, 1024 * 1024);
+ if (!bdsm) {
+ warn_noalloc();
+ return;
+ }
+
+ pci_config_writel(bdf, 0x5C, cpu_to_le32((u32)bdsm));
+
+ dprintf(1, "Allocated 1MB reserved memory for Intel IGD stolen memory at "
+ "0x%08x\n", (u32)bdsm);
}
static const struct pci_device_id pci_device_tbl[] = {
next prev parent reply other threads:[~2016-02-13 0:23 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-13 0:23 [Qemu-devel] [RFC PATCH v3 0/3] IGD assignment support for QEMU/vfio Alex Williamson
2016-02-13 0:23 ` [Qemu-devel] [RFC PATCH v3 1/3] fw/pci: Add support for mapping Intel IGD OpRegion via QEMU Alex Williamson
2016-02-13 0:23 ` [Qemu-devel] [RFC PATCH v3 2/3] Further increase maximum size of permanent high memory area Alex Williamson
2016-02-13 0:23 ` Alex Williamson [this message]
2016-02-13 2:49 ` [Qemu-devel] [RFC PATCH v3 3/3] fw/pci: Allocate IGD stolen memory Kevin O'Connor
2016-02-13 15:12 ` Alex Williamson
2016-02-13 18:18 ` Kevin O'Connor
2016-02-13 18:51 ` Alex Williamson
2016-02-13 20:05 ` Kevin O'Connor
2016-02-13 20:57 ` Alex Williamson
2016-02-14 0:20 ` Kevin O'Connor
2016-02-14 1:03 ` Alex Williamson
2016-02-15 9:54 ` Igor Mammedov
2016-02-15 19:20 ` Alex Williamson
2016-02-15 19:29 ` Michael S. Tsirkin
2016-02-15 19:50 ` Kevin O'Connor
2016-02-15 20:08 ` Michael S. Tsirkin
2016-02-15 19:54 ` Alex Williamson
2016-02-16 12:08 ` Gerd Hoffmann
2016-02-15 14:15 ` Kevin O'Connor
2016-02-15 10:31 ` Gerd Hoffmann
2016-02-15 17:46 ` Alex Williamson
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=20160213002318.18456.48603.stgit@gimli.home \
--to=alex.williamson@redhat.com \
--cc=allen.m.kay@intel.com \
--cc=kvm@vger.kernel.org \
--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).