Expand description
Pre-IRETQ diagnostics for transitioning from Ring 0 to Ring 3
validate_ring3_state should be invoked immediately before the IRETQ
trampoline. It checks the four prerequisites required for a safe switch to
Ring 3:
- GDT – CS/SS descriptors have DPL=3, P=1 and the code segment has L=1 (64‑bit).
- Paging – every level (PML4 → PDPT → PD → PT) for
target_ripandtarget_rsphas theUSER_ACCESSIBLEflag. - Alignment –
target_rspis 16‑byte aligned (System V ABI requirement). - TSS – a TSS is loaded (
TR ≠ 0) andrsp0points into kernel space (≥ 0xffff_8000_0000_0000), ensuring the CPU can switch back on exception.
If any check fails the function panic!s with a detailed description.
Functions§
- validate_
ring3_ state - Validates all CPU preconditions for a safe Ring 3 transition via
iretq.