[uClinux-dev] kernel 2.6.12 loadable modules

David McCullough davidm at snapgear.com
Thu Oct 6 19:04:52 EDT 2005


Jivin Matt Waddel lays it down ...
> Hi,
> 
> Simple question first, more details below.
> 
> Has anybody tried loadable modules in the 20050906
> 2.6.x release?
> 
> Regards,
> Matt
> 
> 
> Lengthy explanation:
> ---------------------
> 
> I'm testing loadable module support in the 2.6.x kernel
> for a new platform - M5208EVB.  Using a simple
> "hello world" module I get the following error when I
> try to insmod the program:
> 
> # insmod ./hello.ko
> insmod: cannot mmap `./hello.ko': No such device
> 
> So I look at where the busybox insmod is doing an mmap
> and it's in (modutils/insmod.c):
> 
> extern int insmod_ng_main( int argc, char **argv)
> ...
>     map = mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0);
>     if (map == MAP_FAILED) {
>          bb_perror_msg_and_die("cannot mmap `%s'", filename);
> ...
> 
> First I thought mmap is not implemented properly, so I
> found some test code for mmap in uClibc and ran it.  It
> passes as long as the flag variable is or'ed with
> MAP_ANONYMOUS.
> 
> Not setting MAP_ANONYMOUS causes the kernel to follow a
> path where it looks for file->f_op->mmap, this is where
> it fails (mm/nommu.c):
> 
> validate_mmap_request()
> ...
>    /* files must support mmap */
>    if (!file->f_op || !file->f_op->mmap)
>        return -ENODEV;
> ...
> 
> When using insmod where should these file operations be
> defined?
> 
> The code that checks the flag and creates the "file" is
> in (arch/m68knommu/kernel/sys_m68k.c):
> 
> static inline long do_mmap2()
> ...
>    if (!(flags & MAP_ANONYMOUS)) {         <<<<<<<<<
>          file = fget(fd);                  <<<<<<<<<
>            if (!file)
>               goto out;
>    }
> 
> Any hints would be appreciated.

Compare do_mmap2 with the m68k (with mmu) implementation and see if the
nommu version has been changed incorrectly ?

Have you tried modules on 2.4.31 ?  It's possible it is broken there
also since 2.4 and 2.6 now share a lot of a new mmap implementation.
Might help to isolate the problem.

Also,  just in case,  double check you have busybox configured for
2.6 kernels, otherwise it will be using the wrong mechanism for
loading modules.

Cheers,
Davidm

-- 
David McCullough, davidm at cyberguard.com.au, Custom Embedded Solutions + Security
Ph:+61 734352815 Fx:+61 738913630 http://www.uCdot.org http://www.cyberguard.com



More information about the uClinux-dev mailing list