From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95CB7C43603 for ; Fri, 6 Dec 2019 10:56:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 69F622245C for ; Fri, 6 Dec 2019 10:56:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575629800; bh=vs7fz85kQNDofToi4WfYvmrbZmp8cI8zREDtKpBWofc=; h=To:Subject:Date:From:Cc:In-Reply-To:References:List-ID:From; b=jlB8AIjBeNHKy6YgytI7F6R06x5J40033L63UinfMdyrhbM18q2j5xYaL/mLxzLiG 1nnBM+Zu56LOlR2MMJ7hmls3C6YkoG8GBlq9BAGwJ2SMmJFn/8qtGBeEX/UbTTm2B7 6rcYeDr/o+lXrzxzKA/z/1KH4QW5LErRJlymzSJA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726244AbfLFK4h (ORCPT ); Fri, 6 Dec 2019 05:56:37 -0500 Received: from inca-roads.misterjones.org ([213.251.177.50]:37079 "EHLO inca-roads.misterjones.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726154AbfLFK4g (ORCPT ); Fri, 6 Dec 2019 05:56:36 -0500 Received: from www-data by cheepnis.misterjones.org with local (Exim 4.80) (envelope-from ) id 1idBHd-0001CF-6Z; Fri, 06 Dec 2019 11:56:25 +0100 To: linmiaohe Subject: Re: [PATCH] KVM: arm: fix missing =?UTF-8?Q?free=5Fpercpu=5Firq?= =?UTF-8?Q?=20in=20kvm=5Ftimer=5Fhyp=5Finit=28=29?= X-PHP-Originating-Script: 0:main.inc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 06 Dec 2019 10:56:24 +0000 From: Marc Zyngier Cc: , , , , , , , , In-Reply-To: <1574476229-15448-1-git-send-email-linmiaohe@huawei.com> References: <1574476229-15448-1-git-send-email-linmiaohe@huawei.com> Message-ID: <96f07f61e3356c942ce934f81efc4a94@www.loen.fr> X-Sender: maz@kernel.org User-Agent: Roundcube Webmail/0.7.2 X-SA-Exim-Connect-IP: X-SA-Exim-Rcpt-To: linmiaohe@huawei.com, pbonzini@redhat.com, rkrcmar@redhat.com, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kvm@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On 2019-11-23 02:30, linmiaohe wrote: > From: Miaohe Lin > > When host_ptimer_irq request irq resource failed, we forget > to release the host_vtimer_irq resource already requested. > Fix this missing irq release and other similar scenario. That's really not a big deal, as nothing but KVM can use the timers anyway, but I guess it doesn't hurt to be correct. > > Fixes: 9e01dc76be6a ("KVM: arm/arm64: arch_timer: Assign the phys > timer on VHE systems") > Signed-off-by: Miaohe Lin > --- > virt/kvm/arm/arch_timer.c | 17 ++++++++++++----- > 1 file changed, 12 insertions(+), 5 deletions(-) > > diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c > index f182b2380345..73867f97040c 100644 > --- a/virt/kvm/arm/arch_timer.c > +++ b/virt/kvm/arm/arch_timer.c > @@ -935,7 +935,7 @@ int kvm_timer_hyp_init(bool has_gic) > kvm_get_running_vcpus()); > if (err) { > kvm_err("kvm_arch_timer: error setting vcpu affinity\n"); > - goto out_free_irq; > + goto out_free_vtimer_irq; > } > > static_branch_enable(&has_gic_active_state); > @@ -960,7 +960,7 @@ int kvm_timer_hyp_init(bool has_gic) > if (err) { > kvm_err("kvm_arch_timer: can't request ptimer interrupt %d > (%d)\n", > host_ptimer_irq, err); > - return err; > + goto out_disable_gic_state; > } > > if (has_gic) { > @@ -968,7 +968,7 @@ int kvm_timer_hyp_init(bool has_gic) > kvm_get_running_vcpus()); > if (err) { > kvm_err("kvm_arch_timer: error setting vcpu affinity\n"); > - goto out_free_irq; > + goto out_free_ptimer_irq; > } > } > > @@ -977,15 +977,22 @@ int kvm_timer_hyp_init(bool has_gic) > kvm_err("kvm_arch_timer: invalid physical timer IRQ: %d\n", > info->physical_irq); > err = -ENODEV; > - goto out_free_irq; > + goto out_disable_gic_state; > } > > cpuhp_setup_state(CPUHP_AP_KVM_ARM_TIMER_STARTING, > "kvm/arm/timer:starting", kvm_timer_starting_cpu, > kvm_timer_dying_cpu); > return 0; > -out_free_irq: > + > +out_free_ptimer_irq: > + free_percpu_irq(host_ptimer_irq, kvm_get_running_vcpus()); > +out_disable_gic_state: > + if (has_gic) > + static_branch_disable(&has_gic_active_state); Given that we're failing the init of KVM, this is totally superfluous. Also, this state is still valid, no matter what happens (the GIC is not going away from under our feet). > +out_free_vtimer_irq: > free_percpu_irq(host_vtimer_irq, kvm_get_running_vcpus()); > + > return err; > } Thanks, M. -- Jazz is not dead. It just smells funny...