[uClinux-dev] kernel 2.6.12 loadable modules

Greg Ungerer gerg at snapgear.com
Fri Oct 7 02:48:40 EDT 2005


Hi Matt,

Matt Waddel wrote:
> Simple question first, more details below.
> 
> Has anybody tried loadable modules in the 20050906
> 2.6.x release?

I can confirm it is broken in this way for all Coldfire
targets (probably even all m68knommu targets). And in
2.6.13-uc0 as well.


> 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.

The underlying mmap implementation for uClinux changed
a couple of 2.6 kernels back. I suspect this stems from
those changes. But I'll need to dig deeper.

Regards
Greg


------------------------------------------------------------------------
Greg Ungerer  --  Chief Software Dude       EMAIL:     gerg at snapgear.com
SnapGear -- a CyberGuard Company            PHONE:       +61 7 3435 2888
825 Stanley St,                             FAX:         +61 7 3891 3630
Woolloongabba, QLD, 4102, Australia         WEB: http://www.SnapGear.com



More information about the uClinux-dev mailing list