From patchwork Fri Jul 30 19:40:19 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 116106 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o6UJePV8016492 for ; Fri, 30 Jul 2010 19:40:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754940Ab0G3TkX (ORCPT ); Fri, 30 Jul 2010 15:40:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:20642 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754036Ab0G3TkV (ORCPT ); Fri, 30 Jul 2010 15:40:21 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6UJeKJH019739 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 30 Jul 2010 15:40:20 -0400 Received: from localhost6.localdomain6 (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6UJeJ9i019202; Fri, 30 Jul 2010 15:40:20 -0400 From: Alex Williamson Subject: [PATCH 2/3] device-assignment: Always use slow mapping for PCI option ROM To: kvm@vger.kernel.org Cc: ddutile@redhat.com, chrisw@redhat.com, gleb@redhat.com, alex.williamson@redhat.com Date: Fri, 30 Jul 2010 13:40:19 -0600 Message-ID: <20100730194019.10110.21091.stgit@localhost6.localdomain6> In-Reply-To: <20100730193941.10110.92913.stgit@localhost6.localdomain6> References: <20100730193941.10110.92913.stgit@localhost6.localdomain6> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 30 Jul 2010 19:40:26 +0000 (UTC) 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);