Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: kvm@vger.kernel.org
Cc: ddutile@redhat.com, chrisw@redhat.com, gleb@redhat.com,
	alex.williamson@redhat.com
Subject: [PATCH 2/3] device-assignment: Always use slow mapping for PCI option ROM
Date: Fri, 30 Jul 2010 13:40:19 -0600	[thread overview]
Message-ID: <20100730194019.10110.21091.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <20100730193941.10110.92913.stgit@localhost6.localdomain6>

KVM doesn't support read-only mappings for MMIO space.  Performance isn't
an issue for the option ROM mapping, so always use slow mapping.  kvm.git
cset b4f8c249 will make kvm hang with a "Bad address" fault without this.
We can also then drop the extraneous mprotects since the guest has no way
to write to these regions.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---

 hw/device-assignment.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/hw/device-assignment.c b/hw/device-assignment.c
index c26ff6d..0e82a16 100644
--- a/hw/device-assignment.c
+++ b/hw/device-assignment.c
@@ -541,6 +541,8 @@ static int assigned_dev_register_regions(PCIRegion *io_regions,
             /* map physical memory */
             pci_dev->v_addrs[i].e_physbase = cur_region->base_addr;
             if (i == PCI_ROM_SLOT) {
+                /* KVM doesn't support read-only mappings, use slow map */
+                slow_map = 1;
                 pci_dev->v_addrs[i].u.r_virtbase =
                     mmap(NULL,
                          cur_region->size,
@@ -566,8 +568,6 @@ static int assigned_dev_register_regions(PCIRegion *io_regions,
             if (i == PCI_ROM_SLOT) {
                 memset(pci_dev->v_addrs[i].u.r_virtbase, 0,
                        (cur_region->size + 0xFFF) & 0xFFFFF000);
-                mprotect(pci_dev->v_addrs[PCI_ROM_SLOT].u.r_virtbase,
-                         (cur_region->size + 0xFFF) & 0xFFFFF000, PROT_READ);
             }
 
             pci_dev->v_addrs[i].r_size = cur_region->size;
@@ -1691,12 +1691,8 @@ static void assigned_dev_load_option_rom(AssignedDevice *dev)
     /* Copy ROM contents into the space backing the ROM BAR */
     if (dev->v_addrs[PCI_ROM_SLOT].r_size >= size &&
         dev->v_addrs[PCI_ROM_SLOT].u.r_virtbase) {
-        mprotect(dev->v_addrs[PCI_ROM_SLOT].u.r_virtbase,
-                 size, PROT_READ | PROT_WRITE);
         memcpy(dev->v_addrs[PCI_ROM_SLOT].u.r_virtbase,
                buf, size);
-        mprotect(dev->v_addrs[PCI_ROM_SLOT].u.r_virtbase,
-                 size, PROT_READ);
     }
 
     free(buf);


  parent reply	other threads:[~2010-07-30 19:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-30 19:40 [PATCH 0/3] device-assignment: PCI option ROM fixes Alex Williamson
2010-07-30 19:40 ` [PATCH 1/3] device-assignment: Fix slow option ROM mapping Alex Williamson
2010-07-31 16:54   ` Chris Wright
2010-07-30 19:40 ` Alex Williamson [this message]
2010-07-31 16:55   ` [PATCH 2/3] device-assignment: Always use slow mapping for PCI option ROM Chris Wright
2010-07-30 19:40 ` [PATCH 3/3] device-assignment: Byte-wise ROM read Alex Williamson
2010-07-31 17:08   ` Chris Wright
2010-08-17  9:49 ` [PATCH 0/3] device-assignment: PCI option ROM fixes Avi Kivity

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=20100730194019.10110.21091.stgit@localhost6.localdomain6 \
    --to=alex.williamson@redhat.com \
    --cc=chrisw@redhat.com \
    --cc=ddutile@redhat.com \
    --cc=gleb@redhat.com \
    --cc=kvm@vger.kernel.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