insmod uses syscall

Chris Kottaridis chriskot at quietwind.net
Tue Jan 24 23:43:37 UTC 2006


OK, I am curious about this. I am running busybox 1.01 on akernel based
off of 2.6.14.

The insmod.c file shows that a module gets inserted by calling the
syscall operation:

 printf("insmod: Calling syscall %d Hex:%x\n", __NR_init_module,
__NR_init_module);
    ret = syscall(__NR_init_module, map, len, options);
    if (ret != 0) {
        bb_perror_msg_and_die("cannot insert `%s': %s (%li)",
                filename, moderror(errno), ret);
    }

The printf is mine so I can see what values are getting passed. Now I
did an strace on this and the ultimate OS call that seems to get called
is:

>mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
>0) = 0x40018000
>write(1, "insmod: Calling syscall 9437312 "..., 43insmod: Calling
>syscall 9437312 Hex:900080
>) = 43
>vm86old(0x900080)                      = -1 ENOSYS (Function not
^^^^^^^^
>implemented)
>write(2, "insmod: ", 8insmod: )                = 8
>write(2, "cannot insert `md-mod.ko\':38--1:"..., 62cannot insert
>`md-mod.ko':38--1: Function not implemented (-1)) = 62

Seems the libc converts this to an OS call to vm86old(), which
apparently isn't configured into the kernel. Now if I strace the the
module-init-tools and run that insmod:

>open("raid0.ko", O_RDONLY)              = 3
>read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\1\0(\0\1\0\0\0\0\0\0\0"...,
>16384) = 8092
>read(3, "", 8292)                      = 0
>close(3)                                = 0
>init_module("ELF", 0x1f9c)          = 0
>io_submit(0, 0, 0 <unfinished ... exit status 0>

So, it seems that the module-init-tools version of insmod calls the OS
call init_module(), which certainly seems ot make sense.

Now, I have a different kernel version (a 2.6.10 variant) with a
different config file that the busybox (version 1.0) insmod , which
strace on it shows to also be using vm86old(), is working just fine.

I guess I am a bit curious why busybox's insmod doesn't use
init_module() call. Is there some  good reason for this or is this some
leftover historical thing ?

It looks like init_module() takes different parameters then the
vm86old().

I am also curious what kernel config optin gets the vm86old() routine
supported. The two variants I am using have significantly different
configuration files and so far I haven't been able to figure out which
configuration gets vm86old enabled. I tried just copying over the
working .config file, but there were too many other config options that
the compile seemed to complain about.

Any helpful hints would be appreciated.
-- 
Chris Kottaridis <chriskot at quietwind.net>



More information about the busybox mailing list