From patchwork Mon Aug 10 13:21:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 52244 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by patches.linaro.org (Postfix) with ESMTPS id 2EEFA22919 for ; Mon, 10 Aug 2015 13:22:20 +0000 (UTC) Received: by lbsm2 with SMTP id m2sf25705311lbs.1 for ; Mon, 10 Aug 2015 06:22:19 -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=6/3peAyMxTHe54cMNkxlRHSRP5F54sAv13bVmeCTqr0=; b=dn8vGeljGu4O+b7Q7ULyMG1Gblvif37WP6dBET7YAVZNIp+927a/7RZZuWcz/wFavB Tk6Hk8khidRDmBYoWbthGIA7QvxMRSbDdskmsYQS66O4mCFrrry1aOKsfhTL2qDXsAiQ veZUkndUwbbZg2FMnAq18CBpF+3Ql3TqJF0vOCI9YZCvH8amSA00e1UW2m9+lvebB3Sc EzilrhFB9g+PXxWylLeRkyRw58FFArnLmam0Zs6tmxp4+YixZ1IILhfSHqktuzFEc+GN mUZpP6o5SVIC12dNAreZS8HpyAYtI3zuKDGExUL++lsSwWEjwyB7MBMtdo9WnxmXGsI8 6ATw== X-Gm-Message-State: ALoCoQkb4chm8edcGMPGqbQkL5aHVlSm8t+dTyDC1qLa9bJSENoEDq+1r7eZNDiN2DYiryqCwImD X-Received: by 10.112.161.35 with SMTP id xp3mr3389892lbb.2.1439212939153; Mon, 10 Aug 2015 06:22:19 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.74 with SMTP id k10ls744702laf.30.gmail; Mon, 10 Aug 2015 06:22:19 -0700 (PDT) X-Received: by 10.152.181.5 with SMTP id ds5mr19768809lac.60.1439212939007; Mon, 10 Aug 2015 06:22:19 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id y17si7780405lbn.98.2015.08.10.06.22.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Aug 2015 06:22:18 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by lagz9 with SMTP id z9so53404705lag.3 for ; Mon, 10 Aug 2015 06:22:18 -0700 (PDT) X-Received: by 10.112.166.106 with SMTP id zf10mr19837449lbb.36.1439212938855; Mon, 10 Aug 2015 06:22:18 -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.7.198 with SMTP id l6csp1931876lba; Mon, 10 Aug 2015 06:22:18 -0700 (PDT) X-Received: by 10.194.87.69 with SMTP id v5mr42416626wjz.140.1439212929081; Mon, 10 Aug 2015 06:22:09 -0700 (PDT) Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com. [209.85.212.171]) by mx.google.com with ESMTPS id g5si16041171wix.107.2015.08.10.06.22.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Aug 2015 06:22:09 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.171 as permitted sender) client-ip=209.85.212.171; Received: by wibhh20 with SMTP id hh20so150562238wib.0 for ; Mon, 10 Aug 2015 06:22:08 -0700 (PDT) X-Received: by 10.180.105.165 with SMTP id gn5mr23574679wib.20.1439212928682; Mon, 10 Aug 2015 06:22:08 -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 fq15sm29517024wjc.12.2015.08.10.06.22.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Aug 2015 06:22:07 -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, alex.williamson@redhat.com, feng.wu@intel.com Cc: linux-kernel@vger.kernel.org, patches@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 10/10] KVM: arm/arm64: implement IRQ bypass consumer functions Date: Mon, 10 Aug 2015 15:21:04 +0200 Message-Id: <1439212864-12954-11-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1439212864-12954-1-git-send-email-eric.auger@linaro.org> References: <1439212864-12954-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.52 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_start: resume guest execution and set CONFIG_HAVE_KVM_IRQ_BYPASS for arm/arm64. Signed-off-by: Eric Auger --- v2 -> v3: - kvm_arch_irq_bypass_resume renamed into kvm_arch_irq_bypass_start - kvm_vgic_unset_forward does not take the active bool param anymore - kvm_arch_irq_bypass_add_producer now returns an error value - remove kvm_arch_irq_bypass_update v1 -> v2: - struct kvm_kernel_irqfd is retrieved with container_of - function names changed --- arch/arm/kvm/Kconfig | 1 + arch/arm/kvm/arm.c | 35 +++++++++++++++++++++++++++++++++++ arch/arm64/kvm/Kconfig | 1 + 3 files changed, 37 insertions(+) diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig index 3c565b9..655d277 100644 --- a/arch/arm/kvm/Kconfig +++ b/arch/arm/kvm/Kconfig @@ -33,6 +33,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 0529b38..7cfc5dc 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,39 @@ struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr) return NULL; } +int 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); + + return 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); +} + +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_start(struct irq_bypass_consumer *cons) +{ + struct kvm_kernel_irqfd *irqfd = + container_of(cons, struct kvm_kernel_irqfd, consumer); + + kvm_arm_resume_guest(irqfd->kvm); +} + /** * Initialize Hyp-mode and memory mappings on all CPUs. */ diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig index 2509539..6f6e7a5 100644 --- a/arch/arm64/kvm/Kconfig +++ b/arch/arm64/kvm/Kconfig @@ -33,6 +33,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.