Contents of CR3 register when a kernel thread is executed

limp johnkyr83 at hotmail.com
Wed Apr 20 18:23:18 EDT 2011


Thank you all for your replies,

> yes, "borrow" in the sense that:   kernel thread DOES NOT have any process
> context, and so it can be executed in any process context, and which ever
> process context it is executing, when u print the CR3 value, it will
belong
> to that process which the kernel thread is currently executing under.

I've read on LKD by Robert Love book the following:
"Because kernel threads do not have any pages in user-space, they do not
really
deserve their own memory descriptor and page tables. Despite this, kernel
threads
need some of the data, such as the page tables, even to access kernel
memory.
To provide kernel threads the needed data, kernel threads use the memory
descriptor
of whatever task ran previously"

I can't really tell which are the data which are needed by kernel threads
that the
book is talking about..By combining the above with the following (from the
same book): 

"The kernel thread can then use the previous process's page tables as
needed. Because
kernel threads do not access user-space memory, they make use of only the
information
in the address space pertaining to kernel memory, which is the same for all
processes."

I conclude the following:
A kernel thread uses only the address space of the previously scheduled user
process
pertaining to kernel memory for accessing kernel memory. Also, a kernel
thread is using
the virtual memory mechanism of user process to access kernel memory. That
is, it runs
on user-space but accesses *only* kernel memory, right? - i.e. it is
basically a user
process that access only Kernel memory - Why kernel threads cannot directly
access
kernel memory and use a mechanism used in user-space for accessing it?

Sorry for the many questions, any help will be greatly appreciated guys. 

P.S. Please correct me if I interpreted something wrong.

Regards,

John K.




More information about the Kernelnewbies mailing list