From patchwork Mon Aug 3 15:31:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 6930601 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5F7B7C05AC for ; Mon, 3 Aug 2015 15:32:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7E081202E9 for ; Mon, 3 Aug 2015 15:32:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 93EB6201CD for ; Mon, 3 Aug 2015 15:32:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754214AbbHCPcd (ORCPT ); Mon, 3 Aug 2015 11:32:33 -0400 Received: from mail-wi0-f176.google.com ([209.85.212.176]:35419 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754119AbbHCPc2 (ORCPT ); Mon, 3 Aug 2015 11:32:28 -0400 Received: by wibxm9 with SMTP id xm9so126979029wib.0 for ; Mon, 03 Aug 2015 08:32:27 -0700 (PDT) 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=F+tOjuhXJMHfCg9HE4y9vHLokf4vW21Hpc7mNZyI7mI=; b=Zt32gixjsDG27IfgP8mJ/MMR8DlvFAiGs2dyJBvRf0r3+Jq1wRDOiaLpF8mZgU4Zya +bkSEYuFDBh6bLgUPCL0ByNpoEwSG6bh0fR4PpiRiwoT4s8gG5IvckjNXifPg+zD3A6Q uJH+dxFJ4uLDlnfIqNyl3F16uv+LGhTv5HvzGXXB3WyA88E0oUEF7xY26fN9FIdL4gzd Qfcr9sxpYFrnDiB6Lsh3nMTKM1hqLhAIub/w4XjQSdcBIHS9vaaViKitkZWexNttMRPE EOri8teIk/TYrivOmycGlCzGDSpj5cVoJ8TySS280g1MD2YwB8BPcxLlRXgztNgxRF9c qv1g== X-Gm-Message-State: ALoCoQnFF8FyCzoebdjFFXRNFthHopY6rp8YITzZwB5jFlVzMTBb74qdjCgfn8g4gguBrRYOL3w2 X-Received: by 10.180.83.101 with SMTP id p5mr34004657wiy.52.1438615947463; Mon, 03 Aug 2015 08:32:27 -0700 (PDT) Received: from gnx2579.home (LCaen-156-56-7-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by smtp.gmail.com with ESMTPSA id ny7sm14134420wic.11.2015.08.03.08.32.25 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Aug 2015 08:32:26 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, christoffer.dall@linaro.org, marc.zyngier@arm.com Cc: linux-kernel@vger.kernel.org, patches@linaro.org, pbonzini@redhat.com, andre.przywara@arm.com, p.fedin@samsung.com Subject: [PATCH v3 5/7] KVM: arm/arm64: build a default routing table Date: Mon, 3 Aug 2015 17:31:27 +0200 Message-Id: <1438615889-10892-6-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1438615889-10892-1-git-send-email-eric.auger@linaro.org> References: <1438615889-10892-1-git-send-email-eric.auger@linaro.org> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 Implement a default routing table made of flat irqchip routing entries (gsi = irqchip.pin) covering the VGIC SPI indexes. This routing table is overwritten by the first user-space call to KVM_SET_GSI_ROUTING ioctl. Signed-off-by: Eric Auger --- PATCH: creation --- virt/kvm/arm/vgic.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index 8114235..1b092e3 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -1785,6 +1785,8 @@ int vgic_init(struct kvm *kvm) ret |= vgic_init_bitmap(&dist->irq_cfg, nr_cpus, nr_irqs); ret |= vgic_init_bytemap(&dist->irq_priority, nr_cpus, nr_irqs); + ret |= kvm_setup_default_irq_routing(kvm); + if (ret) goto out; @@ -2266,6 +2268,25 @@ out: return r; } +int kvm_setup_default_irq_routing(struct kvm *kvm) +{ + struct kvm_irq_routing_entry *entries; + u32 nr = kvm->arch.vgic.nr_irqs - VGIC_NR_PRIVATE_IRQS; + int i, ret; + + entries = kcalloc(nr, sizeof(struct kvm_kernel_irq_routing_entry), + GFP_KERNEL); + for (i = 0; i < nr; i++) { + entries[i].gsi = i; + entries[i].type = KVM_IRQ_ROUTING_IRQCHIP; + entries[i].u.irqchip.irqchip = 0; + entries[i].u.irqchip.pin = i; + } + ret = kvm_set_irq_routing(kvm, entries, nr, 0); + kfree(entries); + return ret; +} + /** * kvm_set_msi: inject the MSI corresponding to the * MSI routing entry