* Paging and system calls
@ 2003-04-28 12:48 Kasim Sinan Yildirim
2003-04-28 13:14 ` Jamie Lokier
0 siblings, 1 reply; 2+ messages in thread
From: Kasim Sinan Yildirim @ 2003-04-28 12:48 UTC (permalink / raw)
To: linux-newbie, linux-kernel
Hi,
I am working on a small kernel and i am examining the source code of the
linux.
Since every task has its own page tables, when task switching occurs, the
cr3 field of the TSS is put to the cr3 register which is page directory base
register.
İn my operating system, when a system call occurs, the user level code jumps
to system level code by changing its selectors to KernelCS and KernelDS. But
at this point, the cr3 register still points to the page directory of the
user process. So, the actual code that is pointed by kernel level page
directory is not equal to the user level page directory entry. As a result ,
the system fails.
How this problem is solved in Linux? Have you got any solution to my problem?
Thanks...
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Paging and system calls
2003-04-28 12:48 Paging and system calls Kasim Sinan Yildirim
@ 2003-04-28 13:14 ` Jamie Lokier
0 siblings, 0 replies; 2+ messages in thread
From: Jamie Lokier @ 2003-04-28 13:14 UTC (permalink / raw)
To: Kasim Sinan Yildirim; +Cc: linux-newbie, linux-kernel
Kasim Sinan Yildirim wrote:
> ?n my operating system, when a system call occurs, the user level code jumps
> to system level code by changing its selectors to KernelCS and KernelDS. But
> at this point, the cr3 register still points to the page directory of the
> user process. So, the actual code that is pointed by kernel level page
> directory is not equal to the user level page directory entry. As a result ,
> the system fails.
>
> How this problem is solved in Linux? Have you got any solution to my problem?
In Linux, there is no separate kernel page directory. The the upper
1GB (configurable) of each process address space holds the same kernel
level page mappings in _all_ page directories, so process context
switches don't change those mappings.
The exception is vmalloc() kernel mappings. For these the kernel area
of each process address spaceis filled in lazily by the page fault
handler. Once filled, these also have the same values in all contexts.
This is why user space can only address 0-3GB of address space in
Linux. It has the huge benefits that (a) system calls and interrupts
don't need to switch page directories and incur TLB flush costs; (b)
the kernel code can easily read and write user space.
It gets a bit more complex when dealing with more than about 1GB RAM
(actually the threshold is some imprecise 10's of meg below that.
Then PAE page tables are used instead, and you have kmap() mappings in
the kernel area. But you probably aren't using PAE in your operating
system.
-- Jamie
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-04-28 13:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-28 12:48 Paging and system calls Kasim Sinan Yildirim
2003-04-28 13:14 ` Jamie Lokier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).