I am writing my own boot loader and a kernel. I was reading through sample boot loaders, and when I was reading the Set GDT sections, i have found the following values ...
Kernel code and data segment, the base and limit was set to 0 - 0xFFFFFFFF
User code and data segment, the base and limit was set to 0 - 0xFFFFFFFF
I knew and understood the values for Access and Granularity ... but both user and kernel segment having same values is what I don't understand .. If my understanding of GDT is correct, the objective of segmentation is primarily for memory protection ... then when Kernel and User segments share the same base address and limit, then where exactly the segmentation comes into picture ?
Sorry, if i didn't understand the concepts very well ... but I am confused in this ...
doubt in GDT values
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Re: doubt in GDT values
Hi,
Keep in mind that the segmented model was around before paging, and as such it's a leftover from the past (backwards compatibility).
You are correct in that the objective of segmentation is for memory protection. However, it is far more popular nowadays to have flat segments covering the entire address space, with paging for the memory protection.If my understanding of GDT is correct, the objective of segmentation is primarily for memory protection ... then when Kernel and User segments share the same base address and limit, then where exactly the segmentation comes into picture ?
Keep in mind that the segmented model was around before paging, and as such it's a leftover from the past (backwards compatibility).
-
- Member
- Posts: 524
- Joined: Sun Nov 09, 2008 2:55 am
- Location: Pennsylvania, USA
Re: doubt in GDT values
Typically protection is done through paging. If you are going to use segmentation for protection, you will need to modify the segment addresses.
Because paging makes some features (mapping files into memory, swap space, etc.) much easier to implement and more effective, you should probably use paging if you ever plan to add these features to your OS.
EDIT: ^^^
Because paging makes some features (mapping files into memory, swap space, etc.) much easier to implement and more effective, you should probably use paging if you ever plan to add these features to your OS.
EDIT: ^^^