Skip to content

Commit a9c037c

Browse files
committed
Explain that SS must be set in Ring 3
Signed-off-by: Joe Richey <[email protected]>
1 parent b0ab474 commit a9c037c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/instructions/segmentation.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
//! Provides functions to read and write segment registers.
22
33
#[cfg(docsrs)]
4-
use crate::{registers::control::Cr4Flags, structures::gdt::GlobalDescriptorTable};
4+
use crate::{
5+
registers::control::Cr4Flags,
6+
structures::gdt::{Descriptor, GlobalDescriptorTable},
7+
};
58
use crate::{
69
registers::model_specific::{FsBase, GsBase, Msr},
710
structures::gdt::SegmentSelector,
@@ -152,7 +155,11 @@ impl Segment for CS {
152155
/// Stack Segment
153156
///
154157
/// Entirely unused in 64-bit mode; setting the segment register does nothing.
155-
/// However, this register is often set by the `syscall`/`sysret` and
158+
/// However, in ring 3, the SS register still has to point to a valid
159+
/// [`Descriptor`] (it cannot be zero). This means a user-mode read/write
160+
/// segment descriptor must be present in the GDT.
161+
///
162+
/// This register is also set by the `syscall`/`sysret` and
156163
/// `sysenter`/`sysexit` instructions (even on 64-bit transitions). This is to
157164
/// maintain symmetry with 32-bit transitions where setting SS actually will
158165
/// actually have an effect.

0 commit comments

Comments
 (0)