Skip to content

Commit 1ea319c

Browse files
authored
Merge pull request #366 from rust-osdev/tss
tss: Update documentation
2 parents d64cc5a + 9ab8c70 commit 1ea319c

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/instructions/tables.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,20 @@ pub fn sidt() -> DescriptorTablePointer {
7070

7171
/// Load the task state register using the `ltr` instruction.
7272
///
73+
/// Note that loading a TSS segment selector marks the corresponding TSS
74+
/// Descriptor in the GDT as "busy", preventing it from being loaded again
75+
/// (either on this CPU or another CPU). TSS structures (including Descriptors
76+
/// and Selectors) should generally be per-CPU. See
77+
/// [`tss_segment`](crate::structures::gdt::Descriptor::tss_segment)
78+
/// for more information.
79+
///
80+
/// Calling `load_tss` with a busy TSS selector results in a `#GP` exception.
81+
///
7382
/// ## Safety
7483
///
7584
/// This function is unsafe because the caller must ensure that the given
76-
/// `SegmentSelector` points to a valid TSS entry in the GDT and that loading
77-
/// this TSS is safe.
85+
/// `SegmentSelector` points to a valid TSS entry in the GDT and that the
86+
/// corresponding data in the TSS is valid.
7887
#[inline]
7988
pub unsafe fn load_tss(sel: SegmentSelector) {
8089
unsafe {

src/structures/gdt.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,13 @@ impl Descriptor {
312312
}
313313

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

0 commit comments

Comments
 (0)