[lkml]   [2011]   [Oct]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: copy_*_user
I found that __copy_from_user_ll(void *to, const void __user *from,
unsigned long n) eventually calls some asm which use mov and rep on
the passed-in to & from pointers. This is in kernel mode and to & from
are virtual addresses ? are not the kernel accessing physical RAM
directly ( without pagetable ) ?



On Sat, Oct 22, 2011 at 10:50 PM, Américo Wang <> wrote:
> On Sun, Oct 23, 2011 at 1:06 AM, Xin Tong <> wrote:
>> I am investigating copy_from_user  and copy_to_user in linux under
>> i386. These two function both take a pointer with virtual address and
>> a pointer with physical address.
>> copy_from_user calls __copy_from_user_ll and copy_to_user  calls
>> __copy_to_user_ll. It make sense to me that __copy_to_user_ll converts
>> the virtual address to physical address using the current process's
>> page table.
> [...]
>> But it seems to be that __copy_from_user_ll  is not converted the
>> address at all before attempting to copy. Can someone help explain to
>> me why ?
> You missed that __copy_to_user_ll() only does that when CONFIG_X86_WP_WORKS_OK
> is not defined. And there is a comment right inside __copy_to_user_ll() said:
>               /*
>                 * CPU does not honor the WP bit when writing
>                 * from supervisory mode, and due to preemption or SMP,
>                 * the page tables can change at any time.
>                 * Do it manually.      Manfred <>
>                 */
> this is why it uses kmap_atomic()+memcpy() to copy the data.
> Also, all the addresses are virtual address.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2011-10-23 11:25    [W:0.071 / U:3.376 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site