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 <joerichey@google.com>
  • Loading branch information
josephlr committed Mar 8, 2023
1 parent 14cdce4 commit 7673551
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 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 @@ -270,9 +271,10 @@ 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.
/// Returns the Descriptor Privilege Level (DPL). When using this descriptor
/// via a [`SegmentSelector`], the RPL and Current Privilege 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 7673551

Please sign in to comment.