A segment selector is loaded into a segment register (cs, ds, etc.) to
select one of the regular segments in the system as the one addressed
via that segment register.
Segment selector Format:
#tabular2214#
- TI
- Table indicator:
0 means selector indexes into GDT
1 means selector indexes into LDT
- RPL
- Privilege level. \ uses only two privilege levels.
0 means kernel
3 means user
<#2220#> Examples:<#2220#>
- Kernel code segment
- <#2222#><#2222#>
TI=0, index=1, RPL=0, therefore selector = 0x08 (GDT[1])
- User data segment
- <#2223#><#2223#>
TI=1, index=2, RPL=3, therefore selector = 0x17 (LDT[2])
Selectors used in :
#tabular2225#
Selectors for system segments are not to be loaded directly into
segment registers. Instead one must load the TR or LDTR.
On entry into syscall:
- ds and es are set to the kernel data segment (0x10)
- fs is set to the user data segment (0x17) and is used to access
data pointed to by arguments to the system call.
- The stack segment and pointer are automatically set to ss0 and
esp0 by the interrupt and the old values restored when the syscall returns.