When a program moves data into a selector register, that data becomes a selector and the processor fetches the content of the appropriate entry from the specified table into onboard registers which are not accessible to the programmer. The processor verifies the validity of the attempted access to the memory whenever a selector register is updated. This makes the protection overhead occur as part of the instruction which modifies a selector register, but eliminates it for further use of the selector.
Note: If the RPL of the SS register is not the same as CPL, or if an attempt is made to move the null selector into SS, a general protection exception occurs.
etc etc
30 | | | | 36 (pl=2) limit
|--------------| |--------------| ---------- ==x==
LDTR = 28 | |--- | | 2F | | |
|--------------| | |--------------| | | |
20 | | | | | 27 | | |
|--------------| | |--------------| | | |
18 | | | DS | | 1F-- |==x== | |
|--------------| | |--------------| | | | | |
TR = 10 | | | | | 17 | | | | |
|--------------| | |--------------| | | offset | |
08 | | | | | 0F | | | | |
|--------------| | |--------------| | | | | |
00 | useless | |base| | 07 |base | | | |
GDTR ----> -------------- ---> -------------- ----> ---------- ---
GDT LDT
Note: The first descriptor in the GDT is reserved, by definition, and cannot be used. Any selector which would reference it is called the NULL SELECTOR; possible values are 0000, 0001, 0002, and 0003.
By definition, the null selector may be placed in DS, ES, FS, or GS, but any attempt to form an address with it is a general protection fault.
Note: The LDTR is a register that contains a selector. It can be accessed only by privilege level 0 instructions. It must contain a selector that references the GDT, and a descriptor whose "type" is LDT.
Note: It is not unusual for a GDT selector to describe the same storage as an LDT selector does. In OS2 2.x, application selectors in the GDT happen to describe one 448 Meg segment, not just a 64K segment like the LDT selectors describe. The linear address assigned to each LDT descriptor is extremely convenient for changing one form of an address to another, called thunking, which will be discussed later.