From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754832AbaKNOF2 (ORCPT ); Fri, 14 Nov 2014 09:05:28 -0500 Received: from mail-pd0-f172.google.com ([209.85.192.172]:61371 "EHLO mail-pd0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754140AbaKNOFX (ORCPT ); Fri, 14 Nov 2014 09:05:23 -0500 Message-ID: <54660C16.6080107@gmail.com> Date: Fri, 14 Nov 2014 22:05:10 +0800 From: Chen Gang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Marc Zyngier CC: "christoffer.dall@linaro.org" , "gleb@kernel.org" , Paolo Bonzini , "linux-arm-kernel@lists.infradead.org" , "kvmarm@lists.cs.columbia.edu" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] virt: kvm: arm: vgic: Process the failure case when kvm_register_device_ops() fails References: <5464C865.90504@gmail.com> <5464CE9A.6050209@arm.com> In-Reply-To: <5464CE9A.6050209@arm.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/13/2014 11:30 PM, Marc Zyngier wrote: > On 13/11/14 15:04, Chen Gang wrote: >> When kvm_register_device_ops() fails, also need call free_percpu_irq() >> just like others have down within kvm_vgic_hyp_init(). >> >> Signed-off-by: Chen Gang >> --- >> virt/kvm/arm/vgic.c | 10 ++++++++-- >> 1 file changed, 8 insertions(+), 2 deletions(-) >> >> diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c >> index 3aaca49..b799f17 100644 >> --- a/virt/kvm/arm/vgic.c >> +++ b/virt/kvm/arm/vgic.c >> @@ -2470,8 +2470,14 @@ int kvm_vgic_hyp_init(void) >> >> on_each_cpu(vgic_init_maintenance_interrupt, NULL, 1); >> >> - return kvm_register_device_ops(&kvm_arm_vgic_v2_ops, >> - KVM_DEV_TYPE_ARM_VGIC_V2); >> + ret = kvm_register_device_ops(&kvm_arm_vgic_v2_ops, >> + KVM_DEV_TYPE_ARM_VGIC_V2); >> + if (ret) { >> + kvm_err("Cannot register device ops\n"); >> + goto out_free_irq; >> + } >> + >> + return 0; >> >> out_free_irq: >> free_percpu_irq(vgic->maint_irq, kvm_get_running_vcpus()); >> > > Awesome. You're now freeing a per-cpu interrupt after just after having > enabled it on all CPUs. What could possibly go wrong? > OK, thanks. What you said sound reasonable to me. Need call on_each_cpu for disable_percpu_irq(). Also need call __unregister_cpu_notifier(), and need a new function vgic_arch_unsetup() for arm64. I shall send patch v2 for it. Thanks. -- Chen Gang Open share and attitude like air water and life which God blessed