i386/kvm: ignore masked irqs when update msi routes
When we are with intel-iommu device and with IR on, KVM will register
an IEC notifier to detect interrupt updates from the guest and we'll
kick off kvm_update_msi_routes_all() when it happens to make sure
kernel IRQ cache is matching the latest.
Though, kvm_update_msi_routes_all() is buggy in that it ignored the
mask bit of either MSI/MSIX messages and it tries to translate the
message even if the corresponding message was already masked by the
guest driver (hence the MSI/MSIX message will be invalid).
Without this patch, we can receive an error message when we reboot a
guest with both an assigned vfio-pci device and intel-iommu enabled:
qemu-system-x86_64: vtd_interrupt_remap_msi: MSI address low 32 bit invalid: 0x0
The error does not affect functionality of the guest since when we
failed to translate we'll just silently continue (which makes sense
since crashing the VM for this seems even worse), but still it's
better to fix it up.
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <20190116030815.27273-5-peterx@redhat.com>
[PMD: this patch was first (incorrectly) introduced as a56de056c9
]
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190212140621.17009-4-philmd@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
This commit is contained in:
parent
4387b78ac3
commit
558e8c6139
@ -3894,7 +3894,7 @@ static QLIST_HEAD(, MSIRouteEntry) msi_route_list = \
|
||||
static void kvm_update_msi_routes_all(void *private, bool global,
|
||||
uint32_t index, uint32_t mask)
|
||||
{
|
||||
int cnt = 0;
|
||||
int cnt = 0, vector;
|
||||
MSIRouteEntry *entry;
|
||||
MSIMessage msg;
|
||||
PCIDevice *dev;
|
||||
@ -3902,11 +3902,19 @@ static void kvm_update_msi_routes_all(void *private, bool global,
|
||||
/* TODO: explicit route update */
|
||||
QLIST_FOREACH(entry, &msi_route_list, list) {
|
||||
cnt++;
|
||||
vector = entry->vector;
|
||||
dev = entry->dev;
|
||||
if (!msix_enabled(dev) && !msi_enabled(dev)) {
|
||||
if (msix_enabled(dev) && !msix_is_masked(dev, vector)) {
|
||||
msg = msix_get_message(dev, vector);
|
||||
} else if (msi_enabled(dev) && !msi_is_masked(dev, vector)) {
|
||||
msg = msi_get_message(dev, vector);
|
||||
} else {
|
||||
/*
|
||||
* Either MSI/MSIX is disabled for the device, or the
|
||||
* specific message was masked out. Skip this one.
|
||||
*/
|
||||
continue;
|
||||
}
|
||||
msg = pci_get_msi_message(dev, entry->vector);
|
||||
kvm_irqchip_update_msi_route(kvm_state, entry->virq, msg, dev);
|
||||
}
|
||||
kvm_irqchip_commit_routes(kvm_state);
|
||||
|
Loading…
Reference in New Issue
Block a user