Skip to content

Commit 592f87a

Browse files
committed
Descriptor: update comments
Clarify the DPL_RING_3 flag, remove the the comment saying that the DPL is ignored in 64-bit mode data segments, explain the exception for stack segments. Signed-off-by: Joe Richey <[email protected]>
1 parent 14cdce4 commit 592f87a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/structures/gdt.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ bitflags! {
202202
const EXECUTABLE = 1 << 43;
203203
/// This flag must be set for user segments (in contrast to system segments).
204204
const USER_SEGMENT = 1 << 44;
205-
/// The DPL for this descriptor is Ring 3. In 64-bit mode, ignored for data segments.
205+
/// These two bits encode the Descriptor Privilege Level (DPL) for this descriptor.
206+
/// If both bits are set, the DPL is Ring 3, if both are unset, the DPL is Ring 0.
206207
const DPL_RING_3 = 3 << 45;
207208
/// Must be set for any segment, causes a segment not present exception if not set.
208209
const PRESENT = 1 << 47;
@@ -271,8 +272,9 @@ impl DescriptorFlags {
271272

272273
impl Descriptor {
273274
/// Returns the Descriptor Privilage Level (DPL). When using this descriptor
274-
/// via a [`SegmentSelector`], the `rpl` and Current Privilage Level (CPL)
275-
/// must less than or equal to the DPL.
275+
/// via a [`SegmentSelector`], the RPL and Current Privilage Level (CPL)
276+
/// must less than or equal to the DPL, except for stack segments where the
277+
/// RPL, CPL, and DPL must all be equal.
276278
#[inline]
277279
pub const fn dpl(self) -> PrivilegeLevel {
278280
let value_low = match self {

0 commit comments

Comments
 (0)