From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Levin Subject: [PATCH 2/2] kvm tools: inject MSI directly without going through a GSI Date: Thu, 2 Aug 2012 16:29:24 +0200 Message-ID: <1343917764-28715-2-git-send-email-levinsasha928@gmail.com> References: <1343917764-28715-1-git-send-email-levinsasha928@gmail.com> Cc: kvm@vger.kernel.org, Sasha Levin To: penberg@kernel.org, mingo@elte.hu, gorcunov@gmail.com Return-path: Received: from mail-bk0-f46.google.com ([209.85.214.46]:43501 "EHLO mail-bk0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754796Ab2HBO3N (ORCPT ); Thu, 2 Aug 2012 10:29:13 -0400 Received: by bkwj10 with SMTP id j10so4280789bkw.19 for ; Thu, 02 Aug 2012 07:29:12 -0700 (PDT) In-Reply-To: <1343917764-28715-1-git-send-email-levinsasha928@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: 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 --- 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 #include #include +#include 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