pub struct MemoryRegion {
pub host_addr: u64,
pub vm_addr: u64,
pub len: u64,
pub vm_gap_shift: u8,
pub is_writable: bool,
}Expand description
Memory region for bounds checking and address translation
Fields§
§host_addr: u64start host address
vm_addr: u64start virtual address
len: u64Length in bytes
vm_gap_shift: u8Size of regular gaps as bit shift (63 means this region is continuous)
is_writable: boolIs also writable (otherwise it is readonly)
Implementations§
Source§impl MemoryRegion
impl MemoryRegion
Sourcepub fn new_from_slice(
slice: &[u8],
vm_addr: u64,
vm_gap_size: u64,
is_writable: bool,
) -> Self
pub fn new_from_slice( slice: &[u8], vm_addr: u64, vm_gap_size: u64, is_writable: bool, ) -> Self
Creates a new MemoryRegion structure from a slice
Sourcepub fn vm_to_host<E: UserDefinedError>(
&self,
vm_addr: u64,
len: u64,
) -> Result<u64, EbpfError<E>>
pub fn vm_to_host<E: UserDefinedError>( &self, vm_addr: u64, len: u64, ) -> Result<u64, EbpfError<E>>
Convert a virtual machine address into a host address Does not perform a lower bounds check, as that is already done by the binary search in MemoryMapping::map()
Trait Implementations§
Source§impl Clone for MemoryRegion
impl Clone for MemoryRegion
Source§fn clone(&self) -> MemoryRegion
fn clone(&self) -> MemoryRegion
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MemoryRegion
impl Debug for MemoryRegion
Source§impl Default for MemoryRegion
impl Default for MemoryRegion
Source§fn default() -> MemoryRegion
fn default() -> MemoryRegion
Returns the “default value” for a type. Read more
impl Eq for MemoryRegion
Source§impl Ord for MemoryRegion
impl Ord for MemoryRegion
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for MemoryRegion
impl PartialEq for MemoryRegion
Source§impl PartialOrd for MemoryRegion
impl PartialOrd for MemoryRegion
impl StructuralPartialEq for MemoryRegion
Auto Trait Implementations§
impl Freeze for MemoryRegion
impl RefUnwindSafe for MemoryRegion
impl Send for MemoryRegion
impl Sync for MemoryRegion
impl Unpin for MemoryRegion
impl UnsafeUnpin for MemoryRegion
impl UnwindSafe for MemoryRegion
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
Mutably borrows from an owned value. Read more