From patchwork Thu Aug 2 14:29:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 1267621 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id DB7963FCC5 for ; Thu, 2 Aug 2012 14:29:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754873Ab2HBO3O (ORCPT ); Thu, 2 Aug 2012 10:29:14 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=nHba+sm5HwxcSt1heIuv2OuTUlFGMMwnNhveaO4TIUc=; b=fltlmaa8amJ1VZttBbDOjte2f0qrcrJ2uCuBPEPqMF0Hx7KyUaykXr10nmfxWKLem2 XJXnd9SP29BW7B7i71dekPFSAWJx3tlby8eZN6wsY8uS0+Rsruaxe+yR8F+Lv5MVKQlu qTWympPyGCqAch7hVNqwYjap8bFHvC5+uDyWncGzh0wzdlzGZVK1wFM9BvzwiQ4187Mv 1xIQrZ7tkcKczTWSISuEH9MXOuy7FfyuFFDl8KiGAFH7r2PM+vpUQJUCZY7KvqfUKPak 5ZbMyzRxJ/ftZ5Rn1egfvPwViqmrmcY3uh0P7jWxvCtTHnIjb/KDptVjDQsqG+2jnTD4 R0nA== Received: by 10.204.41.206 with SMTP id p14mr8278555bke.54.1343917751964; Thu, 02 Aug 2012 07:29:11 -0700 (PDT) Received: from localhost.localdomain (95-89-78-76-dynip.superkabel.de. [95.89.78.76]) by mx.google.com with ESMTPS id hg13sm3544831bkc.7.2012.08.02.07.29.10 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 02 Aug 2012 07:29:11 -0700 (PDT) From: Sasha Levin To: penberg@kernel.org, mingo@elte.hu, gorcunov@gmail.com Cc: kvm@vger.kernel.org, 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> X-Mailer: git-send-email 1.7.8.6 In-Reply-To: <1343917764-28715-1-git-send-email-levinsasha928@gmail.com> References: <1343917764-28715-1-git-send-email-levinsasha928@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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);