[Pkg-xen-devel] [Xen-devel] Crash during boot in Debian lenny default dom0 kernel (2.6.26-2-xen-686) / bugfix patch

Pasi Kärkkäinen pasik at iki.fi
Fri Feb 26 11:12:45 UTC 2010


Hello,

More information and a patch for the bug.

-- Pasi

----- Forwarded message from George Dunlap <George.Dunlap at eu.citrix.com> -----

From: George Dunlap <George.Dunlap at eu.citrix.com>
To: Jan Beulich <JBeulich at novell.com>
Cc: Sander Eikelenboom <linux at eikelenboom.it>,
	Jeremy Fitzhardinge <jeremy at goop.org>,
	Yunhong Jiang <yunhong.jiang at intel.com>,
	"xen-devel at lists.xensource.com" <xen-devel at lists.xensource.com>
Date: Fri, 26 Feb 2010 11:05:48 +0000
Subject: Re: [Xen-devel] Crash during boot in Debian lenny default dom0 kernel
	(2.6.26-2-xen-686)

OK, the attached patch fits cleanly in to the debian source package
infrastructure and can result in a built .deb file that actually
works.

Can those who know the system take a quick look to see if there's
anything obviously broken?  I'll file a bug report to debian with the
patch Monday; hopefully it will be picked up quickly.

Thanks,
 -George

On Thu, Feb 25, 2010 at 1:28 PM, George Dunlap
<George.Dunlap at eu.citrix.com> wrote:
> Forward porting the linux-2.6.18 patch has been straightforward so
> far... I'm going to give it a spin and see if it actually boots. :-)
>
> It's linux-2.6.18.hg c/s 645:359b1e70d9eb, in case you're interested.
>
>  -George
>
> On Thu, Feb 25, 2010 at 1:07 PM, Jan Beulich <JBeulich at novell.com> wrote:
>>>>> George Dunlap <George.Dunlap at eu.citrix.com> 25.02.10 13:13 >>>
>>>Any suggestions for a simple fix I can try to push upstream?
>>
>> I'm afraid not (other than simply disabling at least the MSI-X part of
>> the code), as it would require table_base to be initialized properly.
>>
>> Jan
>>
>>
>> _______________________________________________
>> Xen-devel mailing list
>> Xen-devel at lists.xensource.com
>> http://lists.xensource.com/xen-devel
>>
>

diff -u -r build_i386_xen_686/drivers/pci/msi-xen.c build_i386_xen_686-fix/drivers/pci/msi-xen.c
--- build_i386_xen_686/drivers/pci/msi-xen.c	2010-02-25 12:23:43.000000000 +0000
+++ build_i386_xen_686-fix/drivers/pci/msi-xen.c	2010-02-25 13:08:16.000000000 +0000
@@ -238,11 +238,27 @@
 	return 0;
 }
 
+static u64 find_table_base(struct pci_dev *dev, int pos)
+{
+	u8 bar;
+	u32 reg;
+	unsigned long flags;
+
+ 	pci_read_config_dword(dev, msix_table_offset_reg(pos), &reg);
+	bar = reg & PCI_MSIX_FLAGS_BIRMASK;
+
+	flags = pci_resource_flags(dev, bar);
+	if (flags & (IORESOURCE_DISABLED | IORESOURCE_UNSET | IORESOURCE_BUSY))
+		return 0;
+
+	return pci_resource_start(dev, bar);
+}
+
 /*
  * Protected by msi_lock
  */
 static int msi_map_pirq_to_vector(struct pci_dev *dev, int pirq,
-                                  int entry_nr, int msi)
+				  int entry_nr, u64 table_base)
 {
 	struct physdev_map_pirq map_irq;
 	int rc;
@@ -254,10 +270,10 @@
 	map_irq.type = MAP_PIRQ_TYPE_MSI;
 	map_irq.index = -1;
 	map_irq.pirq = pirq;
-    map_irq.msi_info.bus = dev->bus->number;
-    map_irq.msi_info.devfn = dev->devfn;
-	map_irq.msi_info.entry_nr = entry_nr;
-    map_irq.msi_info.msi = msi;
+	map_irq.bus = dev->bus->number;
+	map_irq.devfn = dev->devfn;
+	map_irq.entry_nr = entry_nr;
+	map_irq.table_base = table_base;
 
 	if ((rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq)))
 		printk(KERN_WARNING "map irq failed\n");
@@ -268,9 +284,9 @@
 	return map_irq.pirq;
 }
 
-static int msi_map_vector(struct pci_dev *dev, int entry_nr, int msi)
+static int msi_map_vector(struct pci_dev *dev, int entry_nr, u64 table_base)
 {
-	return msi_map_pirq_to_vector(dev, -1, entry_nr, msi);
+	return msi_map_pirq_to_vector(dev, -1, entry_nr, table_base);
 }
 
 static void pci_intx_for_msi(struct pci_dev *dev, int enable)
