Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Linux - Kernel This forum is for all discussion relating to the Linux kernel.


  Search this Thread
Old 08-29-2009, 09:54 AM   #1
LQ Newbie
Registered: Aug 2009
Posts: 1

Rep: Reputation: 0
mapping contiguous kernel memory to user space


I'm using linux kernel I've been using the mmap system call to map kernel memory (RAM), obtained by get_free_pages, to user space. My driver uses the "fault" (previously called nopage) method for that purpose.

here's a snipet of the fault callback;
offset = vmf->pgoff << PAGE_SHIFT;
if( offset > dev->dma_buff_size)
printk("ds3b3_vm_fault: SIGBUS - my_offset: %#x vmf_pgoff: %#x page_shift: %i \n",
offset, vmf->pgoff, PAGE_SHIFT);

addr = (char *)vma->vm_start;
addr += offset;

page = virt_to_page( addr );

vmf->page = page;
When the application loads the module the following is printed on the console;
<4>ds3b3_vm_fault: entered - vma->vm_start: 0x48000000 vma->vm_end 0x483fd000
<4>ds3b3_vm_fault: entered - vma->vm_flags: 0x820fb vma->vm_pgoff 0x0
<4>ds3b3_vm_fault: entered - vmf->flags: 0x1 vmf->pgoff 0x0 vmf->virtual_address: 0x48000000
<4>ds3b3_vm_fault: SUCCESS - vmf->page: 0xc13d1000
<1>BUG: Bad page map in process dcb pte:880004d2 pmd:0c5ec400
<1>addr:48000000 vm_flags:000820fb anon_vmanull) mapping:ce4927d0 index:0
<1>vma->vm_ops->fault: ds3b3_vm_fault+0x0/0xf8 [ds3b3]
<1>vma->vm_file->f_op->mmap: ds3b3_nopage_mmap+0x0/0x4c [ds3b3]
<4>Call Trace:
<4>[cd659d80] [c0006bc0] show_stack+0x44/0x16c (unreliable)
<4>[cd659dc0] [c00627c8] print_bad_pte+0x140/0x1cc
<4>[cd659df0] [c00628d0] vm_normal_page+0x7c/0xb4
<4>[cd659e00] [c00630b4] follow_page+0xf4/0x1f0
<4>[cd659e20] [c00645e4] __get_user_pages+0x130/0x3ec
<4>[cd659e80] [c0064b28] make_pages_present+0x8c/0xc4
<4>[cd659e90] [c0066780] mlock_vma_pages_range+0x74/0x9c
<4>[cd659eb0] [c0068efc] mmap_region+0x1dc/0x3c8
<4>[cd659f10] [c00037b8] sys_mmap+0x78/0x100
<4>[cd659f40] [c000e558] ret_from_syscall+0x0/0x3c
I do not understand why the first page of the buffer is determined to be a bad page? Do I need to perform any initialization to the buffer pages after allocation and prior to the application calling mmap?

Any comments or advice would be appreciated.



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
pgprot_noncached when mapping io memory to user space marc_ba Linux - Kernel 1 06-20-2011 01:08 PM
Sharing Memory between driver space and user space ian b davidson Programming 1 11-10-2008 07:35 AM
mmap: contiguous mapping of several files yurii Programming 5 05-28-2008 04:03 PM
mapping contiguous kernel memory to user space nili Linux - Kernel 4 01-29-2008 02:43 PM
memory mapping without being super user usagirl126 Linux - Security 7 02-20-2004 11:40 PM > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 04:32 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