Skip to main content

VmPagePtr

Struct VmPagePtr 

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

Type-safe wrapper around a raw pointer to a kernel page.

Implementations§

Source§

impl VmPagePtr

Source

pub const unsafe fn from_raw(ptr: *mut c_void) -> Option<Self>

Creates a VmPagePtr from a raw pointer.

§Safety

The caller must ensure that ptr is a valid pointer to a kernel page.

Source

pub fn as_raw(self) -> *mut c_void

Returns the raw pointer.

Source

pub unsafe fn is_free(self) -> bool

Returns whether this page is in the FREE state. When in the FREE state the page is assumed to be owned by the relevant PmmNode, and hence unless its lock is held this query must be assumed to be racy.

§Safety

The caller must ensure that it either still has ownership of the page or knows it is safe to inspect the state.

Source

pub unsafe fn is_free_loaned(self) -> bool

Returns whether this page is in the FREE_LOANED state. Similar to the FREE state the page is assumed to be owned by the relevant PmmNode, however this distinguishes whether the page is part of the general purpose free list, versus the more narrowly usable set of loaned pages.

§Safety

The caller must ensure that it either still has ownership of the page or knows it is safe to inspect the state.

Source

pub unsafe fn is_loaned(self) -> bool

If true, this page is “loaned” in the sense of being loaned from a contiguous VMO (via decommit) to Zircon. If the original contiguous VMO is deleted, this page will no longer be loaned. A loaned page cannot be pinned. Instead a different physical page (non-loaned) is used for the pin. A loaned page can be (re-)committed back into its original contiguous VMO, which causes the data in the loaned page to be moved into a different physical page (which itself can be non-loaned or loaned). A loaned page cannot be used to allocate a new contiguous VMO. Maybe queried by anyone who either owns the page, or has sufficient knowledge that the loaned state cannot be being altered in parallel.

§Safety

The caller must ensure that it either still has ownership of the page or knows it is safe to inspect the state.

Source

pub unsafe fn is_loan_cancelled(self) -> bool

If true, the original contiguous VMO wants the page back. Such pages won’t be reused until the page is no longer loaned, either via commit of the page back into the contiguous VMO that loaned the page, or via deletion of the contiguous VMO that loaned the page. Such pages are not in the free_loaned_list_ in pmm, which is how reuse is prevented. Should only be called by the PmmNode under its lock.

§Safety

The caller must ensure that it either still has ownership of the page or knows it is safe to inspect the state.

Source

pub unsafe fn set_is_loaned(self)

Sets the loaned flag on the page.

§Safety

The caller must ensure that it owns the page and holds the loaned pages lock of the PmmNode

Source

pub unsafe fn clear_is_loaned(self)

Clears the loaned flag on the page.

§Safety

The caller must ensure that it owns the page and holds the loaned pages lock of the PmmNode

Source

pub unsafe fn set_is_loan_cancelled(self)

Sets the loan_cancelled flag on the page. May be done even if not the owner of the page.

§Safety

The caller must ensure that it holds the loaned pages lock of the PmmNode

Source

pub unsafe fn clear_is_loan_cancelled(self)

Clears the loan_cancelled flag on the page. May be done even if not the owner of the page.

§Safety

The caller must ensure that it holds the loaned pages lock of the PmmNode

Source

pub unsafe fn dump(self)

Dumps information about the page to the debuglog.

§Safety

The caller must ensure that it either still has ownership of the page or knows it is safe to access the pages state.

Source

pub unsafe fn paddr(self) -> PAddr

Return the physical address of the page.

§Safety

The caller must ensure that it either still has ownership of the page or knows it is safe to inspect the state.

Source

pub unsafe fn state(self) -> VmPageState

Return the current VmPageState of this page.

§Safety

The caller must ensure that it either still has ownership of the page or knows it is safe to inspect the state.

Source

pub unsafe fn set_state(self, new_state: VmPageState)

Sets the VmPageState of this page.

§Safety

The caller must ensure that it owns the page or holds the necessary locks to modify its state.

Trait Implementations§

Source§

impl Clone for VmPagePtr

Source§

fn clone(&self) -> VmPagePtr

Returns a duplicate of the value. Read more
1.0.0 (const: unstable)§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for VmPagePtr

Source§

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

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

impl PartialEq for VmPagePtr

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable)§

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 VmPagePtr

Source§

impl Eq for VmPagePtr

Source§

impl StructuralPartialEq for VmPagePtr

Auto Trait Implementations§

§

impl Freeze for VmPagePtr

§

impl RefUnwindSafe for VmPagePtr

§

impl !Send for VmPagePtr

§

impl !Sync for VmPagePtr

§

impl Unpin for VmPagePtr

§

impl UnsafeUnpin for VmPagePtr

§

impl UnwindSafe for VmPagePtr

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

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

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Init<T> for T

§

unsafe fn __init(self, slot: *mut T) -> Result<(), Infallible>

Initializes slot. Read more
§

fn chain<F>(self, f: F) -> ChainInit<Self, F, T, E>
where F: FnOnce(&mut T) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T> PinInit<T> for T

§

unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>

Initializes slot. Read more
§

fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>
where F: FnOnce(Pin<&mut T>) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.