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: Eric Auger X-Patchwork-Id: 6724031 Return-Path: X-Original-To: patchwork-linux-arm@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 AAF93C05AC for ; Mon, 6 Jul 2015 13:28:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CD16A20254 for ; Mon, 6 Jul 2015 13:28:22 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CA2F620531 for ; Mon, 6 Jul 2015 13:28:21 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZC6Py-0001Le-ET; Mon, 06 Jul 2015 13:26:42 +0000 Received: from mail-wi0-f180.google.com ([209.85.212.180]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZC6P4-0000Iz-Dz for linux-arm-kernel@lists.infradead.org; Mon, 06 Jul 2015 13:25:47 +0000 Received: by wifm2 with SMTP id m2so29745672wif.1 for ; Mon, 06 Jul 2015 06:25:27 -0700 (PDT) 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=fvAPd9oqMcwGqRfhwxJZX4lwXHq2pVWYZwaCZs37DL8=; b=mTnigDhNi8cCyfn3b5+0zuyi3RrgaAemgSQ+2fA8+L5lmruRCsk1hn4JeZfkbv+j3W yl0bjPjZvQHFDRIlma7x1HjTvnszMdG4zNRQwLcmg4qD+G0Gf2ez9X//MOrkfzRB1yMc hzWrbcnrvgVSZi78QfWU8BL+6ID8b0qUlPrvS06HpU84rGLKSIQZRVQNJA1ewpBRKP6P wQ2A8GIxrPiI106hWumpj7/B99IxSr+VSNQvRmg90Zk/vzN/aYj8MdbMlD3OK2qlTuw7 mkujPxRbepzxxx2atyeivY/GXwlOcwcpIMHCqnl9fRwviUraSR6UtPeOzRMRnMwqmAij R+jw== X-Gm-Message-State: ALoCoQnBDYVhNUwstkVHBv7ZOsgnIXBFH/1GlgTCyhgCX01ywLnh1Bq6jpLpp3YsQf+tHVK7eohA 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 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150706_062546_639238_EC6E0C94 X-CRM114-Status: GOOD ( 12.73 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, alex.williamson@redhat.com, linux-kernel@vger.kernel.org, patches@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 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.