Skip to content

Commit

Permalink
Descriptor: update comments
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
josephlr committed Mar 8, 2023
1 parent 14cdce4 commit 592f87a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/structures/gdt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ bitflags! {
const EXECUTABLE = 1 << 43;
/// This flag must be set for user segments (in contrast to system segments).
const USER_SEGMENT = 1 << 44;
/// The DPL for this descriptor is Ring 3. In 64-bit mode, ignored for data segments.
/// These two bits encode the Descriptor Privilege Level (DPL) for this descriptor.
/// If both bits are set, the DPL is Ring 3, if both are unset, the DPL is Ring 0.
const DPL_RING_3 = 3 << 45;
/// Must be set for any segment, causes a segment not present exception if not set.
const PRESENT = 1 << 47;
Expand Down Expand Up @@ -271,8 +272,9 @@ impl DescriptorFlags {

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

0 comments on commit 592f87a

Please sign in to comment.