Modes: Real, Protected, Long/Flat
Logical Address Space per Process —> Physical Address map required
Address space divided into logical units (segments). e.g. code, data, stack, etc.
Segment further divided (pages). Pages are fixed size (e.g. 4KB in 32bit x86)
Logical Address: (Segment number, page number, page offset)
Global and local segment descriptor tables (GDT, LDT) store segment mappings
Page table for pages, etc.
Address Translation:
Logical Address = (segment number, displacement)
Physical = *(SGTBR + STE * STE Size) + displacement
Complicated by segment selectors and paging
Each segment gets protection bits (representing protection level or DPL). 0 - 3 (0 most privileged)
Current Protection Level (CPL)
Requestor Privilege Level (RPL)
Specified in segment selector
Check: Max (CPL, RPL) <= DPL of target
Why RPL? To avoid privilege execution (kernel executing code on behalf of an application)
Page level Protection
PPL (page protection level) of 0 (privileged) and 1 (non-priv)
CPL with 3 can only access PPL 1
Read-write protection
Execute disable protection
Can combine segment and page protections
Changing Privilege Level
Privileged Instructions
Can only be executed at CPL 0
e.g. LGDT, LLDT, MOV (control registers), HLT, etc.