[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 14/25] i386/kvm: ignore masked irqs when update msi r
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 14/25] i386/kvm: ignore masked irqs when update msi routes |
Date: |
Mon, 4 Feb 2019 09:43:46 -0500 |
From: Peter Xu <address@hidden>
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 <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
target/i386/kvm.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 9af4542fb8..beae1b99da 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -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);
--
MST
- Re: [Qemu-devel] [PULL 23/25] mmap-alloc: fix hugetlbfs misaligned length in ppc64, (continued)
- [Qemu-devel] [PULL 25/25] contrib/libvhost-user: cleanup casts, Michael S. Tsirkin, 2019/02/04
- [Qemu-devel] [PULL 20/25] fw_cfg: fix the life cycle and the name of "qemu_extra_params_fw", Michael S. Tsirkin, 2019/02/04
- [Qemu-devel] [PULL 24/25] r2d: fix build on mingw, Michael S. Tsirkin, 2019/02/04
- [Qemu-devel] [PULL 06/25] vhost-net-user: add stubs for when no virtio-net device is present, Michael S. Tsirkin, 2019/02/04
- [Qemu-devel] [PULL 22/25] mmap-alloc: unfold qemu_ram_mmap(), Michael S. Tsirkin, 2019/02/04
- [Qemu-devel] [PULL 17/25] vhost-user-blk: add discard/write zeroes features support, Michael S. Tsirkin, 2019/02/04
- [Qemu-devel] [PULL 18/25] hw/virtio: Use CONFIG_VIRTIO_PCI switch instead of CONFIG_PCI, Michael S. Tsirkin, 2019/02/04
- [Qemu-devel] [PULL 19/25] acpi: Make TPM 2.0 with TIS available as MSFT0101, Michael S. Tsirkin, 2019/02/04
- [Qemu-devel] [PULL 16/25] contrib/vhost-user-blk: fix the compilation issue, Michael S. Tsirkin, 2019/02/04
- [Qemu-devel] [PULL 14/25] i386/kvm: ignore masked irqs when update msi routes,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 07/25] vhost: restrict Linux dependency to kernel vhost, Michael S. Tsirkin, 2019/02/04
- [Qemu-devel] [PULL 11/25] intel_iommu: fix operator in vtd_switch_address_space, Michael S. Tsirkin, 2019/02/04
- [Qemu-devel] [PULL 08/25] vhost-net: compile it on all targets that have virtio-net., Michael S. Tsirkin, 2019/02/04
- [Qemu-devel] [PULL 15/25] contrib: compile vhost-user-blk tool by default, Michael S. Tsirkin, 2019/02/04
[Qemu-devel] [PULL 13/25] pci/msi: export msi_is_masked(), Michael S. Tsirkin, 2019/02/04