Skip to main content

SlPte

Struct SlPte 

Source
pub struct SlPte(/* private fields */);
Expand description

A 64-bit second-level page table entry (PTE or PDE).

EPT-like format used by Intel VT-d for DMA address translation. Permissions (R/W) are AND-accumulated across all levels per §3.7.1.

Implementations§

Source§

impl SlPte

Source

pub const fn new() -> Self

Creates a new default initialized bitfield.

Source

pub const fn from_bits(bits: u64) -> Self

Convert from bits.

Source

pub const fn into_bits(self) -> u64

Convert into bits.

Source

pub const fn r(&self) -> bool

Read permission — 1 = DMA reads allowed through this entry.

Bits: 0..1

Source

pub const fn with_r_checked(self, value: bool) -> Result<Self, ()>

Read permission — 1 = DMA reads allowed through this entry.

Bits: 0..1

Source

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

Read permission — 1 = DMA reads allowed through this entry.

Bits: 0..1

Source

pub const fn set_r(&mut self, value: bool)

Read permission — 1 = DMA reads allowed through this entry.

Bits: 0..1

Source

pub const fn set_r_checked(&mut self, value: bool) -> Result<(), ()>

Read permission — 1 = DMA reads allowed through this entry.

Bits: 0..1

Source

pub const fn w(&self) -> bool

Write permission — 1 = DMA writes allowed through this entry.

Bits: 1..2

Source

pub const fn with_w_checked(self, value: bool) -> Result<Self, ()>

Write permission — 1 = DMA writes allowed through this entry.

Bits: 1..2

Source

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

Write permission — 1 = DMA writes allowed through this entry.

Bits: 1..2

Source

pub const fn set_w(&mut self, value: bool)

Write permission — 1 = DMA writes allowed through this entry.

Bits: 1..2

Source

pub const fn set_w_checked(&mut self, value: bool) -> Result<(), ()>

Write permission — 1 = DMA writes allowed through this entry.

Bits: 1..2

Source

pub const fn x(&self) -> bool

EPT execute bit; ignored in VT-d second-stage entries.

Bits: 2..3

Source

pub const fn with_x_checked(self, value: bool) -> Result<Self, ()>

EPT execute bit; ignored in VT-d second-stage entries.

Bits: 2..3

Source

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

EPT execute bit; ignored in VT-d second-stage entries.

Bits: 2..3

Source

pub const fn set_x(&mut self, value: bool)

EPT execute bit; ignored in VT-d second-stage entries.

Bits: 2..3

Source

pub const fn set_x_checked(&mut self, value: bool) -> Result<(), ()>

EPT execute bit; ignored in VT-d second-stage entries.

Bits: 2..3

Source

pub const fn ps(&self) -> bool

Page Size — 1 = this is a leaf entry for a large page. Valid at level 3 (1GB) and level 2 (2MB). Must be 0 at level 4.

Bits: 7..8

Source

pub const fn with_ps_checked(self, value: bool) -> Result<Self, ()>

Page Size — 1 = this is a leaf entry for a large page. Valid at level 3 (1GB) and level 2 (2MB). Must be 0 at level 4.

Bits: 7..8

Source

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

Page Size — 1 = this is a leaf entry for a large page. Valid at level 3 (1GB) and level 2 (2MB). Must be 0 at level 4.

Bits: 7..8

Source

pub const fn set_ps(&mut self, value: bool)

Page Size — 1 = this is a leaf entry for a large page. Valid at level 3 (1GB) and level 2 (2MB). Must be 0 at level 4.

Bits: 7..8

Source

pub const fn set_ps_checked(&mut self, value: bool) -> Result<(), ()>

Page Size — 1 = this is a leaf entry for a large page. Valid at level 3 (1GB) and level 2 (2MB). Must be 0 at level 4.

Bits: 7..8

Source

pub const fn a(&self) -> bool

