Segment Selector: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
Overhaul article. Its rather short so I don't think any of the prior contents survived.
m Reverted edits by Melina148 (talk) to last revision by Khaledhammouda
 
(10 intermediate revisions by 5 users not shown)
Line 1: Line 1:
A '''Segment Selector''' is a 16-bit binary data structure that is used on x86 CPUs in '''[[Protected Mode]]''' and '''[[Long Mode]]'''. Its value identifies a segment in either the '''[[Global Descriptor Table]]''' or a '''Local Descriptor Table'''. It contains three fields and is used in a variety of situations to interact with '''[[Segmentation]]'''.
A '''Segment Selector''' is a 16-bit binary data structure specific to the [[IA32_Architecture_Family|IA-32]] and [[X86-64|x86-64]] architectures. It is used in '''[[Protected Mode]]''' and '''[[Long Mode]]'''. Its value identifies a segment in either the '''[[Global Descriptor Table]]''' or a '''[[Local Descriptor Table]]'''. It contains three fields and is used in a variety of situations to interact with '''[[Segmentation]]'''.


For more information, see '''Section 3.4.2: Segment Selectors''' and '''Figure 3-6: Segment Selector''' of the Intel Software Developer Manual, Volume 3-A.
For more information, see '''Section 3.4.2: Segment Selectors''' and '''Figure 3-6: Segment Selector''' of the Intel Software Developer Manual, Volume 3-A.
Line 15: Line 15:
|'''RPL'''
|'''RPL'''
|}
|}
* '''Index:''' The Index of the '''GDT''' or '''LDT''' entry referenced by the selector. Since '''[[Global Descriptor Table#Segment Descriptor|Segment Descriptors]]''' are 8 bytes in length, the value of '''Index''' is never unaligned and contains no data in the lowest 3 bits. As such '''Index''' in a segment selector is ''not'' shifted from a standard 16-bit representation.
* '''Index:''' Bits 3-15 of the Index of the '''GDT''' or '''LDT''' entry referenced by the selector. Since '''[[Global Descriptor Table#Segment Descriptor|Segment Descriptors]]''' are 8 bytes in length, the value of '''Index''' is never unaligned and contains all zeros in the lowest 3 bits.
* '''TI:''' Specifies which descriptor table to use. If clear ('''0''') then the '''GDT''' is used, if set ('''1''') then the '''LDT''' is used.
* '''TI:''' Specifies which descriptor table to use. If clear ('''0''') then the '''GDT''' is used, if set ('''1''') then the current '''LDT''' is used.
* '''RPL:''' The requested '''[[Security#Rings|Privilege Level]]''' of the selector, determines if the selector is valid during permission checks and may set execution or memory access privilege.
* '''RPL:''' The requested '''[[Security#Rings|Privilege Level]]''' of the selector, determines if the selector is valid during permission checks and may set execution or memory access privilege.


== Uses ==
== Uses ==
Line 24: Line 24:
* '''[[Segmentation|Segmentation Registers]]'''
* '''[[Segmentation|Segmentation Registers]]'''
* The '''[[Interrupt Descriptor Table]]'''
* The '''[[Interrupt Descriptor Table]]'''
* The '''[[Task State Segment]]'''

[[Category:X86]]
[[Category:Memory Segmentation]]

Latest revision as of 13:38, 7 June 2024

A Segment Selector is a 16-bit binary data structure specific to the IA-32 and x86-64 architectures. It is used in Protected Mode and Long Mode. Its value identifies a segment in either the Global Descriptor Table or a Local Descriptor Table. It contains three fields and is used in a variety of situations to interact with Segmentation.

For more information, see Section 3.4.2: Segment Selectors and Figure 3-6: Segment Selector of the Intel Software Developer Manual, Volume 3-A.

Segment Selector

Segment Selector
15    3 2 1   0
Index TI RPL
  • Index: Bits 3-15 of the Index of the GDT or LDT entry referenced by the selector. Since Segment Descriptors are 8 bytes in length, the value of Index is never unaligned and contains all zeros in the lowest 3 bits.
  • TI: Specifies which descriptor table to use. If clear (0) then the GDT is used, if set (1) then the current LDT is used.
  • RPL: The requested Privilege Level of the selector, determines if the selector is valid during permission checks and may set execution or memory access privilege.

Uses

Segment Selectors are used in a few locations, including: