doubt in GDT values

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.
Post Reply
extremecoder
Member
Member
Posts: 59
Joined: Tue May 23, 2006 11:00 pm

doubt in GDT values

Post by extremecoder »

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 ...
pcmattman
Member
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

Post by pcmattman »

Hi,
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 ?
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.

Keep in mind that the segmented model was around before paging, and as such it's a leftover from the past (backwards compatibility).
JohnnyTheDon
Member
Member
Posts: 524
Joined: Sun Nov 09, 2008 2:55 am
Location: Pennsylvania, USA

Re: doubt in GDT values

Post by JohnnyTheDon »

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: ^^^
Post Reply