User space memory

Prabhu nath gprabhunath at gmail.com
Tue Mar 12 09:08:05 EDT 2013


On Sun, Mar 10, 2013 at 11:30 PM, Christoph Seitz <c.seitz at tu-bs.de> wrote:

> Hi all,
>
> I have some problems allocation Memory the right way and use it in my
> kernel module.
>
> I use a char device for reading and writing from/to a pcie dma card.
> Especially the read function makes me some headache. The user allocates
> some memory with posix_memalign and call the read function on the
> device, so that the devices knows where to write to. My driver now uses
> get_user_pages() to pin the user pages. The memory has never been
> written or read by the user, so it's not yet in the RAM, right? And
> get_user_pages returns a valid number of pages, but for every page the
> same struct. (respectively the same pointer). Is there any way to ensure
> that the user pages are in the ram and get_user_pages returns a valid
> page array?
>

If you know the RAM physical address range you can figure out by doing the
following
    *page_to_pfn(page_ptr) << 12*;
    where page_ptr is a struct page * returned by get_user_pages().
   * page_to_pfn()* will return the pfn of the corresponding page frame and
left shifting by 12 bits will give you page frame base address.



> Regards
> Chris
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>

-- 
Regards,
Prabhunath G
Linux Trainer
Bangalore
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130312/6238f3f1/attachment.html 


More information about the Kernelnewbies mailing list