From patchwork Thu Aug 4 11:40:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9263515 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5406860754 for ; Thu, 4 Aug 2016 11:44:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41A5C2823D for ; Thu, 4 Aug 2016 11:44:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3338628391; Thu, 4 Aug 2016 11:44:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 8C3932823D for ; Thu, 4 Aug 2016 11:44:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bVH3T-00044u-2a; Thu, 04 Aug 2016 11:43:15 +0000 Received: from mail-lf0-x22b.google.com ([2a00:1450:4010:c07::22b]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bVH1W-00038A-4D for linux-arm-kernel@lists.infradead.org; Thu, 04 Aug 2016 11:41:16 +0000 Received: by mail-lf0-x22b.google.com with SMTP id l69so180219238lfg.1 for ; Thu, 04 Aug 2016 04:40:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KVx3YrPzD0HKop0/VGWrtPJlNH3Lm5Kt5BTGrJ8fNiA=; b=NzoHQtTsG4Tzko4//wVG3E/G6n9QuxKS+jfpBjyne7E4atgoAQY7CmfUUxarMz8yJH wgfNMo7VGH6ka44RF1q/W9tbtJIgm03zFTnGioHje/8VhbsNel9oU07N3uIWujhUfz4d OLDaj9j/gCAAf620WRInQWwnieEpkdWWGawD0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KVx3YrPzD0HKop0/VGWrtPJlNH3Lm5Kt5BTGrJ8fNiA=; b=IL4U+LwGEqEYVOV9wLaKEMgd+VoyH4wCH27JrGcoMr6uR/DZUnbAdZ7tidzy2RuOfs xIFUTc48/Uj7q1yIsAIc0l2PDO+cSJeXSffuFHg0rKX9zGpRyJh132ePPt7Ks66TNd+g Fwb+OC8EqsWGuSdiIAbctkZJdZiuiLSsIf4hsENdcBNM2gL6BNiekgWAgMsQ6QLelWBB O54QW/zMSMy7yALI9oqcHNYcMw8wSUbBJ5bcdEKVIRra+fOi+Jh4qQPw/n+P+g4QBjzb kQKZE1xJGZlIoE7jDzBpct9xMoco/L0bsTXMhIUL3MjrMlSx/QOKZ7XipCWyDp8vBGue Da1w== X-Gm-Message-State: AEkooutE0j2exPgtrn/SekvIGyayq8iTdVM1H/ZxxOtP0H5kBvlVVs5BcZ16JPM6eQZGk+rU X-Received: by 10.25.38.207 with SMTP id m198mr24470061lfm.201.1470310854249; Thu, 04 Aug 2016 04:40:54 -0700 (PDT) Received: from localhost.localdomain (109.59.220.90.mobile.3.dk. [109.59.220.90]) by smtp.gmail.com with ESMTPSA id h9sm2360706lfe.8.2016.08.04.04.40.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Aug 2016 04:40:53 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PULL 6/8] KVM: arm/arm64: Enable MSI routing Date: Thu, 4 Aug 2016 13:40:34 +0200 Message-Id: <1470310836-10371-7-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1470310836-10371-1-git-send-email-christoffer.dall@linaro.org> References: <1470310836-10371-1-git-send-email-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160804_044114_421258_789CEF8E X-CRM114-Status: GOOD ( 14.54 ) 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: Marc Zyngier , Eric Auger , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.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-Virus-Scanned: ClamAV using ClamSMTP From: Eric Auger Up to now, only irqchip routing entries could be set. This patch adds the capability to insert MSI routing entries. For ARM64, let's also increase KVM_MAX_IRQ_ROUTES to 4096: this include SPI irqchip routes plus MSI routes. In the future this might be extended. Signed-off-by: Eric Auger Reviewed-by: Andre Przywara Signed-off-by: Marc Zyngier --- Documentation/virtual/kvm/api.txt | 3 +++ include/linux/kvm_host.h | 2 ++ virt/kvm/arm/vgic/vgic-irqfd.c | 8 ++++++++ virt/kvm/irqchip.c | 24 +++++++++++++++--------- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt index 7e5f9af..7a04216 100644 --- a/Documentation/virtual/kvm/api.txt +++ b/Documentation/virtual/kvm/api.txt @@ -2381,6 +2381,9 @@ On arm/arm64, gsi routing being supported, the following can happen: - in case no routing entry is associated to this gsi, injection fails - in case the gsi is associated to an irqchip routing entry, irqchip.pin + 32 corresponds to the injected SPI ID. +- in case the gsi is associated to an MSI routing entry, the MSI + message and device ID are translated into an LPI (support restricted + to GICv3 ITS in-kernel emulation). 4.76 KVM_PPC_ALLOCATE_HTAB diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index a7eb5c4..a318c3b 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -1048,6 +1048,8 @@ static inline int mmu_notifier_retry(struct kvm *kvm, unsigned long mmu_seq) #ifdef CONFIG_S390 #define KVM_MAX_IRQ_ROUTES 4096 //FIXME: we can have more than that... +#elif defined(CONFIG_ARM64) +#define KVM_MAX_IRQ_ROUTES 4096 #else #define KVM_MAX_IRQ_ROUTES 1024 #endif diff --git a/virt/kvm/arm/vgic/vgic-irqfd.c b/virt/kvm/arm/vgic/vgic-irqfd.c index 6e84d53..683a589 100644 --- a/virt/kvm/arm/vgic/vgic-irqfd.c +++ b/virt/kvm/arm/vgic/vgic-irqfd.c @@ -59,6 +59,14 @@ int kvm_set_routing_entry(struct kvm_kernel_irq_routing_entry *e, (e->irqchip.irqchip >= KVM_NR_IRQCHIPS)) goto out; break; + case KVM_IRQ_ROUTING_MSI: + e->set = kvm_set_msi; + e->msi.address_lo = ue->u.msi.address_lo; + e->msi.address_hi = ue->u.msi.address_hi; + e->msi.data = ue->u.msi.data; + e->msi.flags = ue->flags; + e->msi.devid = ue->u.msi.devid; + break; default: goto out; } diff --git a/virt/kvm/irqchip.c b/virt/kvm/irqchip.c index 0c00054..c620219 100644 --- a/virt/kvm/irqchip.c +++ b/virt/kvm/irqchip.c @@ -178,6 +178,7 @@ int kvm_set_irq_routing(struct kvm *kvm, unsigned flags) { struct kvm_irq_routing_table *new, *old; + struct kvm_kernel_irq_routing_entry *e; u32 i, j, nr_rt_entries = 0; int r; @@ -201,23 +202,25 @@ int kvm_set_irq_routing(struct kvm *kvm, new->chip[i][j] = -1; for (i = 0; i < nr; ++i) { - struct kvm_kernel_irq_routing_entry *e; - r = -ENOMEM; e = kzalloc(sizeof(*e), GFP_KERNEL); if (!e) goto out; r = -EINVAL; - if (ue->flags) { - kfree(e); - goto out; + switch (ue->type) { + case KVM_IRQ_ROUTING_MSI: + if (ue->flags & ~KVM_MSI_VALID_DEVID) + goto free_entry; + break; + default: + if (ue->flags) + goto free_entry; + break; } r = setup_routing_entry(new, e, ue); - if (r) { - kfree(e); - goto out; - } + if (r) + goto free_entry; ++ue; } @@ -234,7 +237,10 @@ int kvm_set_irq_routing(struct kvm *kvm, new = old; r = 0; + goto out; +free_entry: + kfree(e); out: free_irq_routing_table(new);