Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tss: Update documentation #366

Merged
merged 2 commits into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/instructions/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,20 @@ 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.
///
/// Calling `load_tss` with a busy TSS selector results in a `#GP` exception.
///
/// ## 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 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).
Freax13 marked this conversation as resolved.
Show resolved Hide resolved
#[inline]
pub fn tss_segment(tss: &'static TaskStateSegment) -> Descriptor {
use self::DescriptorFlags as Flags;
Expand Down