Signed-off-by: Sheng Yang <[email protected]>
---
 hw/device-assignment.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/hw/device-assignment.c b/hw/device-assignment.c
index d1a6282..aa3358e 100644
--- a/hw/device-assignment.c
+++ b/hw/device-assignment.c
@@ -269,6 +269,9 @@ static void assigned_dev_iomem_map(PCIDevice *pci_dev, int 
region_num,
     AssignedDevRegion *region = &r_dev->v_addrs[region_num];
     PCIRegion *real_region = &r_dev->real_device.regions[region_num];
     int ret = 0;
+#ifdef KVM_CAP_DEVICE_MSIX_MASK
+    struct kvm_assigned_msix_mmio msix_mmio;
+#endif
 
     DEBUG("e_phys=%08" FMT_PCIBUS " r_virt=%p type=%d len=%08" FMT_PCIBUS " 
region_num=%d \n",
           e_phys, region->u.r_virtbase, type, e_size, region_num);
@@ -287,6 +290,16 @@ static void assigned_dev_iomem_map(PCIDevice *pci_dev, int 
region_num,
 
             cpu_register_physical_memory(e_phys + offset,
                     TARGET_PAGE_SIZE, r_dev->mmio_index);
+#ifdef KVM_CAP_DEVICE_MSIX_MASK
+           memset(&msix_mmio, 0, sizeof(struct kvm_assigned_msix_mmio));
+           msix_mmio.assigned_dev_id = calc_assigned_dev_id(r_dev->h_segnr,
+                           r_dev->h_busnr, r_dev->h_devfn);
+           msix_mmio.base_addr = e_phys + offset;
+           if (kvm_assign_reg_msix_mmio(kvm_context, &msix_mmio))
+                fprintf(stderr, "fail to register in-kernel msix_mmio!\n");
+            /* We can still continue because the MMIO accessing can fall
+             * back to QEmu */
+#endif
         }
     }
 
-- 
1.7.0.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to