From mboxrd@z Thu Jan 1 00:00:00 1970 From: mulyadi.santosa@gmail.com (Mulyadi Santosa) Date: Sat, 28 May 2011 16:42:56 +0700 Subject: Build scatterlist covering a process' text segment? In-Reply-To: <4DE01E94.8000505@enea.com> References: <4DDAE865.6000608@enea.com> <4DDD663C.4060201@enea.com> <4DE01E94.8000505@enea.com> Message-ID: To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org Hi... On Sat, May 28, 2011 at 04:58, Arvid Brodin wrote: > Ok. And looking at e.g. sg_set_buf(), the scatterlist expects a kernel virtual > address (it uses virt_to_page() on its "buf" parameter internally, which > requires a kernel virtual adress, if I understand correctly). > > There seems to be no way to map process adresses to kernel addresses. (Well I > guess one could follow the page tables to get the physical page, and then map > back to kernel space, but this only works as long as the memory is paged in.) > Please correct me if I'm wrong. I am not good at it, but I think at the first place, you might use get_user_pages() (take a look here :http://lxr.linux.no/#linux+v2.6.39/mm/memory.c#L1703) then once you get the pointer to the pages (and making sure they're pinned by get_user_pages), I think you just need to use kmap(). I suggest to really observe that scatter gather function and see if address in kernel address space is really needed.... if not, you can avoid using kmap() completely. -- regards, Mulyadi Santosa Freelance Linux trainer and consultant blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com