From patchwork Fri Jul 24 15:23:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Fedin X-Patchwork-Id: 6861091 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EA1729F1D4 for ; Fri, 24 Jul 2015 15:24:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2C2D4206C5 for ; Fri, 24 Jul 2015 15:24:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 28D052077C for ; Fri, 24 Jul 2015 15:24:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754159AbbGXPYA (ORCPT ); Fri, 24 Jul 2015 11:24:00 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:48189 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753808AbbGXPXn (ORCPT ); Fri, 24 Jul 2015 11:23:43 -0400 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NS0007XL03GA340@mailout1.w1.samsung.com> for kvm@vger.kernel.org; Fri, 24 Jul 2015 16:23:40 +0100 (BST) X-AuditID: cbfec7f5-f794b6d000001495-f8-55b2587c2935 Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id F2.BA.05269.C7852B55; Fri, 24 Jul 2015 16:23:40 +0100 (BST) Received: from fedinw7x64.rnd.samsung.ru ([106.109.131.169]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NS0005TD03B2140@eusync2.samsung.com>; Fri, 24 Jul 2015 16:23:40 +0100 (BST) From: Pavel Fedin To: kvm@vger.kernel.org Cc: Marc Zyngier Subject: [RFC 2/2] Send KVM_EXIT_IRQ from timer if irqchip is not used Date: Fri, 24 Jul 2015 18:23:35 +0300 Message-id: <487f6cfeeb9fe6aa26ebcdd3a15885f305b3e21a.1437750590.git.p.fedin@samsung.com> X-Mailer: git-send-email 2.4.4 In-reply-to: References: In-reply-to: References: X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpgluLIzCtJLcpLzFFi42I5/e/4Fd2aiE2hBsd/KFvMmVpo8ffOPzYH Jo8189YwenzeJBfAFMVlk5Kak1mWWqRvl8CV8fvJR5aCz4IVvV+7WRoYN/B1MXJySAiYSDQd aWKDsMUkLtxbD2YLCSxllPj8GMjmArLbmCTufl3GCJJgE1CXOP31AwuILSIgLvFw1UFWEJsZ KP549xQwW1jATWLRlY3MIDaLgKrE5z9f2EFsXoFoiW8X77JALJOTuHJ9OtACDg5OAXOJrs8B EHvNJJ5NOIhLeAIj/wJGhlWMoqmlyQXFSem5RnrFibnFpXnpesn5uZsYIeHydQfj0mNWhxgF OBiVeHgPTNoYKsSaWFZcmXuIUYKDWUmE18FzU6gQb0piZVVqUX58UWlOavEhRmkOFiVx3pm7 3ocICaQnlqRmp6YWpBbBZJk4OKUaGGsk2OcZmCRdrP1568mjBtul///IrJkcvPWDkbrlda6f 62olgl7UP2t2/fPsvJSosOMF6fMv7gtpCVgufMm/b9vTRN+w8uXeV9M0hK9IrUxn1X3vXf17 7lOR2QJ9stJTvic09m6tf/2kP9Bn67p5IV+6+4LjbdjSexoceIVK5mZHKznPigorVmIpzkg0 1GIuKk4EAAEeBzgTAgAA Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Signed-off-by: Pavel Fedin --- arch/arm/kvm/arm.c | 18 +++++++++++------- include/linux/kvm_host.h | 7 +++++++ virt/kvm/arm/arch_timer.c | 6 ++++++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 7e389fd..67545bd 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -461,13 +461,7 @@ static int kvm_vcpu_first_run_init(struct kvm_vcpu *vcpu) return ret; } - /* - * Enable the arch timers only if we have an in-kernel VGIC - * and it has been properly initialized, since we cannot handle - * interrupts from the virtual timer with a userspace gic. - */ - if (irqchip_in_kernel(kvm) && vgic_initialized(kvm)) - kvm_timer_enable(kvm); + kvm_timer_enable(kvm); return 0; } @@ -547,6 +541,16 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) run->exit_reason = KVM_EXIT_INTR; } + if (vcpu->irq) { + ret = 0; + run->exit_reason = KVM_EXIT_IRQ; + run->irq.irq = vcpu->irq->irq; + run->irq.level = vcpu->irq->level; + + vcpu->irq = NULL; + continue; + } + if (ret <= 0 || need_new_vmid_gen(vcpu->kvm)) { local_irq_enable(); kvm_timer_sync_hwstate(vcpu); diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index ad45054..3907e79 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -267,6 +267,13 @@ struct kvm_vcpu { } spin_loop; #endif bool preempted; + + /* + * IRQ pending to the userspace on this CPU. + * Currently we support only one slot, used only by ARM architecture. + */ + const struct kvm_irq_level *irq; + struct kvm_vcpu_arch arch; }; diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index 98c95f2..e1b0aa9 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -65,6 +65,12 @@ static void kvm_timer_inject_irq(struct kvm_vcpu *vcpu) struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; timer->cntv_ctl |= ARCH_TIMER_CTRL_IT_MASK; + + if (!irqchip_in_kernel(vcpu->kvm)) { + vcpu->irq = timer->irq; + return; + } + ret = kvm_vgic_inject_irq(vcpu->kvm, vcpu->vcpu_id, timer->irq->irq, timer->irq->level);