Accessed (bit 8): hardware sets this when using the entry for translation. Enabled by Second Stage Access/Dirty bit Enable (SSADE) in the referencing scalable-mode PASID-table entry; otherwise ignored.

Bits: 8..9

Source

pub const fn with_a_checked(self, value: bool) -> Result<Self, ()>

Accessed (bit 8): hardware sets this when using the entry for translation. Enabled by Second Stage Access/Dirty bit Enable (SSADE) in the referencing scalable-mode PASID-table entry; otherwise ignored.

Bits: 8..9

Source

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

Accessed (bit 8): hardware sets this when using the entry for translation. Enabled by Second Stage Access/Dirty bit Enable (SSADE) in the referencing scalable-mode PASID-table entry; otherwise ignored.

Bits: 8..9

Source

pub const fn set_a(&mut self, value: bool)

Accessed (bit 8): hardware sets this when using the entry for translation. Enabled by Second Stage Access/Dirty bit Enable (SSADE) in the referencing scalable-mode PASID-table entry; otherwise ignored.

Bits: 8..9

Source

pub const fn set_a_checked(&mut self, value: bool) -> Result<(), ()>

Accessed (bit 8): hardware sets this when using the entry for translation. Enabled by Second Stage Access/Dirty bit Enable (SSADE) in the referencing scalable-mode PASID-table entry; otherwise ignored.

Bits: 8..9

Source

pub const fn d(&self) -> bool

Dirty (bit 9): hardware sets this on the leaf entry for a DMA write. Ignored in non-leaf entries or when the PASID-table SSADE field is clear.

Bits: 9..10

Source

pub const fn with_d_checked(self, value: bool) -> Result<Self, ()>

Dirty (bit 9): hardware sets this on the leaf entry for a DMA write. Ignored in non-leaf entries or when the PASID-table SSADE field is clear.

Bits: 9..10

Source

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

Dirty (bit 9): hardware sets this on the leaf entry for a DMA write. Ignored in non-leaf entries or when the PASID-table SSADE field is clear.

Bits: 9..10

Source

pub const fn set_d(&mut self, value: bool)

Dirty (bit 9): hardware sets this on the leaf entry for a DMA write. Ignored in non-leaf entries or when the PASID-table SSADE field is clear.

Bits: 9..10

Source

pub const fn set_d_checked(&mut self, value: bool) -> Result<(), ()>

Dirty (bit 9): hardware sets this on the leaf entry for a DMA write. Ignored in non-leaf entries or when the PASID-table SSADE field is clear.

Bits: 9..10

Source

pub const fn snp(&self) -> bool

Snoop behavior (bit 11, ignored by emulator).

Bits: 11..12

Source

pub const fn with_snp_checked(self, value: bool) -> Result<Self, ()>

Snoop behavior (bit 11, ignored by emulator).

Bits: 11..12

Source

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

Snoop behavior (bit 11, ignored by emulator).

Bits: 11..12

Source

pub const fn set_snp(&mut self, value: bool)

Snoop behavior (bit 11, ignored by emulator).

Bits: 11..12

Source

pub const fn set_snp_checked(&mut self, value: bool) -> Result<(), ()>

Snoop behavior (bit 11, ignored by emulator).

Bits: 11..12

Source

pub const fn address(&self) -> u64

Address bits [51:12] — next-level table or page frame address.

Bits: 12..52

Source

pub const fn with_address_checked(self, value: u64) -> Result<Self, ()>

Address bits [51:12] — next-level table or page frame address.

Bits: 12..52

Source

pub const fn with_address(self, value: u64) -> Self

Address bits [51:12] — next-level table or page frame address.

Bits: 12..52

Source

pub const fn set_address(&mut self, value: u64)

Address bits [51:12] — next-level table or page frame address.

Bits: 12..52

Source

pub const fn set_address_checked(&mut self, value: u64) -> Result<(), ()>

Address bits [51:12] — next-level table or page frame address.

Bits: 12..52

