public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Exposing device ids and driver names
@ 2009-10-01 16:40 Nathaniel McCallum
  2009-10-01 16:42 ` Greg KH
  2009-10-01 17:47 ` Stefan Richter
  0 siblings, 2 replies; 14+ messages in thread
From: Nathaniel McCallum @ 2009-10-01 16:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: greg

Please CC me on any responses as I'm not subscribed to lkml.

I have the aim at creating two tools helpful to linux.  The first tool 
is a driver regression test of sorts.  I want to be able to create 
essentially a time line of hardware support as they appear in distros. 
The second tool, related to the first, is a program which runs on 
Windows and scans for a user's hardware and tells them which distro will 
best support their hardware.  I already have a working prototype of 
these two tools.  It currently uses the data exported by modinfo.  This 
however does not provide transparency for drivers compiled into the kernel.

Thus, my requirements are as follows.  I need to be able to gather the 
*_device_id tables and driver names from the kernel by scanning the 
kernel/module binaries.  The implementation should be careful not to 
expand memory footprint if at all possible and should seek to expose 
only stable structures to userspace.

Further, I have the limitation that symbol names are unhelpful since 
they are stripped out of the kernel.

My initial investigation has led me to one of two methods (though I am 
certainly open to other suggestions).  Since symbols are most often 
stripped from the kernel, I have largely focused my investigation on 
using ELF sections.

The first method is to expand the MODULE_DEVICE_TABLE() macro to do 
something for built in modules (such as the following):
#define MODULE_DEVICE_TABLE(type, name)                        \
   static const struct type##_device_id *__##name##_dev_tbl     \
     __used __section(.dev.ids.##type)

This has the advantage of being an extremely small change to the kernel 
and being easy to parse out of the binaries.  The disadvantages are that 
it adds a pointer for each device table (expanding memory footprint) and 
does not provide the name of the driver which will be loaded for that 
table (making it hard to track when a driver moves in/out of the kernel 
to/from a module).

The second method is to create a macro for *_driver struct definitions 
(similar to DEFINE_PCI_DEVICE_TABLE() in include/linux/pci.h).  Perhaps 
something like this:
#define DEFINE_DRIVER(type, name) \
   static struct type##_driver name __section(.drv.##type)

The advantages of this method are minimal memory footprint increase 
(only the size of the ELF section header and name) and easy parsing of 
both the driver name and the type##_device_id struct.  The disadvantages 
are that every driver will have to be updated to use the new macro 
(which can probably be done programatically) and that *_driver structs 
have now become part of the kernel ABI (I'm not sure how bad this is). 
I also ran into a wierd problem where the *_driver structs are zeroed 
when built into modules, but I'm not sure what causes that (it wasn't my 
patch).

Which method is preferable? Any other suggestions?

Thanks for your help,
Nathaniel

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2009-10-01 21:37 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-01 16:40 Exposing device ids and driver names Nathaniel McCallum
2009-10-01 16:42 ` Greg KH
2009-10-01 17:01   ` Nathaniel McCallum
2009-10-01 18:05     ` Greg KH
2009-10-01 18:35       ` Nathaniel McCallum
2009-10-01 18:40         ` Greg KH
2009-10-01 18:56           ` Nathaniel McCallum
2009-10-01 19:07             ` Greg KH
2009-10-01 19:17               ` Nathaniel McCallum
2009-10-01 21:36           ` Nathaniel McCallum
2009-10-01 17:47 ` Stefan Richter
2009-10-01 18:02   ` Nathaniel McCallum
2009-10-01 18:23     ` Stefan Richter
2009-10-01 18:28       ` Nathaniel McCallum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox