Putting kernel space at 0x00000000 -> 0x3FFFFFFF ?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Adek336

Re:Putting kernel space at 0x00000000 -> 0x3FFFFFFF ?

Post by Adek336 »

That is how my kernel, panalix works - I use memory from 1Mb to 2Gb, and, I must say it works very well. But, certainly it makes things harder to run v86 tasks
Perica
Member
Member
Posts: 454
Joined: Sat Nov 25, 2006 12:50 am

Re:Putting kernel space at 0x00000000 -> 0x3FFFFFFF ?

Post by Perica »

..
Last edited by Perica on Sun Dec 03, 2006 9:27 pm, edited 1 time in total.
Tim

Re:Putting kernel space at 0x00000000 -> 0x3FFFFFFF ?

Post by Tim »

Perica wrote: (virtual-8086 mode won't be used for any reason what-so-ever)
Not supporting high-res graphics (VESA) or power management (APM)?
Perica
Member
Member
Posts: 454
Joined: Sat Nov 25, 2006 12:50 am

Re:Putting kernel space at 0x00000000 -> 0x3FFFFFFF ?

Post by Perica »

..
Last edited by Perica on Sun Dec 03, 2006 9:27 pm, edited 1 time in total.
HOS

Re:Putting kernel space at 0x00000000 -> 0x3FFFFFFF ?

Post by HOS »

i'm sure this is a stupid question... but could somebody tell me why kernel/application address space must be in completely separate virtual addresses? is it because system calls do not really change the address space and therefore need to be able to see the kernel's memory and the current application's memory all at once? or is it for some other reason?

tia
Tim

Re:Putting kernel space at 0x00000000 -> 0x3FFFFFFF ?

Post by Tim »

Right. Kernel memory must be present in every address space because every process must be able to call the kernel. Kernel memory is kept separate from user memory because kernel memory must not be accessible from ring 3 code, for security.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Putting kernel space at 0x00000000 -> 0x3FFFFFFF ?

Post by Candy »

HOS wrote: i'm sure this is a stupid question... but could somebody tell me why kernel/application address space must be in completely separate virtual addresses? is it because system calls do not really change the address space and therefore need to be able to see the kernel's memory and the current application's memory all at once? or is it for some other reason?

tia
Kernel memory must be present in every address space because every process must be able to call the kernel
As for this all, Tim is correct in just about all aspects, but 1.

It is not REQUIRED to have all that memory in all user address spaces. It is very useful though.

To access the kernel you only need a way to access it. That is through the IDT, through external interrupts (Linus forbid), through some arcane ways you devise yourself, or through normal switching of process contexts. However, all of these have a huge overhead. You need to poll in some cases, other cases have huge latencies so using these methods is very unpractical.

As the Intel engineers know their bit of stealing, and do some R&D too, they know of better ways. If you map in the kernel in each address space, then the kernel pages will always be available. To execute a kernel call, no matter how hard, would be trivial, since it's all there. They also thought about the security, because it's not a good thing to let user code write to kernel space (protection of tasks from each other is one of the major points of modern OSes, but it's hard).

Therefore, most people decide for a section of the memory space to be kernel only space. This allows for very quick switching between user and kernel space, and as such, fast operating systems on a whole. The fastest alleged entry I've seen is the AMD SYSCALL interface with 3 cycles latency (afaik). After that comes SYSENTER (Intel + 32-bit AMD's) with about 5, and after those follow interrupts with 10+ latency (afaik again).

It's also done because modern processors (something like ppro+ or so) allow pages to be global, which means they don't lose their tlb's on a cr3 change. That also speeds up the process.
Post Reply