Re: [PATCH] pci: fix unterminated pci_device_id lists
On Sep 13 2007 02:42, Jeff Garzik wrote: > Alexey Dobriyan wrote: >> -static struct pci_device_id rtl8139_pci_tbl[] = { >> +PCI_MODULE_DEVICE_TABLE_BEGIN(rtl8139_pci_tbl) >> {0x10ec, 0x8139, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 }, >> {0x10ec, 0x8138, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 }, >> {0x1113, 0x1211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 }, >> @@ -273,10 +273,7 @@ static struct pci_device_id rtl8139_pci_tbl[] = { >> {PCI_ANY_ID, 0x8139, 0x10ec, 0x8139, 0, 0, RTL8139 }, >> {PCI_ANY_ID, 0x8139, 0x1186, 0x1300, 0, 0, RTL8139 }, >> {PCI_ANY_ID, 0x8139, 0x13d1, 0xab06, 0, 0, RTL8139 }, >> - >> -{0,} >> -}; >> -MODULE_DEVICE_TABLE (pci, rtl8139_pci_tbl); >> +PCI_MODULE_DEVICE_TABLE_END That looks sooo... wxwidgets-like :) > I think the previous version looks better. Nod. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] pci: fix unterminated pci_device_id lists
On Thu, Sep 13, 2007 at 10:34:02AM +0400, Alexey Dobriyan wrote: > [non-terminated PCI ids arrays] > > Here is compile-time hack (yep, warped and whitespace damaged :)) > It's better than modpost-time hack. because it triggers earlier. > It's worse than modpost-time hack, because of tree-wide changes. > > diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c > index f4e4298..b895b5f 100644 > --- a/drivers/net/8139too.c > +++ b/drivers/net/8139too.c > @@ -237,7 +237,7 @@ static const struct { > }; > > > -static struct pci_device_id rtl8139_pci_tbl[] = { > +PCI_MODULE_DEVICE_TABLE_BEGIN(rtl8139_pci_tbl) > {0x10ec, 0x8139, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 }, > {0x10ec, 0x8138, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 }, > {0x1113, 0x1211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 }, > @@ -273,10 +273,7 @@ static struct pci_device_id rtl8139_pci_tbl[] = { > {PCI_ANY_ID, 0x8139, 0x10ec, 0x8139, 0, 0, RTL8139 }, > {PCI_ANY_ID, 0x8139, 0x1186, 0x1300, 0, 0, RTL8139 }, > {PCI_ANY_ID, 0x8139, 0x13d1, 0xab06, 0, 0, RTL8139 }, > - > - {0,} > -}; > -MODULE_DEVICE_TABLE (pci, rtl8139_pci_tbl); > +PCI_MODULE_DEVICE_TABLE_END Looks at bit too magic to my taste. And anyway deferring the check until modpost time should not cause troubles anyway assuming people do build their kernel after adding a device ID. And the above requires one to use the special macro in all places whereas the modpost check will catch it also for new device ID users. Sam - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] pci: fix unterminated pci_device_id lists
Alexey Dobriyan wrote: -static struct pci_device_id rtl8139_pci_tbl[] = { +PCI_MODULE_DEVICE_TABLE_BEGIN(rtl8139_pci_tbl) {0x10ec, 0x8139, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 }, {0x10ec, 0x8138, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 }, {0x1113, 0x1211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 }, @@ -273,10 +273,7 @@ static struct pci_device_id rtl8139_pci_tbl[] = { {PCI_ANY_ID, 0x8139, 0x10ec, 0x8139, 0, 0, RTL8139 }, {PCI_ANY_ID, 0x8139, 0x1186, 0x1300, 0, 0, RTL8139 }, {PCI_ANY_ID, 0x8139, 0x13d1, 0xab06, 0, 0, RTL8139 }, - - {0,} -}; -MODULE_DEVICE_TABLE (pci, rtl8139_pci_tbl); +PCI_MODULE_DEVICE_TABLE_END I think the previous version looks better. Jeff - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] pci: fix unterminated pci_device_id lists
[non-terminated PCI ids arrays] Here is compile-time hack (yep, warped and whitespace damaged :)) It's better than modpost-time hack. because it triggers earlier. It's worse than modpost-time hack, because of tree-wide changes. diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c index f4e4298..b895b5f 100644 --- a/drivers/net/8139too.c +++ b/drivers/net/8139too.c @@ -237,7 +237,7 @@ static const struct { }; -static struct pci_device_id rtl8139_pci_tbl[] = { +PCI_MODULE_DEVICE_TABLE_BEGIN(rtl8139_pci_tbl) {0x10ec, 0x8139, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 }, {0x10ec, 0x8138, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 }, {0x1113, 0x1211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 }, @@ -273,10 +273,7 @@ static struct pci_device_id rtl8139_pci_tbl[] = { {PCI_ANY_ID, 0x8139, 0x10ec, 0x8139, 0, 0, RTL8139 }, {PCI_ANY_ID, 0x8139, 0x1186, 0x1300, 0, 0, RTL8139 }, {PCI_ANY_ID, 0x8139, 0x13d1, 0xab06, 0, 0, RTL8139 }, - - {0,} -}; -MODULE_DEVICE_TABLE (pci, rtl8139_pci_tbl); +PCI_MODULE_DEVICE_TABLE_END static struct { const char str[ETH_GSTRING_LEN]; diff --git a/include/linux/module.h b/include/linux/module.h index b6a646c..aef3cd9 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -137,6 +137,13 @@ extern struct module __this_module; #define MODULE_DEVICE_TABLE(type,name) \ MODULE_GENERIC_TABLE(type##_device,name) +#define PCI_MODULE_DEVICE_TABLE_BEGIN(name)\ + MODULE_DEVICE_TABLE(pci, name); \ + static struct pci_device_id name[] = { + +#define PCI_MODULE_DEVICE_TABLE_END\ + {}}; + /* Version of form [:][-]. Or for CVS/RCS ID version, everything but the number is stripped. : A (small) unsigned integer which allows you to start versions - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] pci: fix unterminated pci_device_id lists
On Wed, 12 Sep 2007 14:53:56 -0700 Greg KH <[EMAIL PROTECTED]> wrote: > On Wed, Sep 12, 2007 at 03:48:49PM +0400, Alexey Dobriyan wrote: > > On 9/12/07, Jeff Garzik <[EMAIL PROTECTED]> wrote: > > > Kees Cook wrote: > > > > This patch against 2.6.23-rc6 fixes a couple drivers that do not > > > > correctly terminate their pci_device_id lists. This results in garbage > > > > being spewed into modules.pcimap when the module happens to not have > > > > 28 NULL bytes following the table, and/or the last PCI ID is actually > > > > truncated from the table when calculating the modules.alias PCI aliases, > > > > cause those unfortunate device IDs to not auto-load. > > > > > > > > Signed-off-by: Kees Cook <[EMAIL PROTECTED]> > > > > > > ACK > > > > I mut say, non-terminated PCI ids lists are constant PITA. There should be > > a way to a) put it in macro[1], so that terminator automatically added, and > > b) still allow #ifdef inside table like, e.g. 8139too does. > > > > [1] or not macro, because #ifdef inside macros aren't allowed. > > If you know of a way to do this in an easier manner, patches are always > gladly accepted :) Change (ie: fix) the APIs to take a `length' arg, then fix up 10^42 drivers. Oh, you said "easy" ;) Perhaps there's some clever way in which we can check that the tables are correctly terminated. I guess some static code-checker could do it. A weaker option would be to do some runtime hack which carefully walks the table and checks stuff. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] pci: fix unterminated pci_device_id lists
On Wed, Sep 12, 2007 at 03:48:49PM +0400, Alexey Dobriyan wrote: > On 9/12/07, Jeff Garzik <[EMAIL PROTECTED]> wrote: > > Kees Cook wrote: > > > This patch against 2.6.23-rc6 fixes a couple drivers that do not > > > correctly terminate their pci_device_id lists. This results in garbage > > > being spewed into modules.pcimap when the module happens to not have > > > 28 NULL bytes following the table, and/or the last PCI ID is actually > > > truncated from the table when calculating the modules.alias PCI aliases, > > > cause those unfortunate device IDs to not auto-load. > > > > > > Signed-off-by: Kees Cook <[EMAIL PROTECTED]> > > > > ACK > > I mut say, non-terminated PCI ids lists are constant PITA. There should be > a way to a) put it in macro[1], so that terminator automatically added, and > b) still allow #ifdef inside table like, e.g. 8139too does. > > [1] or not macro, because #ifdef inside macros aren't allowed. If you know of a way to do this in an easier manner, patches are always gladly accepted :) thanks, greg k-h - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] pci: fix unterminated pci_device_id lists
On 9/12/07, Jeff Garzik <[EMAIL PROTECTED]> wrote: > Kees Cook wrote: > > This patch against 2.6.23-rc6 fixes a couple drivers that do not > > correctly terminate their pci_device_id lists. This results in garbage > > being spewed into modules.pcimap when the module happens to not have > > 28 NULL bytes following the table, and/or the last PCI ID is actually > > truncated from the table when calculating the modules.alias PCI aliases, > > cause those unfortunate device IDs to not auto-load. > > > > Signed-off-by: Kees Cook <[EMAIL PROTECTED]> > > ACK I mut say, non-terminated PCI ids lists are constant PITA. There should be a way to a) put it in macro[1], so that terminator automatically added, and b) still allow #ifdef inside table like, e.g. 8139too does. [1] or not macro, because #ifdef inside macros aren't allowed. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] pci: fix unterminated pci_device_id lists
Kees Cook wrote: This patch against 2.6.23-rc6 fixes a couple drivers that do not correctly terminate their pci_device_id lists. This results in garbage being spewed into modules.pcimap when the module happens to not have 28 NULL bytes following the table, and/or the last PCI ID is actually truncated from the table when calculating the modules.alias PCI aliases, cause those unfortunate device IDs to not auto-load. Signed-off-by: Kees Cook <[EMAIL PROTECTED]> ACK - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/