diff mbox

[1/5] qemu-kvm: device assignment: Reset MSI-X table mask bit as set

Message ID 1289461894-7355-2-git-send-email-sheng@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sheng Yang Nov. 11, 2010, 7:51 a.m. UTC
None
diff mbox

Patch

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;