Skip to content

Commit fe44ae4

Browse files
committed
tss: Update documentation
Hopefully, this help address confusion like that seen in: #322 Signed-off-by: Joe Richey <[email protected]>
1 parent aab60f7 commit fe44ae4

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/instructions/tables.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,18 @@ 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+
///
7380
/// ## Safety
7481
///
7582
/// 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.
83+
/// `SegmentSelector` points to a valid TSS entry in the GDT, that is entry is
84+
/// not busy, and that the corresponding data in the TSS is valid.
7885
#[inline]
7986
pub unsafe fn load_tss(sel: SegmentSelector) {
8087
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)