Page 1 of 1

For what do I need GDT in long mode?

Posted: Mon Jun 09, 2014 7:30 am
by Roman
I don't understand it since GDT is used in segmentation, but long mode requires paging.

Re: For what do I need GDT in long mode?

Posted: Mon Jun 09, 2014 12:27 pm
by iansjack
Paging and segmentation are not mutually exclusive. You still use segment descriptors in long mode, although they are a little different. The programming manual explains it.

Re: For what do I need GDT in long mode?

Posted: Mon Jun 09, 2014 2:21 pm
by Gigasoft
Roman wrote:I don't understand it since GDT is used in segmentation, but long mode requires paging.
This syllogism is one that it is doubtful whether Aristotle would approve of. There seems to be some hidden premise here. Would you care to explain what prompted you to think there would be a problem with logically reconciling those two statements?

As for the answer to the question itself, the GDT is used in the exact same way in long mode as in protected mode, except that a previously unused bit now indicates that a code segment is to be run in 64 bit mode. However, when in 64 bit mode, it should be noted that segment bases and limits are not applied except for the FS and GS bases.

Re: For what do I need GDT in long mode?

Posted: Tue Jun 10, 2014 3:45 am
by alexfru
Thread Local Storage would be the most typical answer.

Re: For what do I need GDT in long mode?

Posted: Tue Jun 10, 2014 11:36 am
by Candy
You use the GDT in long mode for:

- TSS, to have a valid interrupt stack table that allows you to turn on the red zone again

And that's pretty much it.