Enum MemoryMapping

Source
pub enum MemoryMapping<'a> {
    Identity,
    Aligned(AlignedMemoryMapping<'a>),
    Unaligned(UnalignedMemoryMapping<'a>),
}
Expand description

Maps virtual memory to host memory.

Variants§

§

Identity

Used when address translation is disabled

§

Aligned(AlignedMemoryMapping<'a>)

Aligned memory mapping which uses the upper half of an address to identify the underlying memory region.

§

Unaligned(UnalignedMemoryMapping<'a>)

Memory mapping that allows mapping unaligned memory regions.

Implementations§

Source§

impl<'a> MemoryMapping<'a>

Source

pub fn new( regions: Vec<MemoryRegion>, config: &'a Config, sbpf_version: SBPFVersion, ) -> Result<Self, EbpfError>

Creates a new memory mapping.

Uses aligned or unaligned memory mapping depending on the value of config.aligned_memory_mapping=true.

Source

pub fn new_with_cow( regions: Vec<MemoryRegion>, cow_cb: MemoryCowCallback, config: &'a Config, sbpf_version: SBPFVersion, ) -> Result<Self, EbpfError>

Creates a new memory mapping.

Uses aligned or unaligned memory mapping depending on the value of config.aligned_memory_mapping=true. cow_cb is used to copy CoW memory regions.

Source

pub fn map( &self, access_type: AccessType, vm_addr: u64, len: u64, ) -> ProgramResult

Map virtual memory to host memory.

Source

pub fn load<T: Pod + Into<u64>>(&self, vm_addr: u64) -> ProgramResult

Loads size_of::<T>() bytes from the given address.

Works across memory region boundaries.

Source

pub fn store<T: Pod>(&self, value: T, vm_addr: u64) -> ProgramResult

Store value at the given address.

Works across memory region boundaries if len does not fit within a single region.

Source

pub fn region( &self, access_type: AccessType, vm_addr: u64, ) -> Result<&MemoryRegion, EbpfError>

Returns the MemoryRegion corresponding to the given address.

Source

pub fn get_regions(&self) -> &[MemoryRegion]

Returns the MemoryRegions in this mapping.

Source

pub fn replace_region( &mut self, index: usize, region: MemoryRegion, ) -> Result<(), EbpfError>

Replaces the MemoryRegion at the given index

Trait Implementations§

Source§

impl<'a> Debug for MemoryMapping<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for MemoryMapping<'a>

§

impl<'a> !RefUnwindSafe for MemoryMapping<'a>

§

impl<'a> !Send for MemoryMapping<'a>

§

impl<'a> !Sync for MemoryMapping<'a>

§

impl<'a> Unpin for MemoryMapping<'a>

§

impl<'a> !UnwindSafe for MemoryMapping<'a>

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V