Enum Descriptor
pub enum Descriptor {
UserSegment(u64),
SystemSegment(u64, u64),
}Expand description
A 64-bit mode segment descriptor.
Segmentation is no longer supported in 64-bit mode, so most of the descriptor contents are ignored.
Variants§
UserSegment(u64)
Descriptor for a code or data segment.
Since segmentation is no longer supported in 64-bit mode, almost all of code and data descriptors is ignored. Only some flags are still used.
SystemSegment(u64, u64)
A system segment descriptor such as a LDT or TSS descriptor.
Implementations§
§impl Descriptor
impl Descriptor
pub const fn dpl(self) -> PrivilegeLevel
pub const fn dpl(self) -> PrivilegeLevel
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.
pub const fn kernel_code_segment() -> Descriptor
pub const fn kernel_code_segment() -> Descriptor
Creates a segment descriptor for a 64-bit kernel code segment. Suitable
for use with syscall or 64-bit sysenter.
pub const fn kernel_data_segment() -> Descriptor
pub const fn kernel_data_segment() -> Descriptor
Creates a segment descriptor for a kernel data segment (32-bit or
64-bit). Suitable for use with syscall or sysenter.
pub const fn user_data_segment() -> Descriptor
pub const fn user_data_segment() -> Descriptor
Creates a segment descriptor for a ring 3 data segment (32-bit or
64-bit). Suitable for use with sysret or sysexit.
pub const fn user_code_segment() -> Descriptor
pub const fn user_code_segment() -> Descriptor
Creates a segment descriptor for a 64-bit ring 3 code segment. Suitable
for use with sysret or sysexit.
pub fn tss_segment(tss: &'static TaskStateSegment) -> Descriptor
pub fn tss_segment(tss: &'static TaskStateSegment) -> Descriptor
Creates a TSS system descriptor for the given TSS.
While it is possible to create multiple Descriptors that point to the same TSS, this generally isn’t recommended, as the TSS usually contains per-CPU information such as the RSP and IST pointers. Instead, there should be exactly one TSS and one corresponding TSS Descriptor per CPU. Then, each of these descriptors should be placed in a GDT (which can either be global or per-CPU).
pub unsafe fn tss_segment_unchecked(tss: *const TaskStateSegment) -> Descriptor
pub unsafe fn tss_segment_unchecked(tss: *const TaskStateSegment) -> Descriptor
Similar to Descriptor::tss_segment, but unsafe since it does not enforce a lifetime
constraint on the provided TSS.
§Safety
The caller must ensure that the passed pointer is valid for as long as the descriptor is being used.
pub fn tss_segment_with_iomap(
tss: &'static TaskStateSegment,
iomap: &'static [u8],
) -> Result<Descriptor, InvalidIoMap>
pub fn tss_segment_with_iomap( tss: &'static TaskStateSegment, iomap: &'static [u8], ) -> Result<Descriptor, InvalidIoMap>
Creates a TSS system descriptor for the given TSS, setting up the IO permissions bitmap.
§Example
use x86_64::structures::gdt::Descriptor;
use x86_64::structures::tss::TaskStateSegment;
/// A helper that places some I/O map bytes behind a TSS.
#[repr(C)]
struct TssWithIOMap {
tss: TaskStateSegment,
iomap: [u8; 5],
}
static TSS: TssWithIOMap = TssWithIOMap {
tss: TaskStateSegment::new(),
iomap: [0xff, 0xff, 0x00, 0x80, 0xff],
};
let tss = Descriptor::tss_segment_with_iomap(&TSS.tss, &TSS.iomap).unwrap();Trait Implementations§
§impl Clone for Descriptor
impl Clone for Descriptor
§fn clone(&self) -> Descriptor
fn clone(&self) -> Descriptor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for Descriptor
Auto Trait Implementations§
impl Freeze for Descriptor
impl RefUnwindSafe for Descriptor
impl Send for Descriptor
impl Sync for Descriptor
impl Unpin for Descriptor
impl UnsafeUnpin for Descriptor
impl UnwindSafe for Descriptor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more