~ubuntu-branches/ubuntu/trusty/qemu/trusty

« back to all changes in this revision

Viewing changes to hw/i386/kvm/pci-assign.c

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2013-10-22 22:47:07 UTC
  • mfrom: (1.8.3) (10.1.42 sid)
  • Revision ID: package-import@ubuntu.com-20131022224707-1lya34fw3k3f24tv
Tags: 1.6.0+dfsg-2ubuntu1
* Merge 1.6.0~rc0+dfsg-2exp from debian experimental.  Remaining changes:
  - debian/control
    * update maintainer
    * remove libiscsi, usb-redir, vde, vnc-jpeg, and libssh2-1-dev
      from build-deps
    * enable rbd
    * add qemu-system and qemu-common B/R to qemu-keymaps
    * add D:udev, R:qemu, R:qemu-common and B:qemu-common to
      qemu-system-common
    * qemu-system-arm, qemu-system-ppc, qemu-system-sparc:
      - add qemu-kvm to Provides
      - add qemu-common, qemu-kvm, kvm to B/R
      - remove openbios-sparc from qemu-system-sparc D
      - drop openbios-ppc and openhackware Depends to Suggests (for now)
    * qemu-system-x86:
      - add qemu-common to Breaks/Replaces.
      - add cpu-checker to Recommends.
    * qemu-user: add B/R:qemu-kvm
    * qemu-kvm:
      - add armhf armel powerpc sparc to Architecture
      - C/R/P: qemu-kvm-spice
    * add qemu-common package
    * drop qemu-slof which is not packaged in ubuntu
  - add qemu-system-common.links for tap ifup/down scripts and OVMF link.
  - qemu-system-x86.links:
    * remove pxe rom links which are in kvm-ipxe
    * add symlink for kvm.1 manpage
  - debian/rules
    * add kvm-spice symlink to qemu-kvm
    * call dh_installmodules for qemu-system-x86
    * update dh_installinit to install upstart script
    * run dh_installman (Closes: #709241) (cherrypicked from 1.5.0+dfsg-2)
  - Add qemu-utils.links for kvm-* symlinks.
  - Add qemu-system-x86.qemu-kvm.upstart and .default
  - Add qemu-system-x86.modprobe to set nesting=1
  - Add qemu-system-common.preinst to add kvm group
  - qemu-system-common.postinst: remove bad group acl if there, then have
    udev relabel /dev/kvm.
  - New linaro patches from qemu-linaro rebasing branch
  - Dropped patches:
    * xen-simplify-xen_enabled.patch
    * sparc-linux-user-fix-missing-symbols-in-.rel-.rela.plt-sections.patch
    * main_loop-do-not-set-nonblocking-if-xen_enabled.patch
    * xen_machine_pv-do-not-create-a-dummy-CPU-in-machine-.patch
    * virtio-rng-fix-crash
  - Kept patches:
    * expose_vms_qemu64cpu.patch - updated
    * linaro arm patches from qemu-linaro rebasing branch
  - New patches:
    * fix-pci-add: change CONFIG variable in ifdef to make sure that
      pci_add is defined.
* Add linaro patches
* Add experimental mach-virt patches for arm virtualization.
* qemu-system-common.install: add debian/tmp/usr/lib to install the
  qemu-bridge-helper

Show diffs side-by-side

added added

removed removed

Lines of Context:
226
226
    uint32_t r;
227
227
 
228
228
    r = *in;
229
 
    DEBUG("slow_bar_readl addr=0x" TARGET_FMT_plx " val=0x%08x\n", addr, r);
 
229
    DEBUG("addr=0x" TARGET_FMT_plx " val=0x%08x\n", addr, r);
230
230
 
231
231
    return r;
232
232
}
238
238
    uint32_t r;
239
239
 
240
240
    r = *in;
241
 
    DEBUG("slow_bar_readl addr=0x" TARGET_FMT_plx " val=0x%08x\n", addr, r);
 
