Skip to main content

GuestMap

Struct GuestMap 

Source
pub struct GuestMap {
    regions: BTreeMap<u64, Region>,
    pages: u64,
    quota_pages: u64,
}
Expand description

Guest memory map of a world.

Fields§

§regions: BTreeMap<u64, Region>§pages: u64§quota_pages: u64

Implementations§

Source§

impl GuestMap

Source

pub fn new(quota_pages: u64) -> Self

Creates an empty map with a page quota.

Source

pub const fn pages(&self) -> u64

Number of reserved pages.

Source

pub const fn quota_pages(&self) -> u64

Page quota.

Source

pub fn region_count(&self) -> usize

Number of ranges.

Source

pub fn reserve( &mut self, gpa: u64, len: u64, perms: u32, memtype: u8, ) -> Result<Region, MapError>

Reserves a range. Idempotence is forbidden: an exact overlap is an error, which makes double mappings visible.

Source

fn overlaps(&self, gpa: u64, end: u64) -> bool

True if [gpa, end) overlaps an existing range.

Source

pub fn remove(&mut self, gpa: u64) -> Option<Region>

Removes the range starting exactly at gpa.

Source

pub fn region_containing(&self, gpa: u64) -> Option<Region>

Returns the range containing gpa.

Source

pub fn regions(&self) -> impl Iterator<Item = &Region>

Iterates over the ranges (ascending order).

Source

pub fn clear(&mut self)

Clears the whole map (frames remain the caller’s responsibility).

Source

pub fn set_quota(&mut self, quota_pages: u64)

Resets the quota (used when a world is reconfigured).

Source

pub fn reserve_with_plan( &mut self, gpa: u64, len: u64, perms: u32, memtype: u8, ) -> Result<(Region, Vec<MapSegment>), MapError>

Reserves a range and returns its 2 MiB/4 KiB mapping plan.

The reservation rules (alignment, overlap, quota) are exactly those of Self::reserve: the quota counts the same number of 4 KiB pages whatever the granularity, so a 2 MiB leaf accounts for 512 pages.

Trait Implementations§

Source§

impl Debug for GuestMap

Source§

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

Formats the value using the given formatter. Read more

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.