Build scatterlist covering a process' text segment?
Arvid Brodin
arvid.brodin at enea.com
Fri May 27 17:58:44 EDT 2011
Mulyadi Santosa wrote:
> On 26/05/2011, Arvid Brodin <arvid.brodin at enea.com> wrote:
>> Am I correct in that the addresses in (struct task_struct).mm->start_code
>> and
>> ->end_code belong to the address space of the process whose task_struct I'm
>> looking
>> at?
>
>
> I believe yes....
>
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.
Perhaps a better idea is to do_mmap() the "exe_file", (struct mm_struct).exe_file?
I'm still confused about this though:
1) do_mmap() returns unsigned long - not the void * expected by sg_set_buf().
Is this a sign that I'm again mixing different address spaces, or is it ok
just to cast this?
2) I believe do_mmap() maps a file into the address space of the "current process",
and that this address space is also the one used in kernel space at any moment.
Is this correct, or is there an additional, kernel-only memory space that I
should map the file to instead? If so, how do I do that?
Thanks,
Arvid Brodin
Enea Services Stockholm AB
More information about the Kernelnewbies
mailing list