According to the PCI spec, mask bit of MSI-X table should be set after reset. Signed-off-by: Sheng Yang <sheng@xxxxxxxxxxxxxxx> --- hw/device-assignment.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/device-assignment.c b/hw/device-assignment.c index 2605bd1..dfca764 100644 --- a/hw/device-assignment.c +++ b/hw/device-assignment.c @@ -1106,6 +1106,8 @@ static void assigned_dev_update_msi(PCIDevice *pci_dev, unsigned int ctrl_pos) #endif #ifdef KVM_CAP_DEVICE_MSIX + +#define PCI_MSIX_CTRL_MASKBIT 1ul static int assigned_dev_update_msix_mmio(PCIDevice *pci_dev) { AssignedDevice *adev = container_of(pci_dev, AssignedDevice, dev); @@ -1128,9 +1130,8 @@ static int assigned_dev_update_msix_mmio(PCIDevice *pci_dev) /* Get the usable entry number for allocating */ for (i = 0; i < entries_max_nr; i++) { memcpy(&msg_ctrl, va + i * 16 + 12, 4); - memcpy(&msg_data, va + i * 16 + 8, 4); /* Ignore unused entry even it's unmasked */ - if (msg_data == 0) + if (msg_ctrl & PCI_MSIX_CTRL_MASKBIT) continue; entries_nr ++; } @@ -1163,10 +1164,10 @@ static int assigned_dev_update_msix_mmio(PCIDevice *pci_dev) if (entries_nr >= msix_nr.entry_nr) break; memcpy(&msg_ctrl, va + i * 16 + 12, 4); - memcpy(&msg_data, va + i * 16 + 8, 4); - if (msg_data == 0) + if (msg_ctrl & PCI_MSIX_CTRL_MASKBIT) continue; + memcpy(&msg_data, va + i * 16 + 8, 4); memcpy(&msg_addr, va + i * 16, 4); memcpy(&msg_upper_addr, va + i * 16 + 4, 4); @@ -1398,6 +1399,7 @@ static CPUReadMemoryFunc *msix_mmio_read[] = { static int assigned_dev_register_msix_mmio(AssignedDevice *dev) { + int i; dev->msix_table_page = mmap(NULL, 0x1000, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, 0, 0); @@ -1407,6 +1409,8 @@ static int assigned_dev_register_msix_mmio(AssignedDevice *dev) return -EFAULT; } memset(dev->msix_table_page, 0, 0x1000); + for (i = 0; i < 0x1000; i += 0x10) + *(uint32_t *)(dev->msix_table_page + i + 0xc) = 1; dev->mmio_index = cpu_register_io_memory( msix_mmio_read, msix_mmio_write, dev); return 0; -- 1.7.0.1 -- 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