From patchwork Mon Jul 20 13:02:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 6827491 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A85AB9F38B for ; Mon, 20 Jul 2015 13:06:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C974320697 for ; Mon, 20 Jul 2015 13:06:38 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D9D7920685 for ; Mon, 20 Jul 2015 13:06:37 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZHAkO-0006YL-2G; Mon, 20 Jul 2015 13:04:44 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZHAic-0005GE-TD for linux-arm-kernel@lists.infradead.org; Mon, 20 Jul 2015 13:02:59 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1DACE606; Mon, 20 Jul 2015 06:02:44 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.203.153]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E51133F21A; Mon, 20 Jul 2015 06:02:26 -0700 (PDT) From: Andre Przywara To: will.deacon@arm.com, marc.zyngier@arm.com Subject: [PATCH 10/14] PCI: inject PCI device ID on MSI injection Date: Mon, 20 Jul 2015 14:02:12 +0100 Message-Id: <1437397336-21385-11-git-send-email-andre.przywara@arm.com> X-Mailer: git-send-email 2.3.5 In-Reply-To: <1437397336-21385-1-git-send-email-andre.przywara@arm.com> References: <1437397336-21385-1-git-send-email-andre.przywara@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150720_060255_029816_36176255 X-CRM114-Status: GOOD ( 12.68 ) X-Spam-Score: -8.1 (--------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, Pavel Fedin , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, eric.auger@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The ITS emulation requires a unique device ID to be passed along the MSI payload when kvmtool wants to trigger an MSI in the guest. According to the proposed changes to the interface add the PCI bus/device/function triple to the structure passed with the ioctl. Check the respective capability before actually adding the device ID to the kvm_msi struct. Signed-off-by: Andre Przywara --- virtio/pci.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/virtio/pci.c b/virtio/pci.c index 625fec0..e92a2df 100644 --- a/virtio/pci.c +++ b/virtio/pci.c @@ -305,14 +305,28 @@ static void virtio_pci__msix_mmio_callback(struct kvm_cpu *vcpu, update_msix_map(vpci, table, (addr - offset) / 16); } -static void virtio_pci__signal_msi(struct kvm *kvm, struct virtio_pci *vpci, int vec) +static void virtio_pci__signal_msi(struct kvm *kvm, struct virtio_pci *vpci, + int vec) { + static int needs_devid = 0; 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, }; + if (needs_devid == 0) { + if (kvm__supports_vm_extension(kvm, KVM_CAP_MSI_DEVID)) + needs_devid = 1; + else + needs_devid = -1; + } + + if (needs_devid > 0) { + msi.flags = KVM_MSI_VALID_DEVID; + msi.devid = vpci->dev_hdr.dev_num << 3; + } + ioctl(kvm->vm_fd, KVM_SIGNAL_MSI, &msi); }