Skip to main content

Module ring3_diag

Module ring3_diag 

Source
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:

  1. GDT – CS/SS descriptors have DPL=3, P=1 and the code segment has L=1 (64‑bit).
  2. Paging – every level (PML4 → PDPT → PD → PT) for target_rip and target_rsp has the USER_ACCESSIBLE flag.
  3. Alignmenttarget_rsp is 16‑byte aligned (System V ABI requirement).
  4. TSS – a TSS is loaded (TR ≠ 0) and rsp0 points 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.