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: Auger Eric X-Patchwork-Id: 64978 Delivered-To: patches@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1064338lbc; Mon, 4 Apr 2016 01:49:14 -0700 (PDT) X-Received: by 10.25.149.145 with SMTP id x139mr5917802lfd.141.1459759754652; Mon, 04 Apr 2016 01:49:14 -0700 (PDT) Return-Path: Received: from mail-lf0-x232.google.com (mail-lf0-x232.google.com. [2a00:1450:4010:c07::232]) by mx.google.com with ESMTPS id p194si15316811lfb.106.2016.04.04.01.49.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Apr 2016 01:49:14 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 2a00:1450:4010:c07::232 as permitted sender) client-ip=2a00:1450:4010:c07::232; 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:c07::232 as permitted sender) smtp.mailfrom=eric.auger@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x232.google.com with SMTP id c126so40039179lfb.2 for ; Mon, 04 Apr 2016 01:49:14 -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=eEC9vzEtUSWtVAbTrfvowWaBp/4E8HQBWIc4iyMJtep6w/q8AOIFxNgCP04yxqdabL QlmrAtcY9ND7+vLOup+QVOe7UQzNTjko4WaGLWHW8ev9MFVBaWCY2avXz8Rsy1AXadxn rUC3A4Ows1U9LnM/uspUKCbFrwhYYRM32UdWwlULdXESL3cWnlSVl03F81Sg2R1VphBS Xx6+MBj+XyhN4HmfPCmjniRDOJhqwpR+MtLNfXJmAFAENPtuUJF1K1cTa27pBw3agcFJ CDchU3lophlUaqdahEpdR25k5y8YilnzOjWQU/LmOTqgK+tOboprHAgCa3Q/901AtK4x l2aA== X-Gm-Message-State: AD7BkJIeGx1SHt7FZTsrVqvIc7VhT4cZJLBxzNwSn/cFgHs/TCzr4iTpKzKx3J875B4O5giOF1k= X-Received: by 10.194.60.235 with SMTP id k11mr21350472wjr.148.1459759754263; Mon, 04 Apr 2016 01:49:14 -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.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> 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(-) -- 1.9.1 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); }