From patchwork Mon Apr 4 08:47:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 8738761 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 59002C0553 for ; Mon, 4 Apr 2016 08:49:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8906D2022A for ; Mon, 4 Apr 2016 08:49:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A9C7820259 for ; Mon, 4 Apr 2016 08:49:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754543AbcDDItO (ORCPT ); Mon, 4 Apr 2016 04:49:14 -0400 Received: from mail-lf0-f48.google.com ([209.85.215.48]:34998 "EHLO mail-lf0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753779AbcDDItL (ORCPT ); Mon, 4 Apr 2016 04:49:11 -0400 Received: by mail-lf0-f48.google.com with SMTP id c126so40035710lfb.2 for ; Mon, 04 Apr 2016 01:49:10 -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=F97+icWAPDaWOLsebtyem9L0+x0taCyQP+xY7CDLnjE=; b=AnF7mE1ClW34c+NRK/qHBRsvR/Rht/3fZf3OicKdLA2YJWBzMJL8LxwIc9ZxP3nXW0 A/j/iwJQ/rjQe86O2g+uDhvOk+3v2bAD2sGgKzOZv1439VxsMtExs8jlrAdmaleZEjzz 8pWV6BJ5ja9c68nDSYcbBPf44wYQUpHC4PxI4= 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=F97+icWAPDaWOLsebtyem9L0+x0taCyQP+xY7CDLnjE=; b=d9aovVqxvpqQZ0S0pttCCdIl+L5b5eXbCBrhZBwupOAcHWhyzk2hQkAtm8JBmVkzOs vYTDg1ZGXLmFh/aaFtzbEnLnPCKtfSCEyqSzCX3h9s9UlH9oLN6Rh31KRQumf02BR4rO ZHBFCu23tkLIUnh1L/A7nyg2QTy4WMk7o9kHX/dzeLQM5g6fhojKpdcV+e5gUcZ2oQYp FTTj9HnlkcFPx3MY8EqMoVT9ETLukASWRlovkJWJ/Z0HvBc4zDkDypM6HW+XOuUg1n8R UMnRbtG+nWDpf/7HG8bqwkrYQBbzh5e76eOOEXesPHcc2ywp+5FrlBaD++URCvFjrR71 hxoA== X-Gm-Message-State: AD7BkJJXwfH5LfbddkK0zgdhJA+5r2hckBvjsc+jdNm3pen48HJvsPQD62wsThQGB409XHm9 X-Received: by 10.28.171.8 with SMTP id u8mr10735326wme.97.1459759749482; Mon, 04 Apr 2016 01:49:09 -0700 (PDT) Received: from gnx2579.home (LMontsouris-657-1-37-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by smtp.gmail.com with ESMTPSA id kj9sm27921384wjb.14.2016.04.04.01.49.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Apr 2016 01:49:07 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, christoffer.dall@linaro.org, marc.zyngier@arm.com, andre.przywara@arm.com, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Cc: patches@linaro.org, pbonzini@redhat.com, p.fedin@samsung.com, Manish.Jaggi@caviumnetworks.com Subject: [PATCH v4 5/7] KVM: arm/arm64: build a default routing table Date: Mon, 4 Apr 2016 10:47:35 +0200 Message-Id: <1459759657-7402-6-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1459759657-7402-1-git-send-email-eric.auger@linaro.org> References: <1459759657-7402-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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 --- --- virt/kvm/arm/vgic/vgic_init.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/virt/kvm/arm/vgic/vgic_init.c b/virt/kvm/arm/vgic/vgic_init.c index e4459e3..041443b 100644 --- a/virt/kvm/arm/vgic/vgic_init.c +++ b/virt/kvm/arm/vgic/vgic_init.c @@ -261,6 +261,10 @@ int vgic_init(struct kvm *kvm) kvm_for_each_vcpu(i, vcpu, kvm) kvm_vgic_vcpu_init(vcpu); + ret = kvm_setup_default_irq_routing(kvm); + if (ret) + goto out; + dist->initialized = true; out: return ret; @@ -454,3 +458,23 @@ out_free_irq: kvm_get_running_vcpus()); return ret; } + +int kvm_setup_default_irq_routing(struct kvm *kvm) +{ + struct kvm_irq_routing_entry *entries; + struct vgic_dist *dist = &kvm->arch.vgic; + u32 nr = dist->nr_spis; + 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; +}