241
    DEBUG("addr=0x" TARGET_FMT_plx " val=0x%08x\n", addr, r);
242
242
 
243
243
    return r;
244
244
}
250
250
    uint32_t r;
251
251
 
252
252
    r = *in;
253
 
    DEBUG("slow_bar_readl addr=0x" TARGET_FMT_plx " val=0x%08x\n", addr, r);
 
253
    DEBUG("addr=0x" TARGET_FMT_plx " val=0x%08x\n", addr, r);
254
254
 
255
255
    return r;
256
256
}
260
260
    AssignedDevRegion *d = opaque;
261
261
    uint8_t *out = d->u.r_virtbase + addr;
262
262
 
263
 
    DEBUG("slow_bar_writeb addr=0x" TARGET_FMT_plx " val=0x%02x\n", addr, val);
 
263
    DEBUG("addr=0x" TARGET_FMT_plx " val=0x%02x\n", addr, val);
264
264
    *out = val;
265
265
}
266
266
 
269
269
    AssignedDevRegion *d = opaque;
270
270
    uint16_t *out = (uint16_t *)(d->u.r_virtbase + addr);
271
271
 
272
 
    DEBUG("slow_bar_writew addr=0x" TARGET_FMT_plx " val=0x%04x\n", addr, val);
 
272
    DEBUG("addr=0x" TARGET_FMT_plx " val=0x%04x\n", addr, val);
273
273
    *out = val;
274
274
}
275
275
 
278
278
    AssignedDevRegion *d = opaque;
279
279
    uint32_t *out = (uint32_t *)(d->u.r_virtbase + addr);
280
280
 
281
 
    DEBUG("slow_bar_writel addr=0x" TARGET_FMT_plx " val=0x%08x\n", addr, val);
 
281
    DEBUG("addr=0x" TARGET_FMT_plx " val=0x%08x\n", addr, val);
282
282
    *out = val;
283
283
}
284
284
 
298
298
    PCIRegion *real_region = &r_dev->real_device.regions[region_num];
299
299
 
300
300
    if (e_size > 0) {
301
 
        memory_region_init(&region->container, "assigned-dev-container",
302
 
                           e_size);
 
301
        memory_region_init(&region->container, OBJECT(pci_dev),
 
302
                           "assigned-dev-container", e_size);
303
303
        memory_region_add_subregion(&region->container, 0, &region->real_iomem);
304
304
 
305
305
        /* deal with MSI-X MMIO page */
329
329
    AssignedDevRegion *region = &r_dev->v_addrs[region_num];
330
330
 
331
331
    region->e_size = size;
332
 
    memory_region_init(&region->container, "assigned-dev-container", size);
333
 
    memory_region_init_io(&region->real_iomem, &assigned_dev_ioport_ops,
334
 
                          r_dev->v_addrs + region_num,
 
332
    memory_region_init(&region->container, OBJECT(pci_dev),
 
333
                       "assigned-dev-container", size);
 
334
    memory_region_init_io(&region->real_iomem, OBJECT(pci_dev),
 
335
                          &assigned_dev_ioport_ops, r_dev->v_addrs + region_num,
335
336
                          "assigned-dev-iomem", size);
336
337
    memory_region_add_subregion(&region->container, 0, &region->real_iomem);
337
338
}
479
480
                             "due to that.",
480
481
                             i, cur_region->base_addr, cur_region->size);
481
482
                memory_region_init_io(&pci_dev->v_addrs[i].real_iomem,
482
 
                                      &slow_bar_ops, &pci_dev->v_addrs[i],
 
483
                                      OBJECT(pci_dev), &slow_bar_ops,
 
484
                                      &pci_dev->v_addrs[i],
483
485
                                      "assigned-dev-slow-bar",
484
486
                                      cur_region->size);
