Until now i developed my kernel as a 'first half' kernel. But most important systems like for example linux use an higher half kernel. And, if i understand, they use this solution to map the kernel in each process.
I've tried to make (using the tutorial) my kernel higher half with the GDT trick. Now of course i must rewrite my physics memory allocator or i have to modify it to make it run.
But now, if i use a kernel mapped 1:1, when a process must do a system call, for example, is't it easier to disable the paging? the kernel is mapped 1:1, and it can generate the physic address using the page directory of the process, if it is need. And, of course, it can access to all memory because the paging is disable. And also a process can use all the 4GB of address and it isn't limited by the kernel.
I think that there are some other good reason to do this (the higher half kernel) but for the moment i can't see them.
Maybe i wrong to buy the Silberschatz book, but there isn't nothing about higher half kernel and something similar. i also hope that you can understand what i mean in this post..
Thank's for the answer!!
Higher Half Kernel With GDT
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Higher Half Kernel With GDT
You can have the kernel in each address space with whatever method - in fact you need paging if you ever want the kernel out of an address space (the alternative is not having a kernel)Srowen wrote:And, if i understand, they use this solution to map the kernel in each process.
Please read again on Paging and a ton of other wiki pages to get your facts straightBut now, if i use a kernel mapped 1:1, when a process must do a system call, for example, is't it easier to disable the paging? the kernel is mapped 1:1, and it can generate the physic address using the page directory of the process, if it is need. And, of course, it can access to all memory because the paging is disable. And also a process can use all the 4GB of address and it isn't limited by the kernel.
- The CPU maps virtual addresses to physical addresses. Not the kernel.
- A Higherhalf kernel is deliberately not mapped 1:1. Disabling and enabling paging costs performance. You lose any advantage paging can give to your kernel if you do.
- The kernel is always using a part of memory. Thus an application can never get all the address space.
- Processes should be limited by the kernel. You don't want to crash things, right?
- Location independent of physical memoryI think that there are some other good reason to do this (the higher half kernel) but for the moment i can't see them.
- Applications can use a predefined section of space
Nothing about higherhalf kernels? There's at least TWO pages on the wiki (and you just said you found at least one)Maybe i wrong to buy the Silberschatz book, but there isn't nothing about higher half kernel and something similar. i also hope that you can understand what i mean in this post..
To have me and everybody else make more sense of your post, follow these rules, they help getting the right message to come across (they are forum rules for good reason too )
Oh and please, please, learn to type proper English.
- gravaera
- Member
- Posts: 737
- Joined: Tue Jun 02, 2009 4:35 pm
- Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.
Re: Higher Half Kernel With GDT
Hi: I'm assuming that the boldened line meant that you're talking about an identity mapped kernel that's been loaded into the higher half/quarter. But this makes the assumption that everyone has at least 2 or 3 GB of memory.Srowen wrote: But now, if i use a kernel mapped 1:1, when a process must do a system call, for example, is't it easier to disable the paging? the kernel is mapped 1:1, and it can generate the physic address using the page directory of the process, if it is need. And, of course, it can access to all memory because the paging is disable. And also a process can use all the 4GB of address and it isn't limited by the kernel.
I think that there are some other good reason to do this (the higher half kernel) but for the moment i can't see them.
If you weren't, and you were referring to a kernel that is loaded at both phys and virtual 1MB and instead of being virtually loaded at a higher address, to allow for fast sys calls, you just disable paging and do the operation, and then return to paged mode, this would mean that:
1. Process A is running in its own address space. Process A executes an interrupt for a syscall. The interrupt, as listed in the IDT switches to the kernel Segment. The interrupt stub loads the kernel data Segments. The interrupt Stub jumps into the kernel to handle the interrupt.
2. IF you decide to switch off paging now, since your kernel was linked to virtual 1MB it would work, yes, but this brings the extra overhead of having to reload the pagedirectory for the current process for EACH system call. Ie: If an application execute approx 8 system calls per timeslice, then you're cut its performance severely. However, if you had loaded your kernel to the Higher half/quarter, and just executed the interrupt code, then iret'd, you would only have had to pretty much execute the syscall. Your kernel is mapped into all address spaces, so there's no need to switch to an identity mapped PageDirectory, or disable paging. Continuing...
3. By whatever convention you develop, you return the value necessary to the user. The application continues. Two microseconds later, it calls for another system function...
I hope I helped you understand why folks prefer to use a virtual higher half kernel as opposed to a kernel in its own, identity mapped address space. I got the hang of the idea just last week, and have had to begin to redesigning yet again.
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
Re: Higher Half Kernel With GDT
Sorry i don't explain myself very well.. thank's gravaera for the answer.. and i also understand that if i want to disable paging it is the first think to do when an interrupt come.. the higher half solution is better...
and also this think can be added to the wiki that there is only few lines..
and also this think can be added to the wiki that there is only few lines..