[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Modules and the kernel



On Mon, 30 Nov 1998, Udi Finkelstein wrote:

> All this talk about loading modules raises a question:
> 
> As far as I understand, if a certain module is to be used, a kernel must be
> compiled for it. This means that an arbitrary vendor cannot ship an xyz.o
> module to support it's scsi card because the user's kernel must be compiled
> for it, right?

Wrong. There are modules for nearly everything around and many are unknown
to the kernel. A module is simply a compiled piece of code that has not
been linked. When you load a module it gets linked to the kernel symbols,
BSS etc etc. There is a uniform call interface to modules and a uniform
way to treat them (well, almost). If you want, you can say that a part of
the ld functionality has been built into the kernel, and that it can do
'late binding' (I hope that this was not coined in Redmond). This is way
superior to traditional drivers, which are limited to being... drivers. In
Linux you can patch the kernel while it runs... (with some care ;).

When a module is loaded by kerneld then it (kerneld) needs to have access
to a map of symbols that tells it which symbols are defined in which
module. If a program calls an unknown symbol in the kernel, then kerneld
gets to look it up (yes, kerneld needs to know about it at kernel compile
time - this is the only case when the kernel must know about a module at
compile time ?), if it is not in RAM, it loads the module under whose
table that symbol lives and calls the function. 

The module interface is uniform. A module compiled on a machine can be
used on another, assuming they had used the same source tree and the
target has module use enabled. 

> While most Linux hackers find it easy to recompile a new kernel (myself
> included), how many people could add an arbitrary module to the kernel source
> tree? How many *users* could do that?

It is the same process as unpacking a package. The install scripts of ANY
package can trigger a kernel compile. On a K6/233 and up it takes under 5
minutes... 

> Is there any work done on adding true device drivers for Linux (that can be
> added without recompiling a kernel)?

Dear Udi, you can add modules anytime, and download and use modules
anytime. Only kerneld will not be able to help you with them. joystick,
bttv and many sound modules (commercial !!!) work exactly like that.

There is only one BIG problem: a module can do anything inside the kernel,
including take the system over. Better trust the place where you get an
executable module.

Peter