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: Auger Eric X-Patchwork-Id: 64977 Delivered-To: patches@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1064326lbc; Mon, 4 Apr 2016 01:49:12 -0700 (PDT) X-Received: by 10.25.148.208 with SMTP id w199mr4917311lfd.124.1459759752287; Mon, 04 Apr 2016 01:49:12 -0700 (PDT) Return-Path: Received: from mail-lb0-x235.google.com (mail-lb0-x235.google.com. [2a00:1450:4010:c04::235]) by mx.google.com with ESMTPS id x199si15351529lfd.1.2016.04.04.01.49.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Apr 2016 01:49:12 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 2a00:1450:4010:c04::235 as permitted sender) client-ip=2a00:1450:4010:c04::235; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of eric.auger@linaro.org designates 2a00:1450:4010:c04::235 as permitted sender) smtp.mailfrom=eric.auger@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-lb0-x235.google.com with SMTP id bc4so149729925lbc.2 for ; Mon, 04 Apr 2016 01:49:12 -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=XMrGTS2puK29b2nDLoDUwLesrt4vKyQUljRuE1xVS2cCsxvRkqSTW0sRTa7Jxxg0oO 6hJ3Vrfk5CxvK4XDNRDSAwPdxXOfRMMeEEQny8d8FS66X5RSPJl33ylHOyV0KMHiVKzt vSUdIqvVR162k8B9Kw5RsHVTVsZZcskvJpHNFl2uyWsXvvPFwM5DbZPT7M94A4gaJouD JQdWVtk+abIsi84TmsklEmNGPH06xr6X4cZuXW/j9uD4iTk7UD9XxXYFyKOB6vrlj70W gxO4y32lXq2tmJn8v/jUqbFPiae9IYtWmUsiZWYioHeSjvnFVq4h3si96jhpeReojHJD U9pg== X-Gm-Message-State: AD7BkJKG/EYSZLL5zbWTXN4R4t96mLpWn9sJpFIxK92oDv0yt2DnIRa2Bt/3asdoeoowtlEPafs= X-Received: by 10.28.171.8 with SMTP id u8mr10735326wme.97.1459759749482; Mon, 04 Apr 2016 01:49:09 -0700 (PDT) Return-Path: 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> 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(+) -- 1.9.1 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; +}