VirtualMemoryPageBits

Struct VirtualMemoryPageBits 

Source
pub struct VirtualMemoryPageBits {
Show 13 fields pub present: bool, pub writable: bool, pub user: bool, pub write_through: bool, pub cache_disable: bool, pub accessed: bool, pub dirty: bool, pub global: bool, pub no_execute: bool, pub protection_key: u8, pub os_available_low: u8, pub os_available_high: u8, pub pat_bit2: bool,
}
Expand description

Unified, ergonomic view over x86-64 paging entries (all levels / forms).

This type deliberately does not use bit-packing. Instead, it models the semantic superset of fields across:

Use the provided from_* and to_* helpers to map between this view and the actual bitfield entries. Alignment and level-specific constraints are validated in to_* conversions (debug assertions).

Fields§

§present: bool

Present (P): valid entry if true.

§writable: bool

Writable (RW): allows writes if true.

§user: bool

User/Supervisor (US): user-mode access if true.

§write_through: bool

Page Write-Through (PWT): write-through policy (PAT bit0).

§cache_disable: bool

Page Cache Disable (PCD): disable caching (PAT bit1).

§accessed: bool

Accessed (A): set by CPU on first access. Not a permission bit.

§dirty: bool

Dirty (D): set by CPU on first write.

Meaningful for leaf entries only. Ignored in non-leaf mappings.

§global: bool

Global (G): TLB not flushed on CR3 reload (leaf only).

§no_execute: bool

Execute Disable / NX: disallow instruction fetch if true.

Requires EFER.NXE support. Applies across the walk (permission intersection).

§protection_key: u8

Protection key (PKU) or OS-use (bits 59..62).

Only meaningful if PKU is supported; otherwise free for OS use. Value is masked to 4 bits on to_*.

§os_available_low: u8

OS-available (low): bits 9..11 (masked to 3 bits in to_*).

§os_available_high: u8

OS-available (high): bits 52..58 (masked to 7 bits in to_*).

§pat_bit2: bool

PAT selector bit #2:

  • 4 KiB leaf: this is PTE bit7 (PAT small).
  • 2 MiB leaf: this is PDE bit12 (PAT large).
  • 1 GiB leaf: this is PDPTE bit12 (PAT large).
  • Non-leaf: ignored and forced to false in to_*.

Combined with write_through(bit3) and cache_disable(bit4) to form the 3-bit PAT index: [pat_bit2 : PCD : PWT].

Implementations§

Source§

impl VirtualMemoryPageBits

Source

pub fn set_present(&mut self, value: bool) -> &mut Self

Source

pub const fn with_present(self, value: bool) -> Self

Source

pub fn set_writable(&mut self, value: bool) -> &mut Self

Source

pub const fn with_writable(self, value: bool) -> Self

Source

pub fn set_user(&mut self, value: bool) -> &mut Self

Source

pub const fn with_user(self, value: bool) -> Self

Source

pub fn set_write_through(&mut self, value: bool) -> &mut Self

Source

pub const fn with_write_through(self, value: bool) -> Self

Source

pub fn set_cache_disable(&mut self, value: bool) -> &mut Self

Source

pub const fn with_cache_disable(self, value: bool) -> Self

Source

pub fn set_accessed(&mut self, value: bool) -> &mut Self

Source

pub const fn with_accessed(self, value: bool) -> Self

Source

pub fn set_dirty(&mut self, value: bool) -> &mut Self

Source

pub const fn with_dirty(self, value: bool) -> Self

Source

pub fn set_global(&mut self, value: bool) -> &mut Self

Source

pub const fn with_global(self, value: bool) -> Self

Source

pub fn set_no_execute(&mut self, value: bool) -> &mut Self

Source

pub const fn with_no_execute(self, value: bool) -> Self

Source

pub fn set_protection_key(&mut self, value: u8) -> &mut Self

Source

pub const fn with_protection_key(self, value: u8) -> Self

Source

pub fn set_os_available_low(&mut self, value: u8) -> &mut Self

