All of lore.kernel.org
 help / color / mirror / Atom feed
From: Grzegorz Uriasz <gorbak25@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: Wei Liu <wl@xen.org>,
	jakub@bartmin.ski, Ian Jackson <ian.jackson@eu.citrix.com>,
	marmarek@invisiblethingslab.com,
	Grzegorz Uriasz <gorbak25@gmail.com>,
	j.nowak26@student.uw.edu.pl,
	Anthony PERARD <anthony.perard@citrix.com>,
	contact@puzio.waw.pl
Subject: [PATCH 3/3] tools/libxl: Directly map VBIOS to stubdomain
Date: Sun, 14 Jun 2020 22:12:03 +0000	[thread overview]
Message-ID: <9817b73ea628c7ac86903bb9aa7fcfecf4f7b900.1592171394.git.gorbak25@gmail.com> (raw)
In-Reply-To: <cover.1592171394.git.gorbak25@gmail.com>

When passing through a IGD VGA device qemu needs to copy the host VBIOS
to the target domain. Right now the current implementation on the qemu side
is one big undefined behavior as described in my qemu patchset here:
https://patchew.org/QEMU/20200428062847.7764-1-gorbak25@gmail.com/
This patch is tied to the linked patchset for qemu but fortunately
this patch still works without the qemu part merged. When the qemu part
gets merged then qemu will access the VBIOS using /dev/mem - this is
required as currently the linux kernel forbids accessing this memory
region when the VBIOS is corrupted - which will always be the case as
described in the linked patchset. When qemu is running inside a linux
based stubdomain then the stubdomain does not have access to the VBIOS.
This patch maps the VBIOS to the stubdomain so qemu with my fixes may
create a shadow copy for the target domain.

Signed-off-by: Grzegorz Uriasz <gorbak25@gmail.com>
---
 tools/libxl/libxl_pci.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
index 48b1d8073b..9b9564dd73 100644
--- a/tools/libxl/libxl_pci.c
+++ b/tools/libxl/libxl_pci.c
@@ -2445,6 +2445,8 @@ static int libxl__grant_legacy_vga_permissions(libxl__gc *gc, const uint32_t dom
     int ret, i;
     uint64_t vga_iomem_start = 0xa0000 >> XC_PAGE_SHIFT;
     uint64_t vga_iomem_npages = 0x20;
+    uint64_t vga_vbios_start = 0xc0000 >> XC_PAGE_SHIFT;
+    uint64_t vga_vbios_npages = 0x20;
     uint32_t stubdom_domid = libxl_get_stubdom_id(CTX, domid);
     uint64_t vga_ioport_start[] = {0x3B0, 0x3C0};
     uint64_t vga_ioport_size[] = {0xC, 0x20};
@@ -2460,6 +2462,7 @@ static int libxl__grant_legacy_vga_permissions(libxl__gc *gc, const uint32_t dom
               vga_iomem_start, (vga_iomem_start + (vga_iomem_npages << XC_PAGE_SHIFT) - 1));
         return ret;
     }
+
     ret = xc_domain_iomem_permission(CTX->xch, domid,
                                      vga_iomem_start, vga_iomem_npages, 1);
     if (ret < 0) {
@@ -2470,6 +2473,13 @@ static int libxl__grant_legacy_vga_permissions(libxl__gc *gc, const uint32_t dom
         return ret;
     }
 
+    /* VGA ROM */
+    ret = xc_domain_memory_mapping(CTX->xch, stubdom_domid, vga_vbios_start, vga_vbios_start, vga_vbios_npages, DPCI_ADD_MAPPING);
+    if (ret < 0) {
+        LOGED(ERROR, domid, "failed to map VBIOS to stubdom%d", stubdom_domid);
+        return ret;
+    }
+
     /* VGA IOPORTS */
     for (i = 0 ; i < 2 ; i++) {
         ret = xc_domain_ioport_permission(CTX->xch, stubdom_domid,
-- 
2.27.0



  parent reply	other threads:[~2020-06-14 22:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-14 22:12 [PATCH 0/3] IGD Passthrough fixes for linux based stubdomains Grzegorz Uriasz
2020-06-14 22:12 ` [PATCH 1/3] tools/libxl: Grant VGA IO port permission for stubdom/target domain Grzegorz Uriasz
2020-06-15 11:17   ` Roger Pau Monné
2020-06-15 11:32   ` Ian Jackson
2020-06-14 22:12 ` [PATCH 2/3] tools/libxl: Grant permission for mapping opregions to the target domain Grzegorz Uriasz
2020-06-15 12:44   ` Roger Pau Monné
2020-06-14 22:12 ` Grzegorz Uriasz [this message]
2020-06-15 10:26   ` [PATCH 3/3] tools/libxl: Directly map VBIOS to stubdomain Roger Pau Monné

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=9817b73ea628c7ac86903bb9aa7fcfecf4f7b900.1592171394.git.gorbak25@gmail.com \
    --to=gorbak25@gmail.com \
    --cc=anthony.perard@citrix.com \
    --cc=contact@puzio.waw.pl \
    --cc=ian.jackson@eu.citrix.com \
    --cc=j.nowak26@student.uw.edu.pl \
    --cc=jakub@bartmin.ski \
    --cc=marmarek@invisiblethingslab.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.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 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.