From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH 15/15] KVM: Fix racy in kvm_free_assigned_irq Date: Thu, 1 Jan 2009 22:10:37 -0200 Message-ID: <20090102001037.GA5835@amt.cnet> References: <20081225115609.GA10087@syang10-desktop> <200812301014.10487.sheng@linux.intel.com> <20081230164551.GA5826@amt.cnet> <200812311343.55772.sheng@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Amit Shah , Avi Kivity , kvm@vger.kernel.org, Amit Shah , "Han, Weidong" To: Sheng Yang Return-path: Received: from mx2.redhat.com ([66.187.237.31]:51525 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754460AbZABAK5 (ORCPT ); Thu, 1 Jan 2009 19:10:57 -0500 Content-Disposition: inline In-Reply-To: <200812311343.55772.sheng@linux.intel.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Dec 31, 2008 at 01:43:54PM +0800, Sheng Yang wrote: > On Wednesday 31 December 2008 00:45:51 Marcelo Tosatti wrote: > > On Tue, Dec 30, 2008 at 10:14:09AM +0800, Sheng Yang wrote: > > > > There is one remaining issue: kvm_assigned_dev_interrupt_work_handler > > > > can re-enable the interrupt for KVM_ASSIGNED_DEV_GUEST_MSI case. > > > > Perhaps you need a new flag to indicate shutdown (so the host IRQ won't > > > > be reenabled). > > > > > > Is it already covered by disable_irq_no_sync() before cancel_work_sync()? > > > I've noted this in my comment: the irq may be disabled nested(once for > > > MSI and twice for INTx), but I think it's fine for we're going to free > > > it. > > > > The problem is that the irq can be re-enabled in > > kvm_assigned_dev_interrupt_work_handler: > > > > > > context 1 | context 2 > > > > disable_irq_nosync > > kvm_assigned_dev_interrupt_work_handler > > enable_irq > > cancel_work_sync > > > > free_irq > > > > Um... My understanding is a little different... > > Before context1 execute disable_irq_nosync(), in irq handler, > disable_irq_nosync() would also been executed. So only one enable_irq() is not > really enable irq here, which can cover the window at all. That's what I means > nested disable irq... You're right. There have been two disable_irq calls. OK, looks good to me.