@@ -286,7 +302,7 @@
 	if (!dev->msi_enabled)
 		return;
 
-	pirq = msi_map_pirq_to_vector(dev, dev->irq, 0, 1);
+	pirq = msi_map_pirq_to_vector(dev, dev->irq, 0, 0);
 	if (pirq < 0)
 		return;
 
@@ -296,19 +312,29 @@
 
 static void __pci_restore_msix_state(struct pci_dev *dev)
 {
+        int pos;
 	unsigned long flags;
+	u64 table_base;
 	struct msi_dev_list *msi_dev_entry;
 	struct msi_pirq_entry *pirq_entry, *tmp;
 
+	pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
+	if (pos <= 0)
+	  return;
+
 	if (!dev->msix_enabled)
 		return;
 
 	msi_dev_entry = get_msi_dev_pirq_list(dev);
+	table_base = find_table_base(dev, pos);
+	if (!table_base)
+		return;
 
 	spin_lock_irqsave(&msi_dev_entry->pirq_list_lock, flags);
 	list_for_each_entry_safe(pirq_entry, tmp,
-							 &msi_dev_entry->pirq_list_head, list)
-		msi_map_pirq_to_vector(dev, pirq_entry->pirq, pirq_entry->entry_nr, 0);
+				 &msi_dev_entry->pirq_list_head, list)
+		msi_map_pirq_to_vector(dev, pirq_entry->pirq,
+				       pirq_entry->entry_nr, table_base);
 	spin_unlock_irqrestore(&msi_dev_entry->pirq_list_lock, flags);
 
 	pci_intx_for_msi(dev, 0);
@@ -338,10 +364,10 @@
 
 	msi_set_enable(dev, 0);	/* Ensure msi is disabled as I set it up */
 
-   	pos = pci_find_capability(dev, PCI_CAP_ID_MSI);
+	pos = pci_find_capability(dev, PCI_CAP_ID_MSI);
 	pci_read_config_word(dev, msi_control_reg(pos), &control);
 
-	pirq = msi_map_vector(dev, 0, 1);
+	pirq = msi_map_vector(dev, 0, 0);
 	if (pirq < 0)
 		return -EBUSY;
 
@@ -367,7 +393,8 @@
 static int msix_capability_init(struct pci_dev *dev,
 				struct msix_entry *entries, int nvec)
 {
-	int pirq, i, j, mapped;
+        u64 table_base;
+	int pirq, i, j, mapped, pos;
 	struct msi_dev_list *msi_dev_entry = get_msi_dev_pirq_list(dev);
 	struct msi_pirq_entry *pirq_entry;
 
@@ -376,6 +403,11 @@
 
 	msix_set_enable(dev, 0);/* Ensure msix is disabled as I set it up */
 
+	pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
+	table_base = find_table_base(dev, pos);
+	if (!table_base)
+		return -ENODEV;
+
 	/* MSI-X Table Initialization */
 	for (i = 0; i < nvec; i++) {
 		mapped = 0;
@@ -392,7 +424,7 @@
 		}
 		if (mapped)
 			continue;
-		pirq = msi_map_vector(dev, entries[i].entry, 0);
+		pirq = msi_map_vector(dev, entries[i].entry, table_base);
 		if (pirq < 0)
 			break;
 		attach_pirq_entry(pirq, entries[i].entry, msi_dev_entry);
diff -u -r build_i386_xen_686/include/xen/interface/physdev.h build_i386_xen_686-fix/include/xen/interface/physdev.h
--- build_i386_xen_686/include/xen/interface/physdev.h	2010-02-25 12:23:43.000000000 +0000
+++ build_i386_xen_686-fix/include/xen/interface/physdev.h	2010-02-25 12:38:42.000000000 +0000
@@ -136,10 +136,13 @@
     /* IN or OUT */
     int pirq;
     /* IN */
-    struct {
-        int bus, devfn, entry_nr;
-		int msi;  /* 0 - MSIX    1 - MSI */
-    } msi_info;
+    int bus;
+    /* IN */
+    int devfn;
+    /* IN */
+    int entry_nr;
+    /* IN */
+    uint64_t table_base;
 };
 typedef struct physdev_map_pirq physdev_map_pirq_t;
 DEFINE_XEN_GUEST_HANDLE(physdev_map_pirq_t);

_______________________________________________
Xen-devel mailing list
Xen-devel at lists.xensource.com
http://lists.xensource.com/xen-devel


----- End forwarded message -----



More information about the Pkg-xen-devel mailing list