485
487
            } else {
488
490
                snprintf(name, sizeof(name), "%s.bar%d",
489
491
                         object_get_typename(OBJECT(pci_dev)), i);
490
492
                memory_region_init_ram_ptr(&pci_dev->v_addrs[i].real_iomem,
491
 
                                           name, cur_region->size,
492
 
                                           virtbase);
 
493
                                           OBJECT(pci_dev), name,
 
494
                                           cur_region->size, virtbase);
493
495
                vmstate_register_ram(&pci_dev->v_addrs[i].real_iomem,
494
496
                                     &pci_dev->dev.qdev);
495
497
            }
548
550
    if (fscanf(f, "%li\n", &id) == 1) {
549
551
        *val = id;
550
552
    } else {
 
553
        fclose(f);
551
554
        return -1;
552
555
    }
553
556
    fclose(f);
1026
1029
    }
1027
1030
}
1028
1031
 
 
1032
static void assigned_dev_update_msi_msg(PCIDevice *pci_dev)
 
1033
{
 
1034
    AssignedDevice *assigned_dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
 
1035
    uint8_t ctrl_byte = pci_get_byte(pci_dev->config + pci_dev->msi_cap +
 
1036
                                     PCI_MSI_FLAGS);
 
1037
 
 
1038
    if (assigned_dev->assigned_irq_type != ASSIGNED_IRQ_MSI ||
 
1039
        !(ctrl_byte & PCI_MSI_FLAGS_ENABLE)) {
 
1040
        return;
 
1041
    }
 
1042
 
 
1043
    kvm_irqchip_update_msi_route(kvm_state, assigned_dev->msi_virq[0],
 
1044
                                 msi_get_message(pci_dev, 0));
 
1045
}
 
1046
 
1029
1047
static bool assigned_dev_msix_masked(MSIXTableEntry *entry)
1030
1048
{
1031
1049
    return (entry->ctrl & cpu_to_le32(0x1)) != 0;
1201
1219
        if (range_covers_byte(address, len,
1202
1220
                              pci_dev->msi_cap + PCI_MSI_FLAGS)) {
1203
1221
            assigned_dev_update_msi(pci_dev);
 
1222
        } else if (ranges_overlap(address, len, /* 32bit MSI only */
 
1223
                                  pci_dev->msi_cap + PCI_MSI_ADDRESS_LO, 6)) {
 
1224
            assigned_dev_update_msi_msg(pci_dev);
1204
1225
        }
1205
1226
    }
1206
1227
    if (assigned_dev->cap.available & ASSIGNED_DEVICE_CAP_MSIX) {
1631
1652
 
1632
1653
    assigned_dev_msix_reset(dev);
1633
1654
 
1634
 
    memory_region_init_io(&dev->mmio, &assigned_dev_msix_mmio_ops, dev,
1635
 
                          "assigned-dev-msix", MSIX_PAGE_SIZE);
 
1655
    memory_region_init_io(&dev->mmio, OBJECT(dev), &assigned_dev_msix_mmio_ops,
 
1656
                          dev, "assigned-dev-msix", MSIX_PAGE_SIZE);
1636
1657
    return 0;
1637
1658
}
1638
1659
 
1835
1856
    dc->props       = assigned_dev_properties;
1836
1857
    dc->vmsd        = &vmstate_assigned_device;
1837
1858
    dc->reset       = reset_assigned_device;
 
1859
    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
1838
1860
    dc->desc        = "KVM-based PCI passthrough";
1839
1861
}
1840
1862
 
1897
1919
 
1898
1920
    snprintf(name, sizeof(name), "%s.rom",
1899
1921
            object_get_typename(OBJECT(dev)));
1900
 
    memory_region_init_ram(&dev->dev.rom, name, st.st_size);
 
1922
    memory_region_init_ram(&dev->dev.rom, OBJECT(dev), name, st.st_size);
1901
1923
    vmstate_register_ram(&dev->dev.rom, &dev->dev.qdev);
1902
1924
    ptr = memory_region_get_ram_ptr(&dev->dev.rom);
1903
1925
    memset(ptr, 0xff, st.st_size);