LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-13-2011, 06:17 PM   #1
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Blog Entries: 1

Rep: Reputation: 90
When insmodding I get a "function not implemented" message


Hi!

I have built a module to load it on a UML instance running a different kernel from the one I'm running on the host host. I have built the module against the headers for the kernel I'm using on the guest but when I try to insmod the module (on the guest, of course), I get a "function not implemented" message.

Can insmod be a little more verbose about the function that is not implemented? I tried running strace on the insmod but the error comes from init_module so not much more information is available:

Code:
open("r5r.ko", O_RDONLY)                = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\1\0\3\0\1\0\0\0\0\0\0\0\0\0\0\0\220"..., 16384) = 12605
read(3, ""..., 3779)                    = 0
close(3)                                = 0
init_module(0x804a060, 12605, "chunkSize=65536 algorithm=ls dis"...) = -1 ENOSYS (Function not implemented)
write(2, "insmod: error inserting 'r5r.ko':"..., 62insmod: error inserting 'r5r.ko': -1 Function not implemented
) = 62
exit_group(1)                           = ?
I tried to list all symbols defined in the running kernel (/proc/kallsyms) and then trying to find the symbols defined in the module with nm and checking which are missing from kallsyms but there are too many so I think it's a problem with my method to find them... can you tell me another hack for it?

Code:
$ nm r5r.ko | while read a b c; do if [ "$c" == "" ]; then simbolo=$b; else simbolo=$c; fi; lineas=$( grep $simbolo simbolos.txt | wc -l ); if [ $lineas == 0 ]; then echo Symbol $simbolo is not defined; fi; done
Symbol Queue is not defined
Symbol ____versions is not defined
Symbol __mod_algorithm56 is not defined
Symbol __mod_algorithmtype55 is not defined
Symbol __mod_author26 is not defined
Symbol __mod_capacity60 is not defined
Symbol __mod_capacitytype59 is not defined
Symbol __mod_chunkSize54 is not defined
Symbol __mod_chunkSizetype53 is not defined
Symbol __mod_description27 is not defined
Symbol __mod_diskFiles58 is not defined
Symbol __mod_diskFilestype57 is not defined
Symbol __mod_license25 is not defined
Symbol __mod_srcversion54 is not defined
Symbol __mod_vermagic5 is not defined
Symbol __module_depends is not defined
Symbol __param_algorithm is not defined
Symbol __param_arr_diskFiles is not defined
Symbol __param_capacity is not defined
Symbol __param_chunkSize is not defined
Symbol __param_diskFiles is not defined
Symbol __param_str_algorithm is not defined
Symbol __param_str_capacity is not defined
Symbol __param_str_chunkSize is not defined
Symbol __param_str_diskFiles is not defined
Symbol __this_module is not defined
Symbol algor is not defined
Symbol algorithm is not defined
Symbol chunkSize is not defined
Symbol cleanup_module is not defined
Symbol closeOpenFiles is not defined
Symbol diskFiles is not defined
Symbol diskNum is not defined
Symbol loadedChunk is not defined
Symbol majorNumber is not defined
Symbol param_array_ops is not defined
Symbol param_ops_charp is not defined
Symbol param_ops_int is not defined
Symbol r5r_loadChunkFromDisk is not defined
Symbol r5r_ops is not defined
Symbol r5r_request is not defined
Thanks in advance for any help you could provide.

Last edited by eantoranz; 04-13-2011 at 06:18 PM.
 
Old 04-15-2011, 03:24 AM   #2
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Don't you get an option, while compiling the kernel, named "Enable loadable module support"?
 
Old 04-15-2011, 08:12 AM   #3
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
Anisha, thanks for your feedback.

Well, well.... very interesting stuff from the module side. I don't know if the kernel I'm playing with was built with module support because I downloaded it from internet.... now, I just checked and lsmod on the UML guest shows this:

Code:
# lsmod
Opening /proc/modules: No such file or directory
And the file modules is not present on the /proc fs, indeed. Does that mean support for modules was not included when building that kernel?

Now, another thing I noticed is that when you build stuff like modules for the kernel, ARCH=um has to be set, right? So I tried building my module with ARCH=um included in the make command and now I get a lot of errors:

