Skip to main content

Region

Struct Region 

Source
pub struct Region { /* private fields */ }
Expand description

A run of FRESH pages this task was just given by AllocMem, for the §22 P7 stale-translation test.

P7 asks whether a dead task’s translations can outlive it (CLAUDE.md 10.5): a writer stamps its pages, is killed, and a checker spawned after it, given the SAME virtual addresses (every task’s AllocMem grows from one base), must read the zeroes the kernel filled its new pages with. A pattern word there means the checker read through a translation that belonged to the dead writer.

Reading and writing that memory needs a raw pointer, which a test SERVICE must not hold (18.2), so it is wrapped here. The wrapper is sound because a Region can only be made from a successful AllocMem: its pages are mapped, writable, private to this task, and referenced by nothing else - the kernel has just created them, and no Rust object lives there.

Implementations§

Source§

impl Region

Source

pub fn alloc(ctx: &ServiceContext, pages: usize) -> Option<Region>

Ask the kernel for pages fresh 4 KiB pages. None if it refused.

Source

pub fn base(&self) -> u64

The first virtual address of the region (the same in every task that asks first).

Source

pub fn stamp(&self, word: u32)

Write word into every 32-bit word of the region.

Source

pub fn first_not(&self, want: u32) -> Option<(usize, u32)>

The byte offset and value of the first word that is not want, or None if every word is.

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
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, 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.