As previously indicated, I was working for quite a while on a major refactoring of the MSI "additions" we have in qemu-kvm to support in-kernel irqchip, vhost and device assignment. This is now the outcome. I'm quite happy with it, things are still working (apparently), and the invasiveness of KVM hooks into the MSI layer is significantly reduced. Moreover, I was able to port the device assignment code over generic MSI support, reducing the size of that file a bit further. Some further highlights: - fix for HPET MSI support with in-kernel irqchip - fully configurable MSI-X (allows 1:1 mapping for assigned devices) - refactored KVM core API for device assignment and IRQ routing I'm sending the whole series in one chunk so that you can see what the result will be. It's RFC as I bet that there are regressions included and maybe still room left for improvements. Once all is fine (can be broken up into multiple chunks for the merge), I would suggest patching qemu-kvm first and then start with porting things over to upstream. Comments & review welcome. CC: Alexander Graf <agraf@xxxxxxx> CC: Gerd Hoffmann <kraxel@xxxxxxxxxx> CC: Isaku Yamahata <yamahata@xxxxxxxxxxxxx> Jan Kiszka (45): msi: Guard msi/msix_write_config with msi_present msi: Guard msi_reset with msi_present msi: Use msi/msix_present more consistently msi: Invoke msi/msix_reset from PCI core msi: Invoke msi/msix_write_config from PCI core msix: Prevent bogus mask updates on MMIO accesses msi: Generalize msix_supported to msi_supported Introduce MSIMessage structure msi: Factor out msi_message_from_vector msix: Factor out msix_message_from_vector msi: Factor out delivery hook msi: Introduce MSIRoutingCache hpet: Use msi_deliver qemu-kvm: Drop useless kvm_clear_gsi_routes qemu-kvm: Drop unused kvm_del_irq_route qemu-kvm: Use MSIMessage and MSIRoutingCache qemu-kvm: Track MSIRoutingCache in KVM routing table qemu-kvm: Hook into MSI delivery at APIC level qemu-kvm: Factor out kvm_msi_irqfd_set qemu-kvm: msix: Only invoke msix_handle_mask_update on changes qemu-kvm: msix: Don't fire notifier spuriously on set/unset qemu-kvm: msix: Fire mask notifier on global mask changes qemu-kvm: Rework MSI-X mask notifier to generic MSI config notifiers qemu-kvm: msix: Don't handle mask updated while disabled qemu-kvm: Update MSI cache on kvm_msi_irqfd_set qemu-kvm: Use g_realloc for irq_routes extension qemu-kvm: Lazily update MSI caches qemu-kvm: msix: Drop tracking of used vectors pci-assign: Drop kvm_assigned_irq::host_irq initialization pci-assign: Rename assign_irq to assign_intx qemu-kvm: Refactor kvm_deassign_irq to kvm_device_irq_deassign pci-assign: Factor out deassign_irq qemu-kvm: Factor out kvm_device_intx_assign qemu-kvm: Factor out kvm_device_msi_assign pci-assign: Polish assigned_dev_update_msix_mmio qemu-kvm: Factor out kvm_device_msix_* services qemu-kvm: Clean up irqrouting API msi: Implement config notifiers for legacy MSI pci-assign: Use generic MSI support qemu-kvm: msix: Drop check for preexisting cap from msix_add_config msix: Drop unused msix_bar_size msix: Introduce msix_init_simple msix: Allow to customize capability on init pci-assign: Use generic MSI-X support pci-assign: Fix coding style issues hw/apic.c | 28 ++- hw/apic.h | 1 + hw/device-assignment.c | 751 +++++++++++++++++------------------------------ hw/device-assignment.h | 29 +-- hw/hpet.c | 7 +- hw/ide/ich.c | 8 - hw/intel-hda.c | 12 - hw/ioh3420.c | 3 +- hw/ivshmem.c | 22 +-- hw/msi.c | 329 +++++++++++++--------- hw/msi.h | 30 ++- hw/msix.c | 626 ++++++++++++++++++---------------------- hw/msix.h | 29 +- hw/pc.c | 15 +- hw/pci.c | 9 +- hw/pci.h | 34 ++- hw/pci_bridge.c | 4 + hw/virtio-pci.c | 75 ++--- hw/virtio-pci.h | 1 - hw/xio3130_downstream.c | 3 +- hw/xio3130_upstream.c | 2 - kvm-all.c | 1 + kvm-stub.c | 23 +-- kvm.h | 17 +- qemu-common.h | 2 + qemu-kvm-x86.c | 1 - qemu-kvm.c | 281 ++++++++++++------ qemu-kvm.h | 81 +----- 28 files changed, 1110 insertions(+), 1314 deletions(-) -- 1.7.3.4 -- 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