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: 6930811 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 D88D59F38B for ; Mon, 3 Aug 2015 15:35:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 127E6205E1 for ; Mon, 3 Aug 2015 15:35:27 +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 AFC9D20625 for ; Mon, 3 Aug 2015 15:35:24 +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 1ZMHkC-0005iL-7s; Mon, 03 Aug 2015 15:33:40 +0000 Received: from mail-wi0-f179.google.com ([209.85.212.179]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZMHjN-0005BB-BS for linux-arm-kernel@lists.infradead.org; Mon, 03 Aug 2015 15:32:51 +0000 Received: by wicgj17 with SMTP id gj17so110875542wic.1 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=HHPeKgqkbziMAY4Y1E7RNNMXrJDPjbbpX2AJ9BWkh8sf6B3OenM+hmPgOvtfgZ3qt9 QFJi/LIwZ8QRD8IsE0ebBy74Aq3ZZslqmFz2kNgzhP7T+1JzfVh+gSF3Z6JtmgLNay5l SIqUH3lETJP99egChg4O6ETyyH/MpWd60bz9y3MpvKYZO+hoUppmXOdA8ZgjBavtpQuM 0wjYFBdGueKJjm1OcQNIXYHjcPns74ojbLdLn9lPljQL/1kVrx/nO4GgWT/ouaxFqZ2X I0z3gjD0aAcNFnvDRxjLsFdABhkmo5hhiTrx0A3MsVBF7sXmm/yJ+1h0klBy+kikcIfW CWiA== X-Gm-Message-State: ALoCoQmpWzliKCAPXl5HJZHryB1PfaynCwIewaaw4i3efK+KN6bv68hPl9vP4pIXmMQK6RFYzIio 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150803_083249_720232_D0A45AF4 X-CRM114-Status: GOOD ( 12.47 ) X-Spam-Score: -2.6 (--) 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: pbonzini@redhat.com, andre.przywara@arm.com, p.fedin@samsung.com, linux-kernel@vger.kernel.org, patches@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=-4.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 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