Code:
$ LANG=en make
make -C /lib/modules/2.6.38-2-generic/build M=/home/antoranz/proyectos/r5r/module modules ARCH=um
make[1]: Entering directory `/usr/src/linux-headers-2.6.38-2-generic'
  CC [M]  /home/antoranz/proyectos/r5r/module/r5r.o
In file included from /usr/src/linux-headers-2.6.38-2-generic/arch/x86/include/asm/vm86.h:130,
                 from /usr/src/linux-headers-2.6.38-2-generic/arch/x86/include/asm/processor.h:10,
                 from include/linux/prefetch.h:14,
                 from include/linux/list.h:7,
                 from include/linux/module.h:9,
                 from /home/antoranz/proyectos/r5r/module/r5r.c:8:
/usr/src/linux-headers-2.6.38-2-generic/arch/x86/include/asm/ptrace.h: In function 'user_mode':
/usr/src/linux-headers-2.6.38-2-generic/arch/x86/include/asm/ptrace.h:164: error: 'SEGMENT_RPL_MASK' undeclared (first use in this function)
/usr/src/linux-headers-2.6.38-2-generic/arch/x86/include/asm/ptrace.h:164: error: (Each undeclared identifier is reported only once
/usr/src/linux-headers-2.6.38-2-generic/arch/x86/include/asm/ptrace.h:164: error: for each function it appears in.)
/usr/src/linux-headers-2.6.38-2-generic/arch/x86/include/asm/ptrace.h:164: error: 'USER_RPL' undeclared (first use in this function)
/usr/src/linux-headers-2.6.38-2-generic/arch/x86/include/asm/ptrace.h: In function 'user_mode_vm':
/usr/src/linux-headers-2.6.38-2-generic/arch/x86/include/asm/ptrace.h:173: error: 'SEGMENT_RPL_MASK' undeclared (first use in this function)
/usr/src/linux-headers-2.6.38-2-generic/arch/x86/include/asm/ptrace.h:174: error: 'USER_RPL' undeclared (first use in this function)
In file included from /usr/src/linux-headers-2.6.38-2-generic/arch/um/include/asm/thread_info.h:12,
                 from include/linux/thread_info.h:56,
                 from /usr/src/linux-headers-2.6.38-2-generic/arch/um/include/asm/current.h:9,
                 from /usr/src/linux-headers-2.6.38-2-generic/arch/x86/include/asm/processor.h:15,
                 from include/linux/prefetch.h:14,
                 from include/linux/list.h:7,
                 from include/linux/module.h:9,
                 from /home/antoranz/proyectos/r5r/module/r5r.c:8:
/usr/src/linux-headers-2.6.38-2-generic/arch/um/include/asm/page.h: At top level:
/usr/src/linux-headers-2.6.38-2-generic/arch/um/include/asm/page.h:14: warning: "PAGE_SIZE" redefined
/usr/src/linux-headers-2.6.38-2-generic/arch/x86/include/asm/page_types.h:8: note: this is the location of the previous definition
/usr/src/linux-headers-2.6.38-2-generic/arch/um/include/asm/page.h:22: fatal error: sysdep/vm-flags.h: No such file or directory
compilation terminated.
make[2]: *** [/home/antoranz/proyectos/r5r/module/r5r.o] Error 1
make[1]: *** [_module_/home/antoranz/proyectos/r5r/module] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.38-2-generic'
make: *** [all] Error 2
I think there are more lessons to be learned before I'm able to load my module.

---------- Post added 04-15-11 at 10:12 AM ----------

Keep in mind I'm building the module on the host, not the UML guest.
 
Old 04-15-2011, 08:26 AM   #4
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Quote:
Originally Posted by eantoranz View Post
And the file modules is not present on the /proc fs, indeed. Does that mean support for modules was not included when building that kernel?
I have read, that the option of "support for loadable modules" is enabled by default, on distributions like OpenSuse, which I think is true, since I never faced any such problems before. I did guess that you must have downloaded the kernel from the net, anyway, now instead of wasting further time by "guessing" things, I think it is better to recompile the kernel ensuring that that option is enabled, just to be sure.

Quote:
Keep in mind I'm building the module on the host, not the UML guest.
I can't comment anything on this issue.

P.S.
lsmod works fine on Slackware 13.1 (default kernel)
and /proc/modules is also present here.

Last edited by Aquarius_Girl; 04-15-2011 at 08:28 AM.
 
1 members found this post helpful.
Old 04-15-2011, 08:29 AM   #5
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
Yes... sounds like I'll have to get my hands dirty and build my own kernel for UML. :-)

I'll feedback after I do it during the weekend. Thanks for your help!
 
Old 04-15-2011, 07:39 PM   #6
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
Well, well. I have already rebuilt the UML kernel by hand (2.6.38.3, by the way) and apparently the one I downloaded off internet didn't have module support built in because in the one I created I do have it.... so after rebuilding my module against the 2.6.38.3 source I was able to load it.... and now the UML kernel is facing an infinite loop after insmodding so I guess I have to start learning how to debug kernel modules. :-)

Anisha, as usual, very very helpful! Thanks!
 
Old 04-15-2011, 08:44 PM   #7
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Quote:
Originally Posted by eantoranz View Post
and now the UML kernel is facing an infinite loop after insmodding so I guess I have to start learning how to debug kernel modules.
You've put some loops in the kernel module? or you re not able to rmmod it? Anyway, new thread for a new question, BTW, the Kernel debugger is called KDB and its links has been included in the sticky in the Kernel section, if you need it.

Quote:
Originally Posted by eantoranz View Post
Anisha, as usual, very very helpful! Thanks!
I am happy I could help.
 
Old 04-15-2011, 09:36 PM   #8
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
It's a module problem.
 
  


Reply

Tags
error, insmod, kernel, module



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Qt "cannot call constructor for""a function-style cast remove the redundant ::QBrush" Peterius Linux - Software 4 11-24-2010 04:57 PM
Error Message "modprobe: QM_MODULES: Function not implemented" Gedwimor Slackware 3 03-07-2006 08:18 PM
FC4 install errors, "diabling IRQ #10" "nobody cares" error message??? A6Quattro Fedora 6 07-20-2005 12:49 PM
When "function pointer" meets "template"... I can't get rid of this compiling er cyu021 Linux - Software 3 12-17-2004 07:52 PM
"Function not implemented" error in call to "sem_open()" Krishnendu8 Linux - Newbie 1 06-07-2003 02:52 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration