Re: Kernel vs user memory

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Bryan Donlan
Date: Thursday, March 18, 2010 - 5:28 pm

On Thu, Mar 18, 2010 at 20:10, Siddhartha Chhabra
<siddhartha.chhabra@gmail.com> wrote:

It depends.

If the kernel's doing a copy_from_user or copy_to_user family of calls
(ie, the calls used in system call handlers when accessing user space
buffers referenced in the arguments), this will trigger a page fault
exactly like the userspace process would, and the PF handler will then
deal with any copy on write or whatever may be needed. Of course, if a
userspace access wouldn't trigger a PF, the kernel access won't
either.

For the actual copy-on-write process itself, it would be a Bad Thing
to trigger a recursive page fault, so instead the kernel will directly
access the page via the direct mapped section of the address space -
this will never cause a PF (on x86, this may require creating a
temporary mapping for memory at a high physical address, but this
still won't be a PF as it will be set up before the first access).
Additionally, memory mapped IO involves direct DMA to/from pages that
are simultaneously in use by userspace - this won't cause a PF in
kernel mode either. Same with swap.

In short, some kernel accesses to user space do go through normal
channels which may or may not PF; other accesses will never PF. So
it's a bad idea to rely on all kernel accesses triggering a page
fault.

Hope this helps,

Bryan
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Kernel vs user memory, sidc7, (Fri Jan 16, 7:56 pm)
Re: Kernel vs user memory, Bryan Donlan, (Fri Jan 16, 9:16 pm)
Re: Kernel vs user memory, sidc7, (Fri Jan 16, 9:21 pm)
Re: Kernel vs user memory, Bryan Donlan, (Fri Jan 16, 10:26 pm)
Re: Kernel vs user memory, H. Peter Anvin, (Fri Jan 16, 11:26 pm)
Re: Kernel vs user memory, sidc7, (Fri Jan 16, 11:34 pm)
Re: Kernel vs user memory, H. Peter Anvin, (Fri Jan 16, 11:38 pm)
Re: Kernel vs user memory, sidc7, (Fri Jan 16, 11:42 pm)
Re: Kernel vs user memory, H. Peter Anvin, (Sat Jan 17, 12:27 am)
Re: Kernel vs user memory, sidc7, (Mon Jan 19, 1:03 pm)
Re: Kernel vs user memory, Bryan Donlan, (Thu Mar 18, 5:28 pm)
Re: Kernel vs user memory, Bryan Donlan, (Thu Mar 18, 6:06 pm)
Re: Kernel vs user memory, Siddhartha Chhabra, (Thu Mar 18, 6:29 pm)