<div dir="ltr"><div><div><div>HI, <br><br></div>You cannot do this since mmap function is used to map something to your user space address.<br></div>You can remap kernel memory to user space by remap_pfn_range than access the kernel memory by using the mapped <br>
user space address.<br><br></div>MH<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Dec 26, 2013 at 3:42 PM, Yu Bi <span dir="ltr">&lt;<a href="mailto:lazysmartegg@gmail.com" target="_blank">lazysmartegg@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi,</div><div>   <span style="line-height:16.666667938232422px;font-size:13.333333969116211px;font-family:Arial,&#39;Liberation Sans&#39;,&#39;DejaVu Sans&#39;,sans-serif">I try to mmap a file in a linux kernel module. I have tried to use the function do_mmap_pgoff</span><span style="line-height:16.666667938232422px;font-size:13.333333969116211px;font-family:Arial,&#39;Liberation Sans&#39;,&#39;DejaVu Sans&#39;,sans-serif">. But the address returned is memory virtual address in current process&#39; user space, i.e., below the kernel boundary. Instead, I want to map the file in the kernel space and get the kernel virtual address of the mapped region. Is there any kernel API in Linux support this operation? Or I have to reimplement a kernel mmap version ? </span></div>

<div>  But reimplement a kernel version mmap() is  not easy I guess. Do you have any idea? </div><div>   </div><div><br></div><div>      </div><div>   </div><div>   </div></div>
<br>_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
<br></blockquote></div><br></div>