Skip to main content

Segment64

Trait Segment64 

pub trait Segment64: Segment {
    const BASE: Msr;

    // Required methods
    fn read_base() -> VirtAddr;
    unsafe fn write_base(base: VirtAddr);
}
Expand description

An x86 segment which is actually used in 64-bit mode

While most segments are unused in 64-bit mode, the FS and GS segments are still partially used. Only the 64-bit segment base address is used, and this address can be set via the GDT, or by using the FSGSBASE instructions.

Required Associated Constants§

const BASE: Msr

MSR containing the segment base. This MSR can be used to set the base when [CR4.FSGSBASE][Cr4Flags::FSGSBASE] is not set.

Required Methods§

fn read_base() -> VirtAddr

Reads the segment base address

§Exceptions

If [CR4.FSGSBASE][Cr4Flags::FSGSBASE] is not set, this instruction will throw a #UD.

unsafe fn write_base(base: VirtAddr)

Writes the segment base address

§Exceptions

If [CR4.FSGSBASE][Cr4Flags::FSGSBASE] is not set, this instruction will throw a #UD.

§Safety

The caller must ensure that this write operation has no unsafe side effects, as the segment base address might be in use.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

§

impl Segment64 for FS

§

const BASE: Msr = FsBase::MSR

§

impl Segment64 for GS

§

const BASE: Msr = GsBase::MSR