From patchwork Mon Apr 4 08:47:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 8738751 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 8BBE0C0554 for ; Mon, 4 Apr 2016 08:49:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B1EBE20251 for ; Mon, 4 Apr 2016 08:49:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BE7B220254 for ; Mon, 4 Apr 2016 08:49:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932148AbcDDItR (ORCPT ); Mon, 4 Apr 2016 04:49:17 -0400 Received: from mail-lf0-f49.google.com ([209.85.215.49]:33051 "EHLO mail-lf0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754611AbcDDItP (ORCPT ); Mon, 4 Apr 2016 04:49:15 -0400 Received: by mail-lf0-f49.google.com with SMTP id p188so131783766lfd.0 for ; Mon, 04 Apr 2016 01:49:15 -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=p2jJ6kWYflhNN8S/AHZUne87Jd/JVxA52TfowJhjxeY=; b=VR2YjhyNiG+HCOHFdWEWEGnurH0jMd+nkXh3LSzkNxmV9ziLkz2zo4BazqKtkKPgPS Cd2oAtu6AILRf+ert1IOOXXI8xysGoBJgFjJVPIg/Hyr2obb0VKaBiG4ka1fmUmV+ZH0 FyPc3grcyaIGyXsgmVEaA+Dd5Zx/P6k5a5VsE= 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=p2jJ6kWYflhNN8S/AHZUne87Jd/JVxA52TfowJhjxeY=; b=gmFPRoOjs5DuJTk5rm8hxoY9/06trXhdlRlKadUWehW7XOxWPHhUWoFRtAxueS3it2 803EGcWUlgZsXZwE6147mYjh02L62OQ0vYB8zfUGFCQZhJjddjMi/gyhQlsfRjNFQF3j Z8ic6PO/+Xj+D24Wn7P78S2eoppJR2eNLLNYqMoHozGipbLzJvBxXYWzzZ6gEP8QF1N3 VoxMJLHerv/5eNTWtjAgDvvhZQ21f8WHCSKGI6mJECt7sgVR6+9eCQlpfnJ+kwoBTlyG 1U28Tei2MvbLBNiSZP1Y6LE/HBSzn4fx0MHhWp2TzkyJeePseKyiT09GoalYYa/YOPIZ B/Wg== X-Gm-Message-State: AD7BkJICt2raOhZm2xfmRyvkGv2rxWizDEj9PxrJga3C2LRkLaizUTAtG7E+CCvAmRF1t8rZ X-Received: by 10.194.60.235 with SMTP id k11mr21350472wjr.148.1459759754263; Mon, 04 Apr 2016 01:49:14 -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.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Apr 2016 01:49:12 -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 7/7] KVM: arm: enable KVM_SIGNAL_MSI and MSI routing Date: Mon, 4 Apr 2016 10:47:37 +0200 Message-Id: <1459759657-7402-8-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 If the ITS modality is not available, let's simply support MSI injection by transforming the MSI.data into an SPI ID. This becomes possible to use KVM_SIGNAL_MSI ioctl and MSI routing for arm too. Signed-off-by: Eric Auger --- v2 -> v3: - reword the commit message - add sanity check about devid provision v1 -> v2: - introduce vgic_v2m_inject_msi in vgic-v2-emul.c following Andre's advice Conflicts: arch/arm/kvm/Kconfig Conflicts: arch/arm/kvm/Kconfig --- arch/arm/kvm/Kconfig | 1 + virt/kvm/arm/vgic/vgic-v2.c | 15 +++++++++++++++ virt/kvm/arm/vgic/vgic.h | 1 + virt/kvm/arm/vgic/vgic_irqfd.c | 2 +- 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig index 92c3aec..67019e5 100644 --- a/arch/arm/kvm/Kconfig +++ b/arch/arm/kvm/Kconfig @@ -50,6 +50,7 @@ config KVM_NEW_VGIC bool "New VGIC implementation" depends on KVM default y + select HAVE_KVM_MSI select HAVE_KVM_IRQCHIP select HAVE_KVM_IRQ_ROUTING ---help--- diff --git a/virt/kvm/arm/vgic/vgic-v2.c b/virt/kvm/arm/vgic/vgic-v2.c index 5f7c289..7400af0 100644 --- a/virt/kvm/arm/vgic/vgic-v2.c +++ b/virt/kvm/arm/vgic/vgic-v2.c @@ -248,6 +248,21 @@ void vgic_v2_enable(struct kvm_vcpu *vcpu) vcpu->arch.vgic_cpu.vgic_v2.vgic_hcr = GICH_HCR_EN; } +/** + * vgic_v2m_inject_msi: emulates GICv2M MSI injection by injecting + * the SPI ID matching the msi data + * + * @kvm: pointer to the kvm struct + * @msi: the msi struct handle + */ +int vgic_v2m_inject_msi(struct kvm *kvm, struct kvm_msi *msi) +{ + if (msi->flags & KVM_MSI_VALID_DEVID) + return -EINVAL; + + return kvm_vgic_inject_irq(kvm, 0, msi->data, 1); +} + int vgic_v2_map_resources(struct kvm *kvm) { struct vgic_dist *dist = &kvm->arch.vgic; diff --git a/virt/kvm/arm/vgic/vgic.h b/virt/kvm/arm/vgic/vgic.h index 223c778..354a865 100644 --- a/virt/kvm/arm/vgic/vgic.h +++ b/virt/kvm/arm/vgic/vgic.h @@ -44,6 +44,7 @@ int vgic_v2_probe(struct device_node *vgic_node); int vgic_v2_map_resources(struct kvm *kvm); int vgic_register_dist_regions(struct kvm *kvm, gpa_t dist_base_address, enum vgic_type); +int vgic_v2m_inject_msi(struct kvm *kvm, struct kvm_msi *msi); #ifdef CONFIG_KVM_ARM_VGIC_V3 void vgic_v3_irq_change_affinity(struct kvm *kvm, u32 intid, u64 mpidr); diff --git a/virt/kvm/arm/vgic/vgic_irqfd.c b/virt/kvm/arm/vgic/vgic_irqfd.c index a3a7f02..588cdd6 100644 --- a/virt/kvm/arm/vgic/vgic_irqfd.c +++ b/virt/kvm/arm/vgic/vgic_irqfd.c @@ -100,7 +100,7 @@ int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e, msi.devid = e->devid; if (!vgic_has_its(kvm)) - return -ENODEV; + return vgic_v2m_inject_msi(kvm, &msi); return vits_inject_msi(kvm, &msi); }