Skip to content

Commit

Permalink
tss: Update documentation
Browse files Browse the repository at this point in the history
Hopefully, this help address confusion like that seen in:
#322

Signed-off-by: Joe Richey <[email protected]>
  • Loading branch information
josephlr committed Mar 30, 2022
1 parent 6ae5b6a commit 821e4ff
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/instructions/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,18 @@ pub fn sidt() -> DescriptorTablePointer {

/// Load the task state register using the `ltr` instruction.
///
/// Note that loading a TSS segment selector marks the corresponding TSS
/// Descriptor in the GDT as "busy", preventing it from being loaded again
/// (either on this CPU or another CPU). TSS structures (including Descriptors
/// and Selectors) should generally be per-CPU. See
/// [`tss_segment`](crate::structures::gdt::Descriptor::tss_segment)
/// for more information.
///
/// ## Safety
///
/// This function is unsafe because the caller must ensure that the given
/// `SegmentSelector` points to a valid TSS entry in the GDT and that loading
/// this TSS is safe.
/// `SegmentSelector` points to a valid TSS entry in the GDT, that is entry is
/// not busy, and that the corresponding data in the TSS is valid.
#[inline]
pub unsafe fn load_tss(sel: SegmentSelector) {
unsafe {
Expand Down
7 changes: 7 additions & 0 deletions src/structures/gdt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,13 @@ impl Descriptor {
}

/// Creates a TSS system descriptor for the given TSS.
///
/// While it is possible to create multiple Descriptors that point to the
/// same TSS, this generally isn't recommended, as the TSS usually contains
/// per-CPU information such as the RSP and IST pointers. Instead, there
/// should be exactly one TSS and one corresponding TSS Descriptor per CPU.
/// Then, each of these descriptors should be placed in a GDT (which can
/// either be global or per-CPU).
#[inline]
pub fn tss_segment(tss: &'static TaskStateSegment) -> Descriptor {
use self::DescriptorFlags as Flags;
Expand Down

0 comments on commit 821e4ff

Please sign in to comment.