From: "Jan Beulich" Subject: Re: xl/SR-IOV: disposition of VFs when PF disappears? Date: Wed, 29 Oct 2014 07:45:34 +0000 Message-ID: <5450A92E0200007800042F4A@mail.emea.novell.com> References: <544E4A4E020000780004267D@mail.emea.novell.com> <1414414666.23883.13.camel@eu.citrix.com> <20141027133534.GC4050@laptop.dumpdata.com> <20141027180723.GD12989@laptop.dumpdata.com> <544F7D310200007800042BC2@mail.emea.novell.com> <20141028140029.GC21290@laptop.dumpdata.com> <544FC1EA0200007800042CF7@mail.emea.novell.com> <544FD17C0200007800042D5B@mail.emea.novell.com> <20141028165640.GB26801@laptop.dumpdata.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 1XjNwm-00048p-6p for xen-devel@lists.xenproject.org; Wed, 29 Oct 2014 07:45:36 +0000 In-Reply-To: <20141028165640.GB26801@laptop.dumpdata.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: Wei Liu , Stefano Stabellini , "ian.jackson@eu.citrix.com" , Ian Campbell , xen-devel , Anirban Chakraborty List-Id: xen-devel@lists.xenproject.org >>> On 28.10.14 at 17:56, wrote: > On Tue, Oct 28, 2014 at 04:25:16PM +0000, Jan Beulich wrote: >> --- sle12.orig/drivers/xen/xen-pciback/pci_stub.c >> +++ sle12/drivers/xen/xen-pciback/pci_stub.c >> @@ -1502,6 +1502,44 @@ parse_error: >> fs_initcall(pcistub_init); >> #endif >> >> +#ifdef CONFIG_PCI_IOV >> +static int pci_stub_notifier(struct notifier_block *nb, >> + unsigned long action, void *data) >> +{ >> + struct device *dev = data; >> + struct pci_dev *pdev = to_pci_dev(dev); >> + >> + switch (action) { >> + case BUS_NOTIFY_UNBIND_DRIVER: >> + for (;;) { >> + struct pcistub_device *psdev; >> + unsigned long flags; >> + bool found = false; >> + >> + spin_lock_irqsave(&pcistub_devices_lock, flags); >> + >> + list_for_each_entry(psdev, &pcistub_devices, dev_list) >> + if (!psdev->pdev && psdev->dev != pdev >> + && pci_physfn(psdev->dev) == pdev) { >> + found = true; >> + break; >> + } >> + spin_unlock_irqrestore(&pcistub_devices_lock, flags); > > There are existing functions in the PCI back driver to find an device based > on the 'struct pci_dev'. > > That should make this piece of code much simpler by just looking for it > and if found call the 'device_release_driver'. But we're not after the psdev matching the incoming pdev. > However I am not entirely sure what ought to be done if the VF is > in _use_ ? Should we still do it? Of course not (as being insecure) - that's what the !psdev->pdev check is there for. Jan