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: Eric Auger X-Patchwork-Id: 6984161 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 600DCC05AC for ; Mon, 10 Aug 2015 13:26:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8844D205FF for ; Mon, 10 Aug 2015 13:26:34 +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 460BA204A2 for ; Mon, 10 Aug 2015 13:26:33 +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 1ZOn44-0002CV-VF; Mon, 10 Aug 2015 13:24:32 +0000 Received: from mail-wi0-f177.google.com ([209.85.212.177]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZOn26-0000cl-I7 for linux-arm-kernel@lists.infradead.org; Mon, 10 Aug 2015 13:22:34 +0000 Received: by wicne3 with SMTP id ne3so21963566wic.0 for ; Mon, 10 Aug 2015 06:22:08 -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=6/3peAyMxTHe54cMNkxlRHSRP5F54sAv13bVmeCTqr0=; b=Qn7y4p7rIDHqpFfUPlx8fjYIhZ5ogfYVub7ZzjX9/4JoNpcq57bfxt3GbHhdYb0bxM paafGc3mOgJBosHpFJsHja7cdIF8BlVrrRYyCIdA1KUedud8UGnEHNUK9MVM++p8jnxZ BA9OZiyG4oWjzbvlRAWFHA9ywKJRKDiLUCziurUfkkOZUuGtNA4gYX8GSE/cShRsTO3G IsFL3xViYjSmfaXr2uHONv0KZZgkxq9nhS7qr/mrYMGAD5CdHRFos+RBsBvE1D58Rf6j LO6vJNsbi+My1cgJEvbgMYnBqRNVg6NMvNUF45SuFMY8p1nYYVsH6CN4EUKC2bCXhXdN 4o7g== X-Gm-Message-State: ALoCoQmpz/JXJpF2+0FmsUI5GrFDWJYyNkYfE/CZiw3zdnQAvz8RC+E1eCe9iBu6s6fE0h2wkaHf 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 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150810_062231_011099_1FC9EFC4 X-CRM114-Status: GOOD ( 13.55 ) 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, 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.2 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_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.