From patchwork Wed Dec 23 10:07:47 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 69495 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id nBNAApl5001085 for ; Wed, 23 Dec 2009 10:10:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755637AbZLWKKl (ORCPT ); Wed, 23 Dec 2009 05:10:41 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755648AbZLWKKk (ORCPT ); Wed, 23 Dec 2009 05:10:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39018 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755151AbZLWKKk (ORCPT ); Wed, 23 Dec 2009 05:10:40 -0500 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBNAAZa4028743 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 23 Dec 2009 05:10:35 -0500 Received: from redhat.com (vpn-6-207.tlv.redhat.com [10.35.6.207]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id nBNAAXmc026835; Wed, 23 Dec 2009 05:10:34 -0500 Date: Wed, 23 Dec 2009 12:07:47 +0200 From: "Michael S. Tsirkin" To: avi@redhat.com, agraf@suse.de, kvm@vger.kernel.org Subject: [PATCHv3] slow_map: minor improvements to ROM BAR handling Message-ID: <20091223100747.GA4330@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/hw/device-assignment.c b/hw/device-assignment.c index 000fa61..9197dca 100644 --- a/hw/device-assignment.c +++ b/hw/device-assignment.c @@ -233,7 +233,10 @@ static void assigned_dev_iomem_map_slow(PCIDevice *pci_dev, int region_num, int m; DEBUG("slow map\n"); - m = cpu_register_io_memory(slow_bar_read, slow_bar_write, region); + if (region_num == PCI_ROM_SLOT) + m = cpu_register_io_memory(slow_bar_read, NULL, region); + else + m = cpu_register_io_memory(slow_bar_read, slow_bar_write, region); cpu_register_physical_memory(e_phys, e_size, m); /* MSI-X MMIO page */ @@ -486,25 +489,23 @@ static int assigned_dev_register_regions(PCIRegion *io_regions, : PCI_BASE_ADDRESS_SPACE_MEMORY; if (cur_region->size & 0xFFF) { - fprintf(stderr, "PCI region %d at address 0x%llx " - "has size 0x%x, which is not a multiple of 4K. " - "You might experience some performance hit due to that.\n", - i, (unsigned long long)cur_region->base_addr, - cur_region->size); + if (i != PCI_ROM_SLOT) { + fprintf(stderr, "PCI region %d at address 0x%llx " + "has size 0x%x, which is not a multiple of 4K. " + "You might experience some performance hit " + "due to that.\n", + i, (unsigned long long)cur_region->base_addr, + cur_region->size); + } slow_map = 1; } - if (slow_map && (i == PCI_ROM_SLOT)) { - fprintf(stderr, "ROM not aligned - can't continue\n"); - return -1; - } - /* map physical memory */ pci_dev->v_addrs[i].e_physbase = cur_region->base_addr; if (i == PCI_ROM_SLOT) { pci_dev->v_addrs[i].u.r_virtbase = mmap(NULL, - (cur_region->size + 0xFFF) & 0xFFFFF000, + cur_region->size, PROT_WRITE | PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE, 0, (off_t) 0);