Source§

impl SlPte

Source

pub fn is_present(&self) -> bool

Check if this entry is present (R or W is set).

For DMA remapping, an entry is present if any of R or W is set. The X bit is ignored for second-level entries.

Source

pub fn phys_address(&self) -> u64

Get the full physical address from the address field (bits 51:12 shifted).

Source

pub fn iova_index(iova: u64, level: u8) -> usize

Compute the page table entry index for a given IOVA and level.

Extracts the 9-bit index from iova at the bit range for level: (iova >> shift) & 0x1FF, where shift = 12 + (level - 1) * 9.

Level 1: bits 20:12 (shift=12) Level 2: bits 29:21 (shift=21) Level 3: bits 38:30 (shift=30) Level 4: bits 47:39 (shift=39)

Source

pub fn page_size_at_level(level: u8) -> u64

Get the page size at a given level (when PS=1 for large pages).

Level 1: 4KB, Level 2: 2MB, Level 3: 1GB.

Source

pub fn large_page_gpa(&self, iova: u64, level: u8) -> u64

Compute the GPA for a large page mapping at the given level.

Masks the page frame address to the level alignment and adds the offset from the IOVA within the page.

Trait Implementations§

Source§

impl Clone for SlPte

Source§

fn clone(&self) -> SlPte

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 SlPte

Source§

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

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

impl Default for SlPte

Source§

fn default() -> Self

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

impl From<SlPte> for u64

Source§

fn from(v: SlPte) -> u64

Converts to this type from the input type.
Source§

impl From<u64> for SlPte

Source§

fn from(v: u64) -> Self

Converts to this type from the input type.
Source§

impl FromBytes for SlPte
where u64: FromBytes,

§

fn ref_from_bytes( source: &[u8], ) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>
where Self: KnownLayout + Immutable,

Interprets the given source as a &Self. Read more
§

fn ref_from_prefix( source: &[u8], ) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>
where Self: KnownLayout + Immutable,

Interprets the prefix of the given source as a &Self without copying. Read more
§

fn ref_from_suffix( source: &[u8], ) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>
where Self: Immutable + KnownLayout,

Interprets the suffix of the given bytes as a &Self. Read more
§

fn mut_from_bytes( source: &mut [u8], ) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>
where Self: IntoBytes + KnownLayout,

Interprets the given source as a &mut Self. Read more
§

fn mut_from_prefix( source: &mut [u8], ) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>
where Self: IntoBytes + KnownLayout,

Interprets the prefix of the given source as a &mut Self without copying. Read more
§

fn mut_from_suffix( source: &mut [u8], ) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>
where Self: IntoBytes + KnownLayout,

Interprets the suffix of the given source as a &mut Self without copying. Read more
§

fn read_from_bytes(source: &[u8]) -> Result<Self, SizeError<&[u8], Self>>
where Self: Sized,

Reads a copy of Self from the given source. Read more
§

fn read_from_prefix( source: &[u8], ) -> Result<(Self, &[u8]), SizeError<&[u8], Self>>
where Self: Sized,

Reads a copy of Self from the prefix of the given source. Read more
§

fn read_from_suffix( source: &[u8], ) -> Result<(&[u8], Self), SizeError<&[u8], Self>>
where Self: Sized,

Reads a copy of Self from the suffix of the given source. Read more
Source§

impl FromZeros for SlPte
where u64: FromZeros,

§

fn zero(&mut self)

Overwrites self with zeros. Read more
§

fn new_zeroed() -> Self
where Self: Sized,

Creates an instance of Self from zeroed bytes. Read more
§

fn new_box_zeroed() -> Result<Box<Self>, AllocError>
where Self: Sized,

Creates a Box<Self> from zeroed bytes. Read more
§

fn new_vec_zeroed(len: usize) -> Result<Vec<Self>, AllocError>
where Self: Sized,

Creates a Vec<Self> from zeroed bytes. Read more
§

