pub struct FrameRef<'a, M: AnyFrameMeta> {
pub inner: ManuallyDrop<Frame<M>>,
pub _marker: PhantomData<&'a Frame<M>>,
}Expand description
A struct that can work as &'a Frame<M>.
Fields§
§inner: ManuallyDrop<Frame<M>>§_marker: PhantomData<&'a Frame<M>>Implementations§
Source§impl<'a, C: PageTableConfig> FrameRef<'a, PageTablePageMeta<C>>
impl<'a, C: PageTableConfig> FrameRef<'a, PageTablePageMeta<C>>
Sourcepub open spec fn locks_preserved_except<'rcu>(
addr: usize,
guards0: Guards<'rcu, C>,
guards1: Guards<'rcu, C>,
) -> bool
pub open spec fn locks_preserved_except<'rcu>( addr: usize, guards0: Guards<'rcu, C>, guards1: Guards<'rcu, C>, ) -> bool
{
&&& OwnerSubtree::implies(
CursorOwner::node_unlocked(guards0),
CursorOwner::node_unlocked_except(guards1, addr),
)
&&& forall |i: usize| guards0.lock_held(i) ==> guards1.lock_held(i)
&&& forall |i: usize| guards0.unlocked(i) && i != addr ==> guards1.unlocked(i)
}Sourcepub exec fn lock<'rcu, A: InAtomicMode>(
self,
_guard: &'rcu A,
) -> res : PPtr<PageTableGuard<'rcu, C>>where
'a: 'rcu,
pub exec fn lock<'rcu, A: InAtomicMode>(
self,
_guard: &'rcu A,
) -> res : PPtr<PageTableGuard<'rcu, C>>where
'a: 'rcu,
Tracked(owner): Tracked<&NodeOwner<C>>,
Tracked(guards): Tracked<&mut Guards<'rcu, C>>,
->
guard_perm: Tracked<GuardPerm<'rcu, C>>,requiresself.inner@.invariants(*owner),old(guards).unlocked(owner.meta_perm.addr()),ensuresguards.lock_held(owner.meta_perm.addr()),Self::locks_preserved_except(owner.meta_perm.addr(), *old(guards), *guards),res.addr() == guard_perm@.addr(),owner.relate_guard_perm(guard_perm@),Locks the page table node.
An atomic mode guard is required to
- prevent deadlocks;
- provide a lifetime (
'rcu) that the nodes are guaranteed to outlive.
§Verification Design
As of when we verified this library, we didn’t have a spin lock implementation, so we axiomatize what happens when it’s successful.
Sourcepub exec fn make_guard_unchecked<'rcu, A: InAtomicMode>(
self,
_guard: &'rcu A,
) -> res : PPtr<PageTableGuard<'rcu, C>>where
'a: 'rcu,
pub exec fn make_guard_unchecked<'rcu, A: InAtomicMode>(
self,
_guard: &'rcu A,
) -> res : PPtr<PageTableGuard<'rcu, C>>where
'a: 'rcu,
Tracked(owner): Tracked<&NodeOwner<C>>,
Tracked(guards): Tracked<&mut Guards<'rcu, C>>,
->
guard_perm: Tracked<GuardPerm<'rcu, C>>,requiresself.inner@.invariants(*owner),old(guards).unlocked(owner.meta_perm.addr()),ensuresguards.lock_held(owner.meta_perm.addr()),Self::locks_preserved_except(owner.meta_perm.addr(), *old(guards), *guards),res.addr() == guard_perm@.addr(),owner.relate_guard_perm(guard_perm@),Creates a new PageTableGuard without checking if the page table lock is held.
§Safety
This function must be called if this task logically holds the lock.
Calling this function when a guard is already created is undefined behavior unless that guard was already forgotten.
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 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.
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>,
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.slot_owners[self.index()].raw_count == 1,regions.slot_owners[self.index()].inner_perms
== old(regions).slot_owners[self.index()].inner_perms,regions.slot_owners[self.index()].self_addr
== old(regions).slot_owners[self.index()].self_addr,regions.slot_owners[self.index()].usage == old(regions).slot_owners[self.index()].usage,regions.slot_owners[self.index()].path_if_in_pt
== old(regions).slot_owners[self.index()].path_if_in_pt,forall |i: usize| {
i != self.index() ==> regions.slot_owners[i] == old(regions).slot_owners[i]
},regions.slot_owners.dom() =~= old(regions).slot_owners.dom(),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(),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.)