Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


Closed Thread
  Search this Thread
Old 09-11-2008, 08:44 AM   #1
LQ Newbie
Registered: Sep 2008
Posts: 7

Rep: Reputation: 0
how to mmap in kernel module

I want to mmap a file from kernel module. I tried using do_mmap it works but only when i do mmap and access memory in same module.
I want to map a memroy in one module and then will call a function( which access this pointer where memory is mapped) from another module.

Now i have 2 modules first say mmap_mod.c and second say tempmod.c

in mmap_mod.c i call do_mmap in init module and take address in a pointer say mem_ptr. Now same module has another function say get_param, this function just access mem_ptr and and print its content. I have exported this function so i can access it from other module.

Now in tempmod.c i just call this get_param function (exported from mmap_mod.c) and expect data in mmaped region to get printed.

it this case it prints kernel stack and gives error "Unable to handle kernel paging request at virtual memory" It fails where i try to access mem_ptr.

same thing if i do mmap in get_param then everything works fine.

I dont know why this is happening.

am i doing something wrong? or does any one have some other solution if yes please help me out.

Old 09-15-2008, 11:18 PM   #2
LQ Newbie
Registered: Jul 2008
Posts: 18
Blog Entries: 1

Rep: Reputation: 0

If my analysis is right,you are trying to access a memory that is 'swappable'.The pages you are trying to acces may have got swapped and may not be on the RAM when you try to access them.So take a close look at the memory region you are mapping and see that it is in the 'kernel memory' not the user memory.The problem lies with the memory region you selected to map.Please reply with the results and feed back.

Thanks & regards

Closed Thread

kernel, mmap, mode

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
how to mmap file in kernel module shreyasw Linux - Newbie 3 09-25-2008 01:04 AM
linux driver how to mmap many kernel address to user space soararing Programming 1 05-22-2008 05:32 AM
[Error] Kernel Module : No kernel module build environment saman007uk Debian 7 09-09-2006 06:34 PM
kernel BUG at mmap.c:1159! housemusic42 Linux - General 3 03-22-2004 03:49 PM
kernel module ignorant newbie looking for any one with kernel module knowledge cpoet Slackware 4 11-24-2003 09:37 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:44 AM.

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