@@ -6,13 +6,15 @@ use bit_field::BitField;
66use core:: fmt;
77// imports for intra doc links
88#[ cfg( doc) ]
9- use crate :: registers:: control:: Cr4Flags ;
9+ use crate :: {
10+ registers:: control:: Cr4Flags ,
11+ structures:: gdt:: { Descriptor , DescriptorFlags , GlobalDescriptorTable } ,
12+ } ;
1013
1114/// An x86 segment
1215///
1316/// Segment registers on x86 are 16-bit [`SegmentSelector`]s, which index into
14- /// the [`GlobalDescriptorTable`](crate::structures::gdt::GlobalDescriptorTable). The
15- /// corresponding GDT entry is used to
17+ /// the [`GlobalDescriptorTable`]. The corresponding GDT entry is used to
1618/// configure the segment itself. Note that most segmentation functionality is
1719/// disabled in 64-bit mode. See the individual segments for more information.
1820pub trait Segment {
@@ -111,18 +113,27 @@ impl fmt::Debug for SegmentSelector {
111113
112114/// Code Segment
113115///
114- /// The segment base and limit are unused in 64-bit mode. Only the L (long), D
115- /// (default operation size), and DPL (descriptor privilege-level) fields of the
116- /// descriptor are recognized. So changing the segment register can be used to
117- /// change privilege level or enable/disable long mode.
116+ /// While most fields in the Code-Segment [`Descriptor`] are unused in 64-bit
117+ /// long mode, some of them must be set to a specific value. The
118+ /// [`EXECUTABLE`](DescriptorFlags::EXECUTABLE),
119+ /// [`USER_SEGMENT`](DescriptorFlags::USER_SEGMENT), and
120+ /// [`LONG_MODE`](DescriptorFlags::LONG_MODE) bits must be set, while the
121+ /// [`DEFAULT_SIZE`](DescriptorFlags::DEFAULT_SIZE) bit must be unset.
122+ ///
123+ /// The [`DPL_RING_3`](DescriptorFlags::DPL_RING_3) field can be used to change
124+ /// privilege level. The [`PRESENT`](DescriptorFlags::PRESENT) bit can be used
125+ /// to make a segment present or not present.
126+ ///
127+ /// All other fields (like the segment base and limit) are ignored by the
128+ /// processor and setting them has no effect.
118129#[ derive( Debug ) ]
119130pub struct CS ;
120131
121132/// Stack Segment
122133///
123134/// Entirely unused in 64-bit mode; setting the segment register does nothing.
124135/// However, in ring 3, the SS register still has to point to a valid
125- /// [`Descriptor`](crate::structures::gdt::Descriptor) (it cannot be zero). This
136+ /// [`Descriptor`] (it cannot be zero). This
126137/// means a user-mode read/write segment descriptor must be present in the GDT.
127138///
128139/// This register is also set by the `syscall`/`sysret` and
0 commit comments