From patchwork Thu Jul 9 08:22:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 50924 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C9B1A213FD for ; Thu, 9 Jul 2015 08:22:57 +0000 (UTC) Received: by lbko2 with SMTP id o2sf8030758lbk.0 for ; Thu, 09 Jul 2015 01:22:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=3DJzT6/3RyFo1hqYJHCZlc8fjBV9ezFw+UDCy1ervRo=; b=JyvloxlOSdiUNXK3qsplswhaI4OgC89xIuzV9hOhhDVcO5pnC0a91FF/8+WtFHxnd/ cMaSb4W0Bt3IvqHli3GAUCHnOEa+Z6uvhnvaCnaXEPMOdJ5QoIdnFxN8tGXn2QWasn3R KGrJdP0zgfOTnuZDhFnyTG3ib3xc4HrxSoBNz+1CnqEF3thVXaUU5MVjIiIEqpN7r5oY ALLTXO5794DeC/qb/npylbPFe0NWvfEaW5h7u7KPsk3ZfMso56jepgdkF0/lJfFm1euG zFFi0BT49YYYsWIeSsfZJfhmYva+HBioTmmXMapJTuowUnRG3YHChki+mq7BeNCrlYNr z9gg== X-Gm-Message-State: ALoCoQlkUcearwNdvj4LiaO8FrCKbePrJ1UFibfrmI66LMW/X3v1IWO+fHVMXNDtrHa2/hWzQEUk X-Received: by 10.181.13.202 with SMTP id fa10mr2121952wid.4.1436430176533; Thu, 09 Jul 2015 01:22:56 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.194 with SMTP id v2ls1157987lag.59.gmail; Thu, 09 Jul 2015 01:22:56 -0700 (PDT) X-Received: by 10.112.157.36 with SMTP id wj4mr13418859lbb.115.1436430176368; Thu, 09 Jul 2015 01:22:56 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id jv10si4193806lbc.13.2015.07.09.01.22.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Jul 2015 01:22:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by lbnk3 with SMTP id k3so70525670lbn.1 for ; Thu, 09 Jul 2015 01:22:56 -0700 (PDT) X-Received: by 10.152.36.161 with SMTP id r1mr13505086laj.88.1436430176271; Thu, 09 Jul 2015 01:22:56 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp492487lbb; Thu, 9 Jul 2015 01:22:55 -0700 (PDT) X-Received: by 10.181.13.230 with SMTP id fb6mr79575495wid.47.1436430175559; Thu, 09 Jul 2015 01:22:55 -0700 (PDT) Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com. [209.85.212.173]) by mx.google.com with ESMTPS id bz8si8424617wjc.178.2015.07.09.01.22.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Jul 2015 01:22:55 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.173 as permitted sender) client-ip=209.85.212.173; Received: by wiclp1 with SMTP id lp1so102332589wic.0 for ; Thu, 09 Jul 2015 01:22:55 -0700 (PDT) X-Received: by 10.180.99.2 with SMTP id em2mr119464099wib.59.1436430175307; Thu, 09 Jul 2015 01:22:55 -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 ib9sm7522108wjb.2.2015.07.09.01.22.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Jul 2015 01:22:53 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, linux-arm-kernel@lists.infradead.org, marc.zyngier@arm.com, christoffer.dall@linaro.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Cc: patches@linaro.org, andre.przywara@arm.com, p.fedin@samsung.com, pbonzini@redhat.com Subject: [PATCH v2 6/7] KVM: arm/arm64: enable MSI routing Date: Thu, 9 Jul 2015 10:22:16 +0200 Message-Id: <1436430137-24205-7-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1436430137-24205-1-git-send-email-eric.auger@linaro.org> References: <1436430137-24205-1-git-send-email-eric.auger@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: eric.auger@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Up to now, only irqchip routing entries could be set. This patch adds the capability to insert MSI routing entries, with or without device id. Although standard MSI entries can be set, their injection still is not supported. For ARM64, let's also increase KVM_MAX_IRQ_ROUTES to 4096: include SPI irqchip flat routes plus MSI routes. In the future this might be extended. The new MSI routing entry type also must be managed similarly to legacy KVM_IRQ_ROUTING_MSI in eventfd irqfd_wakeup and irqfd_update. Signed-off-by: Eric Auger --- v1 -> v2: - adapt to new routing entry types RFC -> PATCH: - move api MSI routing updates into that patch file - use new devid field of user api struct --- Documentation/virtual/kvm/api.txt | 10 ++++++++++ include/linux/kvm_host.h | 2 ++ virt/kvm/arm/vgic.c | 13 +++++++++++++ virt/kvm/eventfd.c | 6 ++++-- 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt index 9276dac..686b121 100644 --- a/Documentation/virtual/kvm/api.txt +++ b/Documentation/virtual/kvm/api.txt @@ -1431,6 +1431,11 @@ Sets the GSI routing table entries, overwriting any previously set entries. On arm/arm64, GSI routing has the following limitation: - GSI routing does not apply to KVM_IRQ_LINE but only to KVM_IRQFD. +On arm/arm64, MSI routing through in-kernel GICv3 ITS must use +KVM_IRQ_ROUTING_EXTENDED_MSI routing type and device ID must be set +in msi struct. Otherwise, KVM_IRQ_ROUTING_MSI must be used without +populating the msi devid field. + struct kvm_irq_routing { __u32 nr; __u32 flags; @@ -2342,6 +2347,11 @@ On arm/arm64, gsi routing being supported, the following can happen: - in case no routing entry is associated to this gsi, injection fails - in case the gsi is associated to an irqchip routing entry, irqchip.pin + 32 corresponds to the injected SPI ID. +- in case the gsi is associated to an MSI routing entry, + * without GICv3 ITS in-kernel emulation, MSI data matches the SPI ID + of the injected SPI + * with GICv3 ITS in-kernel emulation, the MSI message and device ID + are translated into an LPI. 4.76 KVM_PPC_ALLOCATE_HTAB diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index cac0fe4..ea1a810 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -976,6 +976,8 @@ static inline int mmu_notifier_retry(struct kvm *kvm, unsigned long mmu_seq) #ifdef CONFIG_S390 #define KVM_MAX_IRQ_ROUTES 4096 //FIXME: we can have more than that... +#elif defined(CONFIG_ARM64) +#define KVM_MAX_IRQ_ROUTES 4096 #else #define KVM_MAX_IRQ_ROUTES 1024 #endif diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index 63be67e..c5546d8 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -2252,6 +2252,19 @@ int kvm_set_routing_entry(struct kvm_kernel_irq_routing_entry *e, (e->irqchip.irqchip >= KVM_NR_IRQCHIPS)) goto out; break; + case KVM_IRQ_ROUTING_MSI: + e->set = kvm_set_msi; + e->msi.address_lo = ue->u.msi.address_lo; + e->msi.address_hi = ue->u.msi.address_hi; + e->msi.data = ue->u.msi.data; + break; + case KVM_IRQ_ROUTING_EXTENDED_MSI: + e->set = kvm_set_msi; + e->msi.address_lo = ue->u.msi.address_lo; + e->msi.address_hi = ue->u.msi.address_hi; + e->msi.data = ue->u.msi.data; + e->devid = ue->u.msi.devid; + break; default: goto out; } diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index 9ff4193..d76d05d 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c @@ -238,7 +238,8 @@ irqfd_wakeup(wait_queue_t *wait, unsigned mode, int sync, void *key) irq = irqfd->irq_entry; } while (read_seqcount_retry(&irqfd->irq_entry_sc, seq)); /* An event has been signaled, inject an interrupt */ - if (irq.type == KVM_IRQ_ROUTING_MSI) + if (irq.type == KVM_IRQ_ROUTING_MSI || + irq.type == KVM_IRQ_ROUTING_EXTENDED_MSI) kvm_set_msi(&irq, kvm, KVM_USERSPACE_IRQ_SOURCE_ID, 1, false); else @@ -294,7 +295,8 @@ static void irqfd_update(struct kvm *kvm, struct _irqfd *irqfd) e = entries; for (i = 0; i < n_entries; ++i, ++e) { /* Only fast-path MSI. */ - if (e->type == KVM_IRQ_ROUTING_MSI) + if (e->type == KVM_IRQ_ROUTING_MSI || + e->type == KVM_IRQ_ROUTING_EXTENDED_MSI) irqfd->irq_entry = *e; }