From: "Jan Beulich" Subject: Re: [PATCH v8 for-xen-4.5 1/2] dpci: Move from an hvm_irq_dpci (and struct domain) to an hvm_dirq_dpci model. Date: Thu, 23 Oct 2014 09:58:34 +0100 Message-ID: <5448DF5A0200007800041591@mail.emea.novell.com> References: <1413911967-26886-1-git-send-email-konrad.wilk@oracle.com> <1413911967-26886-2-git-send-email-konrad.wilk@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XhEE9-0006Oi-O5 for xen-devel@lists.xenproject.org; Thu, 23 Oct 2014 08:58:37 +0000 In-Reply-To: <1413911967-26886-2-git-send-email-konrad.wilk@oracle.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Konrad Rzeszutek Wilk Cc: keir@xen.org, ian.campbell@citrix.com, andrew.cooper3@citrix.com, tim@xen.org, xen-devel@lists.xenproject.org, ian.jackson@eu.citrix.com List-Id: xen-devel@lists.xenproject.org >>> On 21.10.14 at 19:19, wrote: > @@ -130,6 +127,18 @@ int pt_irq_create_bind( > return -ENOMEM; > } > pirq_dpci = pirq_dpci(info); > + /* > + * The 'pt_irq_create_bind' can be called right after 'pt_irq_destroy_bind' > + * was called. The 'pirq_cleanup_check' which would free the structure > + * is only called if the event channel for the PIRQ is active. However > + * OS-es that use event channels usually bind the PIRQ to an event channel > + * and also unbind it before 'pt_irq_destroy_bind' is called which means > + * we end up re-using the 'dpci' structure. This can be easily reproduced > + * with unloading and loading the driver for the device. > + * > + * As such on every 'pt_irq_create_bind' call we MUST reset the values. > + */ > + pirq_dpci->dom = d; I continue to disagree with the placement of this (only needed right before calling pirq_guest_bind(), as iirc you actually indicated you agree with), and I can only re-iterate that with it being here two error paths (hit before/without pirq_guest_bind() getting called) would need fixing up too (which wouldn't be needed if that assignment got deferred as much as possible). > @@ -156,6 +165,7 @@ int pt_irq_create_bind( > { > pirq_dpci->gmsi.gflags = 0; > pirq_dpci->gmsi.gvec = 0; > + pirq_dpci->dom = NULL; > pirq_dpci->flags = 0; > pirq_cleanup_check(info, d); > spin_unlock(&d->event_lock); Just like this error path needing adjustment, the other one following failure of pirq_guest_bind() (after > @@ -232,7 +242,6 @@ int pt_irq_create_bind( > { > unsigned int share; > > - pirq_dpci->dom = d; > if ( pt_irq_bind->irq_type == PT_IRQ_TYPE_MSI_TRANSLATE ) > { > pirq_dpci->flags = HVM_IRQ_DPCI_MAPPED | ) would seem to need adjustment too. Jan