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@xxxxxxxxxx> --- 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); -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html