From: Nathaniel McCallum <nathaniel@natemccallum.com>
To: linux-kernel@vger.kernel.org
Cc: greg@kroah.com
Subject: Exposing device ids and driver names
Date: Thu, 01 Oct 2009 12:40:05 -0400 [thread overview]
Message-ID: <4AC4DB65.8070404@natemccallum.com> (raw)
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
next reply other threads:[~2009-10-01 16:40 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-01 16:40 Nathaniel McCallum [this message]
2009-10-01 16:42 ` Exposing device ids and driver names 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4AC4DB65.8070404@natemccallum.com \
--to=nathaniel@natemccallum.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox