Hi. Im having problems understanding the segmentation mechanism in the x86 architecture.
So here is what i know:
There are 6 segment registers for example CS and SS.
The hold a 13 bit pointer, and indicator if the pointer is about LDT or GDT, and 2 bit requested privilege level. Now when i issue a jump to CS:EAX, this is what is happening(if the TI is set to GDT):
the 13 bit offset from CS is beeing taken and added to the value of GDTR(the register that holds a pointer to the base of Global descriptor table), so that a particular sement descriptor can be found. Then the 32 bit adress of the segment is taken from the segment descriptor and eax is added to it, and we get a linear adress(for now, before i learn paging i think of them as physical adresses).
But what i don't understand or rather couldn't find any info about is the LDT. From what i read on the internet they say that if TI is set in a segment register, the 13 bit offset now applies to LDT instead of GDT. But it is not quite true. The pointer in the segment register is actually an offset inside the GDT that , and it is an actual segmnet descriptor that holds the adress of LDT. But what is LDTR for then? And how does one know what offset to use within the LDT if the only one has been used to get to the LDT?
Also, another question. I asked about it on the SAX. I heard that a LDT is assigned per process, but that isnt quite true either. They are assigned only for some processes. How do i know which ones?
I have a few more questions but i think i will postpone them untill my current problems are resolved.
So here is what i know:
There are 6 segment registers for example CS and SS.
The hold a 13 bit pointer, and indicator if the pointer is about LDT or GDT, and 2 bit requested privilege level. Now when i issue a jump to CS:EAX, this is what is happening(if the TI is set to GDT):
the 13 bit offset from CS is beeing taken and added to the value of GDTR(the register that holds a pointer to the base of Global descriptor table), so that a particular sement descriptor can be found. Then the 32 bit adress of the segment is taken from the segment descriptor and eax is added to it, and we get a linear adress(for now, before i learn paging i think of them as physical adresses).
But what i don't understand or rather couldn't find any info about is the LDT. From what i read on the internet they say that if TI is set in a segment register, the 13 bit offset now applies to LDT instead of GDT. But it is not quite true. The pointer in the segment register is actually an offset inside the GDT that , and it is an actual segmnet descriptor that holds the adress of LDT. But what is LDTR for then? And how does one know what offset to use within the LDT if the only one has been used to get to the LDT?
Also, another question. I asked about it on the SAX. I heard that a LDT is assigned per process, but that isnt quite true either. They are assigned only for some processes. How do i know which ones?
I have a few more questions but i think i will postpone them untill my current problems are resolved.