[PATCH 2/2] kvm tools: inject MSI directly without going through a GSI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use the new KVM_SIGNAL_MSI ioctl to inject interrupts directly.

We still create GSIs and keep them for two reasons:

 - They're required by virtio-* devices.
 - There's not much overhead since we just create them when starting the
guest, they don't use anything when the guest is running.

Signed-off-by: Sasha Levin <levinsasha928@xxxxxxxxx>
---
 tools/kvm/virtio/pci.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/tools/kvm/virtio/pci.c b/tools/kvm/virtio/pci.c
index f17cd8a..9888b1a 100644
--- a/tools/kvm/virtio/pci.c
+++ b/tools/kvm/virtio/pci.c
@@ -10,6 +10,7 @@
 #include <linux/virtio_pci.h>
 #include <linux/byteorder.h>
 #include <string.h>
+#include <sys/ioctl.h>
 
 static void virtio_pci__ioevent_callback(struct kvm *kvm, void *param)
 {
@@ -236,6 +237,17 @@ static void virtio_pci__mmio_callback(u64 addr, u8 *data, u32 len, u8 is_write,
 		memcpy(data, table + addr - offset, len);
 }
 
+static void virtio_pci__signal_msi(struct kvm *kvm, struct virtio_pci *vpci, int vec)
+{
+	struct kvm_msi msi = {
+		.address_lo = vpci->msix_table[vec].msg.address_lo,
+		.address_hi = vpci->msix_table[vec].msg.address_hi,
+		.data = vpci->msix_table[vec].msg.data,
+	};
+
+	ioctl(kvm->vm_fd, KVM_SIGNAL_MSI, &msi);
+}
+
 int virtio_pci__signal_vq(struct kvm *kvm, struct virtio_device *vdev, u32 vq)
 {
 	struct virtio_pci *vpci = vdev->virtio;
@@ -249,7 +261,7 @@ int virtio_pci__signal_vq(struct kvm *kvm, struct virtio_device *vdev, u32 vq)
 			return 0;
 		}
 
-		kvm__irq_trigger(kvm, vpci->gsis[vq]);
+		virtio_pci__signal_msi(kvm, vpci, vpci->vq_vector[vq]);
 	} else {
 		vpci->isr = VIRTIO_IRQ_HIGH;
 		kvm__irq_trigger(kvm, vpci->pci_hdr.irq_line);
@@ -270,7 +282,7 @@ int virtio_pci__signal_config(struct kvm *kvm, struct virtio_device *vdev)
 			return 0;
 		}
 
-		kvm__irq_trigger(kvm, vpci->config_gsi);
+		virtio_pci__signal_msi(kvm, vpci, vpci->vq_vector[vpci->config_vector]);
 	} else {
 		vpci->isr = VIRTIO_PCI_ISR_CONFIG;
 		kvm__irq_trigger(kvm, vpci->pci_hdr.irq_line);
-- 
1.7.8.6

--
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


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux