From a66e3fc8aacb854582f15bdf75e58f31aa2dad49 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Wed, 11 Aug 2010 17:01:02 +0100 Subject: [PATCH 1/2] msi: Avoid uninitialized msi descriptors When __pci_enable_msix() returns early, output parameter (struct msi_desc **desc) will not be initialized. On my machine, a Broadcom BCM5709 nic has both MSI and MSIX capability blocks and when guest tries to enable msix interrupts but __pci_enable_msix() returns early for encountering a msi block, the whole system will crash for fatal page fault immediately. Signed-off-by: Wei Wang --- xen/arch/x86/msi.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/msi.c b/xen/arch/x86/msi.c index 5ff709471a..1c8ad26c3d 100644 --- a/xen/arch/x86/msi.c +++ b/xen/arch/x86/msi.c @@ -607,30 +607,35 @@ static int msix_capability_init(struct pci_dev *dev, * indicates the successful setup of an entry zero with the new MSI * irq or non-zero for otherwise. **/ + static int __pci_enable_msi(struct msi_info *msi, struct msi_desc **desc) { int status; struct pci_dev *pdev; + struct msi_desc *old_desc; ASSERT(spin_is_locked(&pcidevs_lock)); pdev = pci_get_pdev(msi->bus, msi->devfn); if ( !pdev ) return -ENODEV; - if ( find_msi_entry(pdev, msi->irq, PCI_CAP_ID_MSI) ) + old_desc = find_msi_entry(pdev, msi->irq, PCI_CAP_ID_MSI); + if ( old_desc ) { dprintk(XENLOG_WARNING, "irq %d has already mapped to MSI on " "device %02x:%02x.%01x.\n", msi->irq, msi->bus, PCI_SLOT(msi->devfn), PCI_FUNC(msi->devfn)); + *desc = old_desc; return 0; } - if ( find_msi_entry(pdev, -1, PCI_CAP_ID_MSIX) ) + old_desc = find_msi_entry(pdev, -1, PCI_CAP_ID_MSIX); + if ( old_desc ) { dprintk(XENLOG_WARNING, "MSI-X is already in use on " "device %02x:%02x.%01x\n", msi->bus, PCI_SLOT(msi->devfn), PCI_FUNC(msi->devfn)); - return 0; + pci_disable_msi(old_desc); } status = msi_capability_init(pdev, msi->irq, desc); @@ -679,6 +684,7 @@ static int __pci_enable_msix(struct msi_info *msi, struct msi_desc **desc) u16 control; u8 slot = PCI_SLOT(msi->devfn); u8 func = PCI_FUNC(msi->devfn); + struct msi_desc *old_desc; ASSERT(spin_is_locked(&pcidevs_lock)); pdev = pci_get_pdev(msi->bus, msi->devfn); @@ -691,20 +697,24 @@ static int __pci_enable_msix(struct msi_info *msi, struct msi_desc **desc) if (msi->entry_nr >= nr_entries) return -EINVAL; - if ( find_msi_entry(pdev, msi->irq, PCI_CAP_ID_MSIX) ) + old_desc = find_msi_entry(pdev, msi->irq, PCI_CAP_ID_MSIX); + if ( old_desc ) { dprintk(XENLOG_WARNING, "irq %d has already mapped to MSIX on " "device %02x:%02x.%01x.\n", msi->irq, msi->bus, PCI_SLOT(msi->devfn), PCI_FUNC(msi->devfn)); + *desc = old_desc; return 0; } - if ( find_msi_entry(pdev, -1, PCI_CAP_ID_MSI) ) + old_desc = find_msi_entry(pdev, -1, PCI_CAP_ID_MSI); + if ( old_desc ) { dprintk(XENLOG_WARNING, "MSI is already in use on " "device %02x:%02x.%01x\n", msi->bus, PCI_SLOT(msi->devfn), PCI_FUNC(msi->devfn)); - return 0; + pci_disable_msi(old_desc); + } status = msix_capability_init(pdev, msi, desc); From a0b0302a08456f071b4b65a6084819048e58b59c Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 12 Aug 2010 17:06:21 +0100 Subject: [PATCH 2/2] tools/python: Remove non-ASCII characters introduced by fffedd3d70e1. fffedd3d70e1 introduced into tools/python/xen/util/vscsi_util.py high-bit-set characters which appear to be UTF-8 for non-breaking spaces. Replace them with spaces to avoid getting a Python syntax error. Signed-off-by: Ian Jackson --- tools/python/xen/util/vscsi_util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/python/xen/util/vscsi_util.py b/tools/python/xen/util/vscsi_util.py index 9abf66b84b..c8c2f36641 100644 --- a/tools/python/xen/util/vscsi_util.py +++ b/tools/python/xen/util/vscsi_util.py @@ -97,7 +97,7 @@ def _vscsi_get_scsidevices_by_lsscsi(option = ""): devices = [] for scsiinfo in os.popen('{ lsscsi -g %s; } 2>/dev/null' % option).readlines(): -        s = scsiinfo.replace(']', '] ').split() + s = scsiinfo.replace(']', '] ').split() hctl = s[0][1:-1] try: devname = s[-2].split('/dev/')[1]