fn extend_vec_zeroed( v: &mut Vec<Self>, additional: usize, ) -> Result<(), AllocError>
where Self: Sized,

Extends a Vec<Self> by pushing additional new items onto the end of the vector. The new items are initialized with zeros.
§

fn insert_vec_zeroed( v: &mut Vec<Self>, position: usize, additional: usize, ) -> Result<(), AllocError>
where Self: Sized,

Inserts additional new items into Vec<Self> at position. The new items are initialized with zeros. Read more
Source§

impl Inspect for SlPte

Source§

fn inspect(&self, req: Request<'_>)

Inspects the object.
Source§

impl IntoBytes for SlPte
where u64: IntoBytes,

§

fn as_bytes(&self) -> &[u8] ⓘ
where Self: Immutable,

Gets the bytes of this value. Read more
§

fn as_mut_bytes(&mut self) -> &mut [u8] ⓘ
where Self: FromBytes,

Gets the bytes of this value mutably. Read more
§

fn write_to(&self, dst: &mut [u8]) -> Result<(), SizeError<&Self, &mut [u8]>>
where Self: Immutable,

Writes a copy of self to dst. Read more
§

fn write_to_prefix( &self, dst: &mut [u8], ) -> Result<(), SizeError<&Self, &mut [u8]>>
where Self: Immutable,

Writes a copy of self to the prefix of dst. Read more
§

fn write_to_suffix( &self, dst: &mut [u8], ) -> Result<(), SizeError<&Self, &mut [u8]>>
where Self: Immutable,

Writes a copy of self to the suffix of dst. Read more
Source§

impl KnownLayout for SlPte
where Self: Sized,

Source§

type PointerMetadata = ()

The type of metadata stored in a pointer to Self. Read more
§

fn size_for_metadata(meta: Self::PointerMetadata) -> Option<usize>

Computes the size of an object of type Self with the given pointer metadata. Read more
Source§

impl TryFromBytes for SlPte
where u64: TryFromBytes,

§

fn try_ref_from_bytes( source: &[u8], ) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: KnownLayout + Immutable,

Attempts to interpret the given source as a &Self. Read more
§

fn try_ref_from_prefix( source: &[u8], ) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: KnownLayout + Immutable,

Attempts to interpret the prefix of the given source as a &Self. Read more
§

fn try_ref_from_suffix( source: &[u8], ) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: KnownLayout + Immutable,

Attempts to interpret the suffix of the given source as a &Self. Read more
§

fn try_mut_from_bytes( bytes: &mut [u8], ) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>
where Self: KnownLayout + IntoBytes,

Attempts to interpret the given source as a &mut Self without copying. Read more
§

fn try_mut_from_prefix( source: &mut [u8], ) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>
where Self: KnownLayout + IntoBytes,

Attempts to interpret the prefix of the given source as a &mut Self. Read more
§

fn try_mut_from_suffix( source: &mut [u8], ) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>
where Self: KnownLayout + IntoBytes,

Attempts to interpret the suffix of the given source as a &mut Self. Read more
§

fn try_read_from_bytes( source: &[u8], ) -> Result<Self, ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: Sized,

Attempts to read the given source as a Self. Read more
§

fn try_read_from_prefix( source: &[u8], ) -> Result<(Self, &[u8]), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: Sized,

Attempts to read a Self from the prefix of the given source. Read more
§

fn try_read_from_suffix( source: &[u8], ) -> Result<(&[u8], Self), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: Sized,

Attempts to read a Self from the suffix of the given source. Read more
Source§

impl Copy for SlPte

Source§

impl Immutable for SlPte
where u64: Immutable,

Auto Trait Implementations§

§

impl Freeze for SlPte

§

impl RefUnwindSafe for SlPte

§

impl Send for SlPte

§

impl Sync for SlPte

§

impl Unpin for SlPte

§

impl UnsafeUnpin for SlPte

§

impl UnwindSafe for SlPte

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more