Skip to content

RFC qemu-kvm: MSI layer rework for in-kernel irqchip support

Jan Kiszka kvm qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest45 patches 98 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/45msi: Guard msi/msix_write_config with msi_presenthw/msi.c hw/msix.c+3 -20 replies
2/45msi: Guard msi_reset with msi_presenthw/msi.c+3 -00 replies
3/45msi: Use msi/msix_present more consistentlyhw/msi.c hw/msix.c+9 -130 replies
4/45msi: Invoke msi/msix_reset from PCI corehw/ioh3420.c hw/pci.c hw/pci_bridge.c +3 more+10 -40 replies
5/45msi: Invoke msi/msix_write_config from PCI corehw/ide/ich.c hw/intel-hda.c hw/ioh3420.c +5 more+4 -260 replies
6/45msix: Prevent bogus mask updates on MMIO accesseshw/msix.c+10 -67 replies
7/45msi: Generalize msix_supported to msi_supportedhw/msi.c hw/msi.h hw/msix.c +2 more+15 -90 replies
8/45Introduce MSIMessage structurehw/msi.h qemu-common.h+6 -06 replies
9/45msi: Factor out msi_message_from_vectorhw/msi.c+25 -180 replies
10/45msix: Factor out msix_message_from_vectorhw/msix.c+13 -60 replies
11/45msi: Factor out delivery hookhw/apic.c hw/apic.h hw/msi.c +3 more+36 -918 replies
12/45msi: Introduce MSIRoutingCachehw/apic.c hw/apic.h hw/msi.c +5 more+37 -1011 replies
13/45hpet: Use msi_deliverhw/hpet.c+6 -10 replies
14/45qemu-kvm: Drop useless kvm_clear_gsi_routesqemu-kvm-x86.c qemu-kvm.c qemu-kvm.h+0 -200 replies
15/45qemu-kvm: Drop unused kvm_del_irq_routeqemu-kvm.c qemu-kvm.h+0 -240 replies
16/45qemu-kvm: Use MSIMessage and MSIRoutingCachehw/msi.c hw/msix.c hw/pci.h +4 more+57 -1010 replies
17/45qemu-kvm: Track MSIRoutingCache in KVM routing tablehw/device-assignment.c kvm-all.c qemu-kvm.c +1 more+23 -103 replies
18/45qemu-kvm: Hook into MSI delivery at APIC levelhw/apic.c hw/msi.c hw/msix.c+15 -190 replies
19/45qemu-kvm: Factor out kvm_msi_irqfd_sethw/virtio-pci.c kvm.h qemu-kvm.c+18 -40 replies
20/45qemu-kvm: msix: Only invoke msix_handle_mask_update on changeshw/msix.c hw/msix.h hw/pci.c+23 -180 replies
21/45qemu-kvm: msix: Don't fire notifier spuriously on set/unsethw/msix.c+14 -80 replies
22/45qemu-kvm: msix: Fire mask notifier on global mask changeshw/msix.c+9 -75 replies
23/45qemu-kvm: Rework MSI-X mask notifier to generic MSI config notifiershw/msix.c hw/msix.h hw/pci.h +1 more+102 -556 replies
24/45qemu-kvm: msix: Don't handle mask updated while disabledhw/msix.c+1 -10 replies
25/45qemu-kvm: Update MSI cache on kvm_msi_irqfd_sethw/virtio-pci.c kvm.h qemu-kvm.c+22 -80 replies
26/45qemu-kvm: Use g_realloc for irq_routes extensionqemu-kvm.c+1 -60 replies
27/45qemu-kvm: Lazily update MSI cacheshw/apic.c hw/msi.c hw/msi.h +6 more+75 -2070 replies
28/45qemu-kvm: msix: Drop tracking of used vectorshw/ivshmem.c hw/msix.c hw/msix.h +2 more+26 -7933 replies
29/45pci-assign: Drop kvm_assigned_irq::host_irq initializationhw/device-assignment.c+0 -10 replies
30/45pci-assign: Rename assign_irq to assign_intxhw/device-assignment.c+7 -70 replies
31/45qemu-kvm: Refactor kvm_deassign_irq to kvm_device_irq_deassignhw/device-assignment.c qemu-kvm.c qemu-kvm.h+35 -330 replies
32/45pci-assign: Factor out deassign_irqhw/device-assignment.c+18 -120 replies
33/45qemu-kvm: Factor out kvm_device_intx_assignhw/device-assignment.c qemu-kvm.c qemu-kvm.h+29 -110 replies
34/45qemu-kvm: Factor out kvm_device_msi_assignhw/device-assignment.c qemu-kvm.c qemu-kvm.h+38 -500 replies
35/45pci-assign: Polish assigned_dev_update_msix_mmiohw/device-assignment.c+29 -240 replies
36/45qemu-kvm: Factor out kvm_device_msix_* serviceshw/device-assignment.c hw/device-assignment.h qemu-kvm.c +1 more+76 -810 replies
37/45qemu-kvm: Clean up irqrouting APIkvm-stub.c kvm.h qemu-kvm.c +1 more+6 -810 replies
38/45msi: Implement config notifiers for legacy MSIhw/msi.c hw/msi.h hw/pci.c +1 more+166 -170 replies
39/45pci-assign: Use generic MSI supporthw/device-assignment.c+31 -460 replies
40/45qemu-kvm: msix: Drop check for preexisting cap from msix_add_confighw/msix.c+33 -350 replies
41/45msix: Drop unused msix_bar_sizehw/msix.c hw/msix.h hw/pci.h+0 -120 replies
42/45msix: Introduce msix_init_simplehw/ivshmem.c hw/msix.c hw/msix.h +2 more+23 -416 replies
43/45msix: Allow to customize capability on inithw/msix.c hw/msix.h hw/pci.h+150 -1140 replies
44/45pci-assign: Use generic MSI-X supporthw/device-assignment.c hw/device-assignment.h+88 -2610 replies
45/45pci-assign: Fix coding style issueshw/device-assignment.c hw/device-assignment.h+107 -1060 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC][PATCH 00/45] qemu-kvm: MSI layer rework for in-kernel irqchip support

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 <[email protected]>
CC Gerd Hoffmann <[email protected]>
CC Isaku Yamahata <[email protected]>

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(-)
Signature · 1 line
1.7.3.4