From patchwork Mon Jul 6 13:24:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 50761 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 359CC229FC for ; Mon, 6 Jul 2015 13:25:39 +0000 (UTC) Received: by widjy10 with SMTP id jy10sf51844872wid.3 for ; Mon, 06 Jul 2015 06:25:38 -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=fvAPd9oqMcwGqRfhwxJZX4lwXHq2pVWYZwaCZs37DL8=; b=m7wUT/ZBsRu7xm2dzPyYesWmnladNmRBijOZnNylAAVy/W8jOvbsWCVXEJt5vlhjdT mDHqRshwybD5hkt4jQu6ZjEOzwvSoBfsuoWdjsHW0lUPpJTBQcc/bEYqhlUn4vz+GFSi ObNXWzcgYF2zASmn6nYLOeaO4roPVBTxf0lidP697YXtJKfuRANTtEVv4Pdtqci7k0o4 FhBL9ikxIk8oSuU7VriTxmk5RAPoFCxn6Lsiowuck2P6fdnBKz7KwZSbM4gjIDFJdt+J QHNVP26i0tN6yRxb9PDvkc2iGs7Nesi75AVuD6VLkv6gojF49PTo+t83JjOTGhjcbCSG 8a5g== X-Gm-Message-State: ALoCoQkjBgipb9gpL4Xe6511QoFQF2Lcr8jXDXbqKdwrX2E6ppMC27GobBIVdks3O3F8CR4Tr6rd X-Received: by 10.180.198.9 with SMTP id iy9mr884249wic.7.1436189138552; Mon, 06 Jul 2015 06:25:38 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.204.9 with SMTP id ku9ls641320lac.37.gmail; Mon, 06 Jul 2015 06:25:38 -0700 (PDT) X-Received: by 10.112.142.232 with SMTP id rz8mr47609642lbb.74.1436189138395; Mon, 06 Jul 2015 06:25:38 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id f9si15262556laa.60.2015.07.06.06.25.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jul 2015 06:25:38 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by laar3 with SMTP id r3so155084206laa.0 for ; Mon, 06 Jul 2015 06:25:38 -0700 (PDT) X-Received: by 10.112.42.50 with SMTP id k18mr45027919lbl.76.1436189138241; Mon, 06 Jul 2015 06:25:38 -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 hn6csp1725386lbb; Mon, 6 Jul 2015 06:25:37 -0700 (PDT) X-Received: by 10.180.95.67 with SMTP id di3mr52727840wib.78.1436189127177; Mon, 06 Jul 2015 06:25:27 -0700 (PDT) Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com. [209.85.212.179]) by mx.google.com with ESMTPS id on6si52196142wic.8.2015.07.06.06.25.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jul 2015 06:25:27 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.179 as permitted sender) client-ip=209.85.212.179; Received: by wibdq8 with SMTP id dq8so153321208wib.1 for ; Mon, 06 Jul 2015 06:25:27 -0700 (PDT) X-Received: by 10.195.11.3 with SMTP id ee3mr96163780wjd.89.1436189126919; Mon, 06 Jul 2015 06:25:26 -0700 (PDT) Received: from gnx2579.home (LCaen-156-56-7-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by mx.google.com with ESMTPSA id q4sm28148131wju.14.2015.07.06.06.25.24 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jul 2015 06:25:25 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, christoffer.dall@linaro.org, marc.zyngier@arm.com, avi.kivity@gmail.com, mtosatti@redhat.com, feng.wu@intel.com, joro@8bytes.org, b.reynal@virtualopensystems.com Cc: linux-kernel@vger.kernel.org, patches@linaro.org, alex.williamson@redhat.com, pbonzini@redhat.com Subject: [RFC v2 9/9] KVM: arm/arm64: implement IRQ bypass consumer functions Date: Mon, 6 Jul 2015 15:24:43 +0200 Message-Id: <1436189083-32527-10-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1436189083-32527-1-git-send-email-eric.auger@linaro.org> References: <1436189083-32527-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.215.53 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: , Implement IRQ bypass callbacks for arm/arm64 IRQ forwarding: - kvm_arch_irq_bypass_add_producer: perform VGIC/irqchip settings for forwarding - kvm_arch_irq_bypass_del_producer: same for inverse operation - kvm_arch_irq_bypass_stop: halt guest execution - kvm_arch_irq_bypass_resume: resume guest execution - void kvm_arch_irq_bypass_update and set CONFIG_HAVE_KVM_IRQ_BYPASS for arm/arm64. Signed-off-by: Eric Auger --- v1 -> v2: - struct kvm_kernel_irqfd is retrieved with container_of - function names changed --- arch/arm/kvm/Kconfig | 1 + arch/arm/kvm/arm.c | 40 ++++++++++++++++++++++++++++++++++++++++ arch/arm64/kvm/Kconfig | 1 + 3 files changed, 42 insertions(+) diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig index 7d38d25..19114a1 100644 --- a/arch/arm/kvm/Kconfig +++ b/arch/arm/kvm/Kconfig @@ -32,6 +32,7 @@ config KVM select HAVE_KVM_EVENTFD select HAVE_KVM_IRQFD select IRQ_BYPASS_MANAGER + select HAVE_KVM_IRQ_BYPASS depends on ARM_VIRT_EXT && ARM_LPAE && ARM_ARCH_TIMER ---help--- Support hosting virtualized guest machines. diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 46d4ef6..db8f040 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #define CREATE_TRACE_POINTS @@ -1149,6 +1151,44 @@ struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr) return NULL; } +void kvm_arch_irq_bypass_add_producer(struct irq_bypass_consumer *cons, + struct irq_bypass_producer *prod) +{ + struct kvm_kernel_irqfd *irqfd = + container_of(cons, struct kvm_kernel_irqfd, consumer); + + kvm_vgic_set_forward(irqfd->kvm, prod->irq, irqfd->gsi); +} +void kvm_arch_irq_bypass_del_producer(struct irq_bypass_consumer *cons, + struct irq_bypass_producer *prod) +{ + struct kvm_kernel_irqfd *irqfd = + container_of(cons, struct kvm_kernel_irqfd, consumer); + + kvm_vgic_unset_forward(irqfd->kvm, prod->irq, irqfd->gsi, + &prod->active); +} + +void kvm_arch_irq_bypass_stop(struct irq_bypass_consumer *cons) +{ + struct kvm_kernel_irqfd *irqfd = + container_of(cons, struct kvm_kernel_irqfd, consumer); + + kvm_arm_halt_guest(irqfd->kvm); +} + +void kvm_arch_irq_bypass_resume(struct irq_bypass_consumer *cons) +{ + struct kvm_kernel_irqfd *irqfd = + container_of(cons, struct kvm_kernel_irqfd, consumer); + + kvm_arm_resume_guest(irqfd->kvm); +} + +void kvm_arch_irq_bypass_update(struct irq_bypass_consumer *cons) +{ +} + /** * Initialize Hyp-mode and memory mappings on all CPUs. */ diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig index dfaca85..822551c 100644 --- a/arch/arm64/kvm/Kconfig +++ b/arch/arm64/kvm/Kconfig @@ -32,6 +32,7 @@ config KVM select HAVE_KVM_EVENTFD select HAVE_KVM_IRQFD select IRQ_BYPASS_MANAGER + select HAVE_KVM_IRQ_BYPASS ---help--- Support hosting virtualized guest machines.