While the lgdt
instruction - used to set up the GDT - takes a m16&32/64
as an operand - the lldt
instruction takes a r/m16
operand.
Deciphering the jargon this means that lgdt
takes a pointer to a structure holding the GDT
size and base address.
On the other hand, lldt
take a segment selector - this segment selector must have the TI
(Table indicator) field set to 0 to point into the GDT
.
Long story short the LDT
is not set up with a base address and a size like the GDT
but with a segment descriptor in the GDT - so it depends on the GDT
.
The type of the segment selected by the segment selector given to lldt
must be of type LDT (decimal value 2).
If any of the conditions above fails a #GP is raised.
For a given hardware thread and a given point in time, there can be only one LDT
and one GDT
active.
The OS can, however, change the active LDT
or GDT
(rare) later - based on its own policy (e.g. for specific processes).
However, an OS rarely changes the GDT
entirely and usually it pre-fill it with all the segment descriptors it needs - including all the necessary LDT
s.
In any case, the GDT
can hold multiple LDT
segment descriptors - but only one is active at any given time, per hardware thread.