Struct x86_64::instructions::segmentation::CS [−][src]
pub struct CS;
Expand description
Code Segment
The segment base and limit are unused in 64-bit mode. Only the L (long), D (default operation size), and DPL (descriptor privilege-level) fields of the descriptor are recognized. So changing the segment register can be used to change privilege level or enable/disable long mode.
Trait Implementations
Note this is special since we cannot directly move to CS
; x86 requires the instruction
pointer and CS
to be set at the same time. To do this, we push the new segment selector
and return value onto the stack and use a “far return” (retfq
) to reload CS
and
continue at the end of our function.
Note we cannot use a “far call” (lcall
) or “far jmp” (ljmp
) to do this because then we
would only be able to jump to 32-bit instruction pointers. Only Intel implements support
for 64-bit far calls/jumps in long-mode, AMD does not.
Returns the current value of the segment register.