Source

pub const fn with_os_available_low(self, value: u8) -> Self

Source

pub fn set_os_available_high(&mut self, value: u8) -> &mut Self

Source

pub const fn with_os_available_high(self, value: u8) -> Self

Source

pub fn set_pat_bit2(&mut self, value: bool) -> &mut Self

Source

pub const fn with_pat_bit2(self, value: bool) -> Self

Source§

impl VirtualMemoryPageBits

Source

pub const fn with_write_combining(self) -> Self

Enable write-combining (WC) via PAT registers.

Source

pub const fn from_pml4e(e: &Pml4Entry) -> Self

Populate from an L4 Pml4Entry (non-leaf).

Source

pub const fn from_pdpte(e: &Pdpte) -> Self

Populate from an L3 Pdpte (non-leaf).

Source

pub const fn from_pdpte_1g(e: &Pdpte1G) -> Self

Populate from an L3 Pdpte1G (1 GiB leaf).

Source

pub const fn from_pde(e: &Pde) -> Self

Populate from an L2 Pde (non-leaf).

Source

pub const fn from_pde_2m(e: &Pde2M) -> Self

Populate from an L2 Pde2M (2 MiB leaf).

Source

pub const fn from_pte_4k(e: &PtEntry4k) -> Self

Populate from an L1 PtEntry4k (4 KiB leaf).

Source§

impl VirtualMemoryPageBits

Source

pub const fn to_pml4e(&self, page: PhysicalPage<Size4K>) -> Pml4Entry

Encode into Pml4Entry (non-leaf).

  • Requires form == L4Entry
  • Enforces 4 KiB alignment; ignores dirty, global, pat_bit2.
Source

pub const fn to_pdpte(&self, page: PhysicalPage<Size4K>) -> Pdpte

Encode into Pdpte (non-leaf).

Source

pub const fn to_pdpte_1g(&self, page: PhysicalPage<Size1G>) -> Pdpte1G

Encode into Pdpte1G (1 GiB leaf).

Source

pub const fn to_pde(&self, page: PhysicalPage<Size4K>) -> Pde

Encode into Pde (non-leaf).

Source

pub const fn to_pde_2m(&self, page: PhysicalPage<Size2M>) -> Pde2M

Encode into Pde2M (2 MiB leaf).

Source

pub const fn to_pte_4k(&self, page: PhysicalPage<Size4K>) -> PtEntry4k

Encode into PtEntry4k (4 KiB leaf).

Trait Implementations§

Source§

impl Clone for VirtualMemoryPageBits

Source§

fn clone(&self) -> VirtualMemoryPageBits

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VirtualMemoryPageBits

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for VirtualMemoryPageBits

Source§

fn default() -> VirtualMemoryPageBits

Returns the “default value” for a type. Read more
Source§

impl From<Pde> for VirtualMemoryPageBits

Source§

fn from(e: Pde) -> Self

Converts to this type from the input type.
Source§

impl From<Pde2M> for VirtualMemoryPageBits

Source§

fn from(e: Pde2M) -> Self

Converts to this type from the input type.
Source§

impl From<Pdpte> for VirtualMemoryPageBits

Source§

fn from(e: Pdpte) -> Self

Converts to this type from the input type.
Source§

impl From<Pdpte1G> for VirtualMemoryPageBits

Source§

fn from(e: Pdpte1G) -> Self

Converts to this type from the input type.
Source§

impl From<Pml4Entry> for VirtualMemoryPageBits

Source§

fn from(e: Pml4Entry) -> Self

Converts to this type from the input type.
Source§

impl From<PtEntry4k> for VirtualMemoryPageBits

Source§

fn from(e: PtEntry4k) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for VirtualMemoryPageBits

Source§

fn eq(&self, other: &VirtualMemoryPageBits) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for VirtualMemoryPageBits

Source§

impl Eq for VirtualMemoryPageBits

Source§

impl StructuralPartialEq for VirtualMemoryPageBits

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.