For what do I need GDT in long mode?

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
User avatar
Roman
Member
Member
Posts: 568
Joined: Thu Mar 27, 2014 3:57 am
Location: Moscow, Russia
Contact:

For what do I need GDT in long mode?

Post by Roman »

I don't understand it since GDT is used in segmentation, but long mode requires paging.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

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

Post 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.
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

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

Post 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.
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

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

Post by alexfru »

Thread Local Storage would be the most typical answer.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

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

Post 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.
Post Reply