lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <877i3uwa0j.fsf@basil.nowhere.org>
Date:	Fri, 13 Feb 2009 17:56:44 +0100
From:	Andi Kleen <andi@...stfloor.org>
To:	Yu Zhao <yu.zhao@...el.com>
Cc:	jbarnes@...tuousgeek.org, linux-pci@...r.kernel.org,
	kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v8 1/7] PCI: initialize and release SR-IOV capability

Yu Zhao <yu.zhao@...el.com> writes:
> +
> +
> +static int sriov_init(struct pci_dev *dev, int pos)
> +{
> +	int i;
> +	int rc;
> +	int nres;
> +	u32 pgsz;
> +	u16 ctrl, total, offset, stride;
> +	struct pci_sriov *iov;
> +	struct resource *res;
> +	struct pci_dev *pdev;
> +
> +	if (dev->pcie_type != PCI_EXP_TYPE_RC_END &&
> +	    dev->pcie_type != PCI_EXP_TYPE_ENDPOINT)
> +		return -ENODEV;
> +

It would be a good idea to put a might_sleep() here just in 
case the msleep happens below and drivers call it incorrectly.

> +	pci_read_config_word(dev, pos + PCI_SRIOV_CTRL, &ctrl);
> +	if (ctrl & PCI_SRIOV_CTRL_VFE) {
> +		pci_write_config_word(dev, pos + PCI_SRIOV_CTRL, 0);
> +		msleep(100);


That's really long. Hopefully that's really needed.

> +
> +	pci_write_config_word(dev, pos + PCI_SRIOV_CTRL, ctrl);
> +	pci_write_config_word(dev, pos + PCI_SRIOV_NUM_VF, total);
> +	pci_read_config_word(dev, pos + PCI_SRIOV_VF_OFFSET, &offset);
> +	pci_read_config_word(dev, pos + PCI_SRIOV_VF_STRIDE, &stride);
> +	if (!offset || (total > 1 && !stride))
> +		return -EIO;
> +
> +	pci_read_config_dword(dev, pos + PCI_SRIOV_SUP_PGSIZE, &pgsz);
> +	i = PAGE_SHIFT > 12 ? PAGE_SHIFT - 12 : 0;
> +	pgsz &= ~((1 << i) - 1);
> +	if (!pgsz)
> +		return -EIO;

All the error paths don't seem to undo the config space writes.
How will the devices behave with half initialized context?

-Andi

-- 
ak@...ux.intel.com -- Speaking for myself only.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