rust-kernel
Rustbelt: a hobby x86_64 kernel written in Rust
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | //! GDT (Global Descriptor Table) + TSS (Task State Segment).
//!
//! In 64-bit mode segmentation is mostly dead, but we still need a GDT for one
//! important reason: it is how the CPU finds the TSS, and the TSS holds the
//! Interrupt Stack Table (IST) -- a list of known-good stacks the CPU can
//! switch to when an exception happens.
//!
//! Why it matters: if the kernel stack overflows, the CPU hits the guard page
//! and raises a page fault. Pushing the exception frame onto the (already
//! overflowed) stack faults again -> double fault -> same problem -> TRIPLE
//! fault, which resets the machine. Giving the double-fault handler its own
//! IST stack breaks that chain.
use lazy_static;
use VirtAddr;
use ;
use TaskStateSegment;
/// Which IST slot (0..=6) the double-fault handler uses.
pub const DOUBLE_FAULT_IST_INDEX: u16 = 0;
lazy_static!
lazy_static!
/// Load our GDT, point CS at our code segment and load the TSS.
|