From patchwork Thu Apr 6 19:04:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9668105 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0FC02602B3 for ; Thu, 6 Apr 2017 19:04:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5F83285C4 for ; Thu, 6 Apr 2017 19:04:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D860A285D4; Thu, 6 Apr 2017 19:04:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C847E285C4 for ; Thu, 6 Apr 2017 19:04:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Xq3G053a3UMqJXsa/uctd0hm4m64acp2kaNXyoB5/7o=; b=WDyF4s/+tBY50P FI8F4VQqHmi0yd4yJENVX+Z6Mv2GVeBUdqV0d9yZC2Isjm8Q69988kOYr+DU+XE96dw6UVOfyfYN3 1mwdCzZKppLRpofXFozrzE33cXHOXLtXiopu9HimMRyArOvRRBxaMxSZXUoUUg0XGbKKeobanXySX G3rXjMGjjQ82QDcwfqyEVdkiRNbEJCZ4F1wT5LocBt0lA0OO8RYcnkkTD5aRpDilxLXbJHTHwFRkv /vfIt50xESi4wmTiQeq05o0fH0c/liF9GCxTH7PW+mp9nDr2vZo/zpiG2hvpVG1adxNCOI2MRcTpF +wunSytxWvSpaU7LHZCw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cwCi0-00061P-E4; Thu, 06 Apr 2017 19:04:40 +0000 Received: from mail-wr0-x22e.google.com ([2a00:1450:400c:c0c::22e]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cwChv-0005xn-Vc for linux-arm-kernel@lists.infradead.org; Thu, 06 Apr 2017 19:04:38 +0000 Received: by mail-wr0-x22e.google.com with SMTP id t20so76808926wra.1 for ; Thu, 06 Apr 2017 12:04:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=EhkjXLTHV2qq5vL/62b1e0HX31XKKdELxKSLivTxv8M=; b=PcmFhSbRQ5A6LhaKz7UHDkTyCCO6eSsdtqMH0n4foeVl86min6aeB1Oton1kl97VVM TVT0B5x1KbsqOurAljupIGeYYhG9Y97RcO5fhDNxlWfrhDW0yrmGCk9v2hnfk0VOCaXQ t+AHfQSy8aYoJkg7p8BwX3VTrZ+vlZmItJX0w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=EhkjXLTHV2qq5vL/62b1e0HX31XKKdELxKSLivTxv8M=; b=NJQes89/tsHVE3uwQivqc62bnwd5xEr1I16PKuABJv/gBAxz3odO7e58tY92nXbHNv rXTjZRdRqSzEjZvJL7BPViB/KkWE83mo5OZTD0DsBEptpyrFPY1zgBO30m64hIoQvL63 DeaFXdq4NbXgSNQqf4qupH18bXx6Du+j9xvxZ+St4k+ljsFwjqPa+Nn13rXfTjot/XfH yPr+3LTjzGVgLTDgTnjVCVxK+gWMRFvrDp+09rkHp8l1M/0xo/CSN8UqBTpXtHD/4qMY fC545YRdWOk1Xkb3PWQRhbRYUagsXF40l4K5Ow7OQGlI6+FLx+aWoD01xBU2VytNG2aD zzsQ== X-Gm-Message-State: AN3rC/7kCNTz9EepUYcWOC3FB2PV7rdoPuShVPLzxn8KcI1FMILtZtLl JVRI0gg1SPvsX+rJ X-Received: by 10.28.213.198 with SMTP id m189mr6614830wmg.102.1491505452847; Thu, 06 Apr 2017 12:04:12 -0700 (PDT) Received: from localhost (xd93ddc2d.cust.hiper.dk. [217.61.220.45]) by smtp.gmail.com with ESMTPSA id c18sm3131237wre.48.2017.04.06.12.04.11 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 06 Apr 2017 12:04:11 -0700 (PDT) Date: Thu, 6 Apr 2017 21:04:13 +0200 From: Christoffer Dall To: Marc Zyngier Subject: Re: [PATCH v3 4/5] KVM: arm/arm64: Report PMU overflow interrupts to userspace irqchip Message-ID: <20170406190413.GH27123@cbox> References: <20170405092815.22503-1-cdall@linaro.org> <20170405092815.22503-5-cdall@linaro.org> <6c476719-8fb3-27b6-c7f6-84088443dcd4@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <6c476719-8fb3-27b6-c7f6-84088443dcd4@arm.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170406_120436_175845_F62A9FDA X-CRM114-Status: GOOD ( 20.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , kvm@vger.kernel.org, Alexander Graf , kvmarm@lists.cs.columbia.edu, Christoffer Dall , Pekka Enberg , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, Apr 06, 2017 at 06:12:10PM +0100, Marc Zyngier wrote: > On 05/04/17 10:28, Christoffer Dall wrote: > > From: Christoffer Dall > > > > When not using an in-kernel VGIC, but instead emulating an interrupt > > controller in userspace, we should report the PMU overflow status to > > that userspace interrupt controller using the KVM_CAP_ARM_USER_IRQ > > feature. > > > > Signed-off-by: Christoffer Dall > > --- > > arch/arm/kvm/arm.c | 9 ++++++--- > > include/kvm/arm_pmu.h | 7 +++++++ > > virt/kvm/arm/pmu.c | 42 ++++++++++++++++++++++++++++++++++++++---- > > 3 files changed, 51 insertions(+), 7 deletions(-) > > > > diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c > > index efb16e5..f935383 100644 > > --- a/arch/arm/kvm/arm.c > > +++ b/arch/arm/kvm/arm.c > > @@ -635,11 +635,13 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) > > > > /* > > * If we have a singal pending, or need to notify a userspace > > - * irqchip about timer level changes, then we exit (and update > > - * the timer level state in kvm_timer_update_run below). > > + * irqchip about timer or PMU level changes, then we exit (and > > + * update the timer level state in kvm_timer_update_run > > + * below). > > */ > > if (signal_pending(current) || > > - kvm_timer_should_notify_user(vcpu)) { > > + kvm_timer_should_notify_user(vcpu) || > > + kvm_pmu_should_notify_user(vcpu)) { > > ret = -EINTR; > > run->exit_reason = KVM_EXIT_INTR; > > } > > @@ -713,6 +715,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) > > > > /* Tell userspace about in-kernel device output levels */ > > kvm_timer_update_run(vcpu); > > + kvm_pmu_update_run(vcpu); > > Very minor nit: as we now have a couple of functions that are going to > check the same thing (irqchip_in_kernel), we could consider moving the > test here. I don't have strong feelings about it though. I like it: Thanks, -Christoffer diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index f935383..4263785 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -714,8 +714,10 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) } /* Tell userspace about in-kernel device output levels */ - kvm_timer_update_run(vcpu); - kvm_pmu_update_run(vcpu); + if (unlikely(!irqchip_in_kernel(vcpu->kvm))) { + kvm_timer_update_run(vcpu); + kvm_pmu_update_run(vcpu); + } if (vcpu->sigset_active) sigprocmask(SIG_SETMASK, &sigsaved, NULL); diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index 5dc2167..5976609 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -193,9 +193,6 @@ void kvm_timer_update_run(struct kvm_vcpu *vcpu) struct arch_timer_context *ptimer = vcpu_ptimer(vcpu); struct kvm_sync_regs *regs = &vcpu->run->s.regs; - if (likely(irqchip_in_kernel(vcpu->kvm))) - return; - /* Populate the device bitmap with the timer states */ regs->device_irq_level &= ~(KVM_ARM_DEV_EL1_VTIMER | KVM_ARM_DEV_EL1_PTIMER); diff --git a/virt/kvm/arm/pmu.c b/virt/kvm/arm/pmu.c index 51218be..4b43e7f 100644 --- a/virt/kvm/arm/pmu.c +++ b/virt/kvm/arm/pmu.c @@ -262,9 +262,6 @@ void kvm_pmu_update_run(struct kvm_vcpu *vcpu) { struct kvm_sync_regs *regs = &vcpu->run->s.regs; - if (likely(irqchip_in_kernel(vcpu->kvm))) - return; - /* Populate the timer bitmap for user space */ regs->device_irq_level &= ~KVM_ARM_DEV_PMU; if (vcpu->arch.pmu.irq_level)