<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Arial","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Arial","sans-serif";
        color:windowtext;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="2050" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif";
color:black'>I'm using linux kernel 2.6.29.1 I've been using the mmap system
call to map 4MB of contiguous kernel memory (RAM), obtained by get_free_pages
with order == 10, to user space. One implementation I have uses
remap_pfn_range(), its seems to work ok, I do have other issues I just want to
make sure its reasonable to use the reamp_pfn_range call for what I am doing.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif";
color:black'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif";
color:black'>Now in LDD3 it says not to use the remap_pfn_range() call because
it only gives access to reserved pages and physical addresses above the top of physical
memory. LDD3 makes reference to the using the nopage and notes about
maintaining proper reference counts with clusters of pages. The material
in the book on this issue seems dated.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif";
color:black'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif";
color:black'>Is there still a limitation with using remap_pfn_range() remap
kernel ram to user space?<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif";
color:black'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif";
color:black'>So in a test driver I made using the "fault" (previously
called nopage) method for that purpose. <br>
<br>
here's a snipet of the fault callback;<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif";
color:black'><o:p> </o:p></span></p>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt;
font-family:"Verdana","sans-serif";color:blue'>offset = vmf->pgoff <<
PAGE_SHIFT;<br>
if( offset > dev->dma_buff_size)<br>
{<br>
printk("ds3b3_vm_fault: SIGBUS - my_offset: %#x vmf_pgoff: %#x page_shift:
%i \n",<br>
offset, vmf->pgoff, PAGE_SHIFT);<br>
return VM_FAULT_SIGBUS;<br>
}<br>
<br>
addr = (char *)vma->vm_start;<br>
addr += offset;<br>
<br>
page = virt_to_page( addr );<br>
<br>
get_page(page);<br>
vmf->page = page;<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt;
font-family:"Verdana","sans-serif";color:black'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif";
color:black'>When the application loads the module the following is printed on
the console;<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif";
color:black'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif";
color:black'> My kprintfs
from the fault handler:<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt;
font-family:"Verdana","sans-serif";color:blue'><4>ds3b3_vm_fault: entered
- vma->vm_start: 0x48000000 vma->vm_end 0x483fd000<br>
<4>ds3b3_vm_fault: entered - vma->vm_flags: 0x820fb vma->vm_pgoff
0x0<br>
<4>ds3b3_vm_fault: entered - vmf->flags: 0x1 vmf->pgoff 0x0
vmf->virtual_address: 0x48000000<br>
<4>ds3b3_vm_fault: SUCCESS - vmf->page: 0xc13d1000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt;
font-family:"Verdana","sans-serif";color:blue'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif";
color:blue'><o:p> </o:p></span></p>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt;
font-family:"Verdana","sans-serif"'>Kernel output to the console<span
style='color:blue'>:<br>
<1>BUG: Bad page map in process dcb pte:880004d2 pmd:0c5ec400<br>
<1>addr:48000000 vm_flags:000820fb anon_vma<img width=15 height=15
id="Picture_x0020_1" src="cid:image001.gif@01CA2A1A.37C11F00"
alt="http://http.cdnlayer.com/lq/images/questions/images/smilies/frown.gif">null)
mapping:ce4927d0 index:0<br>
<1>vma->vm_ops->fault: ds3b3_vm_fault+0x0/0xf8 [ds3b3]<br>
<1>vma->vm_file->f_op->mmap: ds3b3_nopage_mmap+0x0/0x4c [ds3b3]<br>
<4>Call Trace:<br>
<4>[cd659d80] [c0006bc0] show_stack+0x44/0x16c (unreliable)<br>
<4>[cd659dc0] [c00627c8] print_bad_pte+0x140/0x1cc<br>
<4>[cd659df0] [c00628d0] vm_normal_page+0x7c/0xb4<br>
<4>[cd659e00] [c00630b4] follow_page+0xf4/0x1f0<br>
<4>[cd659e20] [c00645e4] __get_user_pages+0x130/0x3ec<br>
<4>[cd659e80] [c0064b28] make_pages_present+0x8c/0xc4<br>
<4>[cd659e90] [c0066780] mlock_vma_pages_range+0x74/0x9c<br>
<4>[cd659eb0] [c0068efc] mmap_region+0x1dc/0x3c8<br>
<4>[cd659f10] [c00037b8] sys_mmap+0x78/0x100<br>
<4>[cd659f40] [c000e558] ret_from_syscall+0x0/0x3c<o:p></o:p></span></span></p>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt;
font-family:"Verdana","sans-serif";color:black'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif";
color:black'>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 or do I need to set
a specific vm flag(s)? <br>
<br>
<br>
Any comments or advice would be appreciated.<br>
<br>
thanks<o:p></o:p></span></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Times New Roman","serif";
color:blue'>John Price <</span><span style='font-size:12.0pt;
font-family:"Times New Roman","serif"'><a
href="blocked::mailto:john.p.price@l-3com.com"
title="blocked::mailto:john.p.price@l-3com.com"><span style='font-size:10.0pt;
color:blue'>john.p.price@l-3com.com</span></a></span><span style='font-size:
10.0pt;font-family:"Times New Roman","serif";color:blue'>> </span><span
style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Times New Roman","serif";
color:blue'>781-970-1743<br>
L-3 Communications<br>
Security & Detection Systems Division, <br>
10E Commerce Way, Woburn, MA 01801</span><o:p></o:p></p>
</div>
</body>
</html>