copy_from_user user space address mapping in the kernel page table.

mind entropy mindentropy at gmail.com
Mon Nov 3 01:11:34 EST 2014


On Mon, Nov 3, 2014 at 6:45 AM,  <Valdis.Kletnieks at vt.edu> wrote:
> On Sun, 02 Nov 2014 19:57:44 +0530, mind entropy said:
>>   In the copy_from_user when the user passes the virtual address is
>> the address mapped in the kernel page tables?
>
> Actually, a large part of the reason for copy_from_user()'s existence is
> to deal with the possibility that the page is *not* mapped at the moment
> because it's been swapped out (at which point we need to schedule a read
> operation for whatever backing store the page had (filesystem, swap, or
> zero-page for a never-before-referenced page), wait for it to arrive,
> and then nail it down so it doesn't leave out from under us before
> we finish the copy from the page.

Got this part. Now the mapping will be done in the kernel page
table,correct? i.e. in the
swapper_pg_dir and this would be what the MMU will use to walk,
correct? In short when the memcpy is
being done the page table will be the kernel pgd right?


>
> And of course, it's even *more* fun when the copy crosses a page boundary,
> and one or both of the pages isn't resident....
>
>>                                                In the function there is
>> a source is a user virtual address(<3GB) and the destination is the
>
> Only for 32-bit kernels.  x86_64 has a different memory layout.



More information about the Kernelnewbies mailing list