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(guard: PPtr<Self>, idx: usize) -> res : Entry<'rcu, C>
pub exec fn entry(guard: PPtr<Self>, idx: usize) -> res : Entry<'rcu, C>
Tracked(owner): Tracked<&NodeOwner<C>>,
Tracked(child_owner): Tracked<&EntryOwner<C>>,
Tracked(guard_perm): Tracked<&GuardPerm<'rcu, C>>,requiresowner.inv(),!child_owner.in_scope,child_owner.inv(),owner.relate_guard_perm(*guard_perm),guard_perm.addr() == guard.addr(),child_owner.match_pte(owner.children_perm.value()[idx as int], child_owner.parent_level),idx < NR_ENTRIES,ensuresres.wf(*child_owner),res.node.addr() == guard_perm.addr(),res.idx == idx,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>>,requiresself.inner.inner@.invariants(*owner),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 exec fn read_pte(&self, idx: usize) -> pte : C::E
pub exec fn read_pte(&self, idx: usize) -> pte : C::E
Tracked(owner): Tracked<&NodeOwner<C>>,requiresself.inner.inner@.invariants(*owner),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 exec fn write_pte(&mut self, idx: usize, pte: C::E)
pub exec fn write_pte(&mut self, idx: usize, pte: C::E)
Tracked(owner): Tracked<&mut NodeOwner<C>>,requiresold(self).inner.inner@.invariants(*old(owner)),idx < NR_ENTRIES,ensuresowner.inv(),owner.meta_perm.addr() == old(owner).meta_perm.addr(),owner.level == old(owner).level,owner.meta_own == old(owner).meta_own,owner.meta_perm.points_to == old(owner).meta_perm.points_to,owner.children_perm.value() == old(owner).children_perm.value().update(idx as int, pte),*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),Gets the metadata of this page.
§Verified Properties
§Preconditions
- The caller must have a valid permission for the frame.
§Postconditions
- The function returns the 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,Gets the physical address of the start of the frame.
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(),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>,
Tracked(perm): Tracked<&MetaPerm<M>>,requiresold(regions).inv(),old(regions).slot_owners[self.index()].raw_count == 1,old(regions).slot_owners[self.index()].self_addr == self.ptr.addr(),perm.points_to.pptr() == self.ptr,perm.points_to.value().wf(old(regions).slot_owners[self.index()]),perm.is_init(),self.inv(),ensuresregions.inv(),res.inner@.ptr.addr() == self.ptr.addr(),regions.slots =~= old(regions).slots,regions.slot_owners =~= old(regions).slot_owners,Borrows a reference from the given 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
- 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(),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§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) -> bool
open spec fn constructor_ensures(self, s0: Self::State, s1: Self::State) -> bool
{ s1.guards == s0.guards.remove(self.inner.inner@.ptr.addr()) }Source§proof fn constructor_spec(self, tracked s: &mut Self::State)
proof fn constructor_spec(self, tracked s: &mut Self::State)
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) -> bool
open spec fn drop_ensures(self, s0: Self::State, s1: Self::State) -> bool
{ s1.guards == s0.guards.insert(self.inner.inner@.ptr.addr(), None) }