pub struct PageTableGuard<'rcu, C: PageTableConfig> {
pub inner: PageTableNodeRef<'rcu, C>,
}Expand description
A guard that holds the lock of a page table node.
Fields§
§inner: PageTableNodeRef<'rcu, C>Implementations§
Source§impl<'rcu, C: PageTableConfig> PageTableGuard<'rcu, C>
impl<'rcu, C: PageTableConfig> PageTableGuard<'rcu, C>
Sourcepub exec fn entry<'a>(&'a mut self, idx: usize) -> res : Entry<'a, 'rcu, C>
pub exec fn entry<'a>(&'a mut self, idx: usize) -> res : Entry<'a, 'rcu, C>
Tracked(owner): Tracked<&NodeOwner<C>>,
Tracked(child_owner): Tracked<&EntryOwner<C>>,
Tracked(regions): Tracked<&MetaRegionOwners>,requiresowner.inv(),!child_owner.in_scope,child_owner.inv(),owner.relate_guard(*old(self)),child_owner.match_pte(owner.children_perm.value()[idx as int], child_owner.parent_level),regions.inv(),regions.slots.contains_key(owner.slot_index),idx < NR_ENTRIES,ensuresres.wf(*child_owner),res.idx == idx,owner.relate_guard(*res.node),*final(self) == *old(self),Borrows an entry in the node at a given index.
§Panics
Panics if the index is not within the bound of
nr_subpage_per_huge<C>.
Sourcepub exec fn nr_children(&self) -> nr : u16
pub exec fn nr_children(&self) -> nr : u16
Tracked(owner): Tracked<&NodeOwner<C>>,
Tracked(regions): Tracked<&MetaRegionOwners>,requiresself.inner.inner@.invariants(*owner),regions.inv(),owner.metaregion_sound_node(*regions),returnsowner.meta_own.nr_children.value(),Gets the number of valid PTEs in a page table node.
§Verified Properties
§Preconditions
- The node must be well-formed.
§Postconditions
- Returns the number of valid PTEs in the node.
§Safety
- We require the caller to provide a permission token to ensure that this function is only called on a valid page table node.
Sourcepub unsafe exec fn read_pte(&self, idx: usize) -> pte : C::E
pub unsafe exec fn read_pte(&self, idx: usize) -> pte : C::E
Tracked(owner): Tracked<&NodeOwner<C>>,
Tracked(regions): Tracked<&MetaRegionOwners>,requiresself.inner.inner@.invariants(*owner),regions.inv(),regions.slots.contains_key(owner.slot_index),idx < NR_ENTRIES,ensurespte == owner.children_perm.value()[idx as int],Reads a non-owning PTE at the given index.
A non-owning PTE means that it does not account for a reference count of the a page if the PTE points to a page. The original PTE still owns the child page.
§Safety
The caller must ensure that the index is within the bound.
Sourcepub unsafe exec fn write_pte(&mut self, idx: usize, pte: C::E)
pub unsafe exec fn write_pte(&mut self, idx: usize, pte: C::E)
Tracked(owner): Tracked<&mut NodeOwner<C>>,
Tracked(regions): Tracked<&MetaRegionOwners>,requiresold(self).inner.inner@.invariants(*old(owner)),regions.inv(),regions.slots.contains_key(old(owner).slot_index),idx < NR_ENTRIES,ensuresfinal(owner).inv(),final(owner).level == old(owner).level,final(owner).meta_own == old(owner).meta_own,final(owner).slot_index == old(owner).slot_index,final(owner).children_perm.value()
== old(owner).children_perm.value().update(idx as int, pte),*final(self) == *old(self),Writes a page table entry at a given index.
This operation will leak the old child if the old PTE is present.
§Safety
The caller must ensure that:
Methods from Deref<Target = Frame<M>>§
Sourcepub exec fn meta(&self) -> &'a M
pub exec fn meta(&self) -> &'a M
Tracked(perm): Tracked<&'a PointsTo<MetaSlot, Metadata<M>>>,requiresself.ptr.addr() == perm.addr(),self.ptr == perm.points_to.pptr(),perm.is_init(),perm.wf(&perm.inner_perms),returnsperm.value().metadata,Gets the metadata of this page.
§Verified Properties
§Preconditions
- The caller must have a valid permission for the frame.
§Postconditions
- The function returns the borrowed metadata of the frame.
§Safety
- By requiring the caller to provide a typed permission, we ensure that the metadata is of type
M. While a non-verified caller cannot be trusted to obey this interface, all functions that return aFrame<M>also return an appropriate permission.
Sourcepub exec fn start_paddr(&self) -> Paddr
pub exec fn start_paddr(&self) -> Paddr
Tracked(perm): Tracked<&vstd::simple_pptr::PointsTo<MetaSlot>>,requiresperm.addr() == self.ptr.addr(),perm.is_init(),FRAME_METADATA_RANGE.start <= perm.addr() < FRAME_METADATA_RANGE.end,perm.addr() % META_SLOT_SIZE == 0,returnsmeta_to_frame(self.ptr.addr()),Gets the physical address of the start of the frame.
§Verified Properties
§Preconditions
- Bookkeeping: takes the permission for the frame’s metadata slot.
§Postconditions
- Correctness: returns the physical address of the frame.
§Safety
The caller cannot obtain a frame that doesn’t have a valid permission, and this function does not mutate any state, so it is always sound to call.
Sourcepub exec fn eq(&self, other: &Self) -> res : bool
pub exec fn eq(&self, other: &Self) -> res : bool
Tracked(regions): Tracked<&MetaRegionOwners>,requiresself.inv(),other.inv(),regions.inv(),ensuresres == (meta_to_frame(self.ptr.addr()) == meta_to_frame(other.ptr.addr())),Compares two frames by their start physical address.
§Verified Properties
§Preconditions
- Safety Invariant: the frames and metadata regions must satisfy the global invariants.
§Postconditions
- Correctness: the function returns true if the frames have the same physical addresses and false otherwise.
§Safety
Everything is immutable, so the safety invariant is preserved implicitly.
§Verification Design
This is an inherent impl equivalent to PartialEq::eq for Frame<M>: freed from the
trait signature so that this version can thread the tracked MetaRegionOwners via verus_spec.
Sourcepub exec fn map_level(&self) -> PagingLevel
pub exec fn map_level(&self) -> PagingLevel
Gets the map level of this page.
This is the level of the page table entry that maps the frame, which determines the size of the frame.
Currently, the level is always 1, which means the frame is a regular page frame.
Sourcepub exec fn reference_count(&self) -> u64
pub exec fn reference_count(&self) -> u64
Tracked(slot_own): Tracked<&mut MetaSlotOwner>,
Tracked(perm): Tracked<&PointsTo<MetaSlot, Metadata<M>>>,requiresperm.addr() == self.ptr.addr(),perm.points_to.pptr() == self.ptr,perm.is_init(),perm.wf(&perm.inner_perms),perm.inner_perms.ref_count.id() == perm.points_to.value().ref_count.id(),returnsperm.value().ref_count,Gets the reference count of the frame.
It returns the number of all references to the frame, including all the
existing frame handles (Frame, Frame<dyn AnyFrameMeta>), and all
the mappings in the page table that points to the frame.
§Verified Properties
§Preconditions
- Safety Invariant: Metaslot region invariants must hold.
- Bookkeeping: The caller must have a valid and well-typed permission for the frame.
§Postconditions
- Correctness: The function returns the reference count of the frame.
§Safety
- The function is safe to call, but using it requires extra care. The reference count can be changed by other threads at any time including potentially between calling this method and acting on the result.
Sourcepub exec fn borrow(&self) -> res : FrameRef<'a, M>
pub exec fn borrow(&self) -> res : FrameRef<'a, M>
Tracked(regions): Tracked<&mut MetaRegionOwners>,requiresself.inv_with_regions(*old(regions)),ensuresfinal(regions).inv(),res.inner@.ptr.addr() == self.ptr.addr(),final(regions).slot_owners =~= old(regions).slot_owners,final(regions).slots =~= old(regions).slots,final(regions).frame_obligations =~= old(regions).frame_obligations,Borrows a reference from the given frame.
§Verified Properties
§Preconditions
- Safety Invariant: Metaslot region invariants must hold.
§Postconditions
- Safety Invariant: Metaslot region invariants hold after the call.
- Correctness: The function returns a reference to the frame.
- Correctness: The system context is unchanged.
Sourcepub exec fn slot(&self) -> slot : &'a MetaSlot
pub exec fn slot(&self) -> slot : &'a MetaSlot
Tracked(slot_perm): Tracked<&'a vstd::simple_pptr::PointsTo<MetaSlot>>,requiresslot_perm.pptr() == self.ptr,slot_perm.is_init(),returnsslot_perm.value(),Gets the metadata slot of the frame.
§Verified Properties
§Preconditions
- Safety: The caller must have a valid permission for the frame.
§Postconditions
- Correctness: The function returns a reference to the metadata slot of the frame.
§Safety
- There is no way to mutably borrow the metadata slot, so taking an immutable reference is safe. (The fields of the slot can be mutably borrowed, but not the slot itself.)
Trait Implementations§
Source§impl<'rcu, C: PageTableConfig> Deref for PageTableGuard<'rcu, C>
impl<'rcu, C: PageTableConfig> Deref for PageTableGuard<'rcu, C>
Source§impl<'rcu, C: PageTableConfig> TrackDrop for PageTableGuard<'rcu, C>
impl<'rcu, C: PageTableConfig> TrackDrop for PageTableGuard<'rcu, C>
Source§type Key = usize
type Key = usize
The node address whose lock this guard holds. The token
thus identifies which guard it tracks; drop_requires’s key
match prevents a guard’s obligation from being used to drop a
different guard. The real lock-set ledger is Guards::guards;
this trait’s discipline lifts the existing state-side discipline
onto the obligation token by carrying the locked address.
Source§open spec fn constructor_requires(self, s: Self::State) -> bool
open spec fn constructor_requires(self, s: Self::State) -> bool
{ s.lock_held(self.inner.inner@.ptr.addr()) }Source§open spec fn constructor_ensures(
self,
s0: Self::State,
s1: Self::State,
obl_key: Self::Key,
) -> bool
open spec fn constructor_ensures( self, s0: Self::State, s1: Self::State, obl_key: Self::Key, ) -> bool
{
&&& s1.guards == s0.guards.remove(self.inner.inner@.ptr.addr())
&&& obl_key == self.inner.inner@.ptr.addr()
}Source§proof fn constructor_spec(self, tracked s: &mut Self::State) -> tracked obl : DropObligation<Self::Key>
proof fn constructor_spec(self, tracked s: &mut Self::State) -> tracked obl : DropObligation<Self::Key>
Source§open spec fn drop_requires(self, s: Self::State) -> bool
open spec fn drop_requires(self, s: Self::State) -> bool
{ s.unlocked(self.inner.inner@.ptr.addr()) }Source§open spec fn drop_ensures(
self,
s0: Self::State,
s1: Self::State,
obl_key: Self::Key,
) -> bool
open spec fn drop_ensures( self, s0: Self::State, s1: Self::State, obl_key: Self::Key, ) -> bool
{ s1.guards == s0.guards.insert(self.inner.inner@.ptr.addr()) }Source§open spec fn consume_requires(self, s: Self::State, obl_key: Self::Key) -> bool
open spec fn consume_requires(self, s: Self::State, obl_key: Self::Key) -> bool
{ obl_key == self.inner.inner@.ptr.addr() }Source§open spec fn consume_ensures(
self,
s0: Self::State,
s1: Self::State,
obl_key: Self::Key,
) -> bool
open spec fn consume_ensures( self, s0: Self::State, s1: Self::State, obl_key: Self::Key, ) -> bool
{ s1.guards == s0.guards.remove(self.inner.inner@.ptr.addr()) }