Map memory to user, then map it back to kernel
Hi folks.
I am looking for a way to map a memory (allocated with get_free_pages()) from kernel space to user space, so that I will later be able to map it back with get_user_pages().
I tried remap_pfn_range(), but it didn't work as it assumes the memory being mapped is IO range (marking vma with VM_IO flag), while get_user_pages() works on regular memory.
Any ideas?
Thanks.
Alexander Sandler.
PS: Please CC to me.
Quoted 7 lines · sasha
Hi folks.
I am looking for a way to map a memory (allocated with
get_free_pages()) from kernel space to user space, so that I will later be able to map it back withget_user_pages().I tried
remap_pfn_range(), but it didn't work as it assumes the memory being mapped is IO range (marking vma withVM_IOflag), whileget_user_pages()works on regular memory.Any ideas?
VM_IO flag means not to swap this memory and don't do any side-effects bound with that IIRC.
If you want to mmap some memory in kernel to allow userspace to be able to read from it, just remap and don't care. I actually don't understand, what you mean by remapping it back to kernelspace, can you be more specific?
Caveat of get_free_pages is that it allocates physically contiguous memory and this may fail in later times, when the memory is not so free. You can use virtual memory to avoid this: vmalloc_32_user, remap_vmalloc_range, vfree.
regards,
Signature · 4 lines
<a href="http://www.fi.muni.cz/~xslaby/">Jiri Slaby</a> faculty of informatics, masaryk university, brno, cz e-mail: jirislaby gmail com, gpg pubkey fingerprint: B674 9967 0407 CE62 ACC8 22A0 32CC 55C3 39D4 7A7E