From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH] kvm-kmod: fix kvm_request_irq race Date: Thu, 21 May 2009 09:29:01 +0300 Message-ID: <4A14F4AD.9060408@redhat.com> References: <20090521062135.GR20823@sequoia.sous-sol.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: Chris Wright Return-path: Received: from mx2.redhat.com ([66.187.237.31]:39705 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751113AbZEUG36 (ORCPT ); Thu, 21 May 2009 02:29:58 -0400 In-Reply-To: <20090521062135.GR20823@sequoia.sous-sol.org> Sender: kvm-owner@vger.kernel.org List-ID: Chris Wright wrote: > Commit "32658734: Fix request_irq() for < 2.6.19" is racy between multiple > guests since ioctl is only serialized per guest. Add mutex and serialize > kvm_request_irq/kvm_free_irq to avoid race. > > Signed-off-by: Chris Wright > --- > external-module-compat-comm.h | 14 +++++++++++--- > 1 files changed, 11 insertions(+), 3 deletions(-) > > diff --git a/external-module-compat-comm.h b/external-module-compat-comm.h > index 8cb5440..eaad986 100644 > --- a/external-module-compat-comm.h > +++ b/external-module-compat-comm.h > @@ -645,6 +645,7 @@ static inline int pci_reset_function(struct pci_dev *dev) > > typedef irqreturn_t (*kvm_irq_handler_t)(int, void *); > static kvm_irq_handler_t kvm_irq_handlers[NR_IRQS]; > +static DEFINE_MUTEX(kvm_irq_handlers_mutex); > > Since this mutex is in a header file, it can be instantiated multiple times. It will only serialize callers within a translation unit. Please define it in a C file. Would be best to move the the code as well. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic.