Hi,
I think that I do understand paging, but it leaves two questions to me:
1) The wiki-page about paging doesn't mention this: Does each process need it's own page directory? (I think so but I'm not sure)
2) Does the kernel need a page-directory, too? And how does this work? Everytime control is passed to the kernel (by SysCalls or Interrupts), do I need to load the kernel-pd?
Regarding the higher-half kernel: Why needs the kernel to be mapped to user-processes? Is this to prevent the loading of kernel's page-directory? And how is the kernel-memory then protected from the user-processes? By the "user-/supervisor"-bit in the pages?
Greets,
kraks
Paging and higher half kernels
Re: Paging and higher half kernels
I'm not sure but it seems like the kernel doesn't need even a page, not to mention a page directory.
"Programmers are tools for converting caffeine into code."
Re: Paging and higher half kernels
Yes.kraks wrote:1) The wiki-page about paging doesn't mention this: Does each process need it's own page directory? (I think so but I'm not sure)
No. How can a user process call a SysCall or an interrupt if there is nothing there (the kernel) in that same directory address space to catch it?kraks wrote:2) Does the kernel need a page-directory, too? And how does this work? Everytime control is passed to the kernel (by SysCalls or Interrupts), do I need to load the kernel-pd?
The important parts of the kernel (or the entire kernel binary) should be mapped to kernel space in a processes address pace. When a new address space is created, it should be mapped to the new address space as well.
Thus it does need a page table (or several), not an entire page directory.
The kernel shouldnt use its own page directory. See above. The reason is the limitation of the architecture that only one page directory can be used at once. If you are in a user process address space, and the kernel is in another, there is no way to task switch or control that process at all because there would be no way to return back to kernel landkraks wrote:Regarding the higher-half kernel: Why needs the kernel to be mapped to user-processes? Is this to prevent the loading of kernel's page-directory? And how is the kernel-memory then protected from the user-processes? By the "user-/supervisor"-bit in the pages?
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Re: Paging and higher half kernels
Are you referring to a full 4GB/4GB split of the address space? If so this is possible, osx does it.neon wrote: If you are in a user process address space, and the kernel is in another, there is no way to task switch or control that process at all because there would be no way to return back to kernel land
- Colonel Kernel
- Member
- Posts: 1437
- Joined: Tue Oct 17, 2006 6:06 pm
- Location: Vancouver, BC, Canada
- Contact:
Re: Paging and higher half kernels
Sort of... There still needs to be part of the kernel mapped in each address space for system calls and interrupts. I think of the OS X "kernel address space" as just a big process that runs in ring 0.blound wrote:Are you referring to a full 4GB/4GB split of the address space? If so this is possible, osx does it.neon wrote: If you are in a user process address space, and the kernel is in another, there is no way to task switch or control that process at all because there would be no way to return back to kernel land
Top three reasons why my OS project died:
- Too much overtime at work
- Got married
- My brain got stuck in an infinite loop while trying to design the memory manager
Re: Paging and higher half kernels
Ok, thank you very much neon, I think I understand now