Skip to main content

try_from_shared_embedded

Function try_from_shared_embedded 

Source
pub proof fn try_from_shared_embedded(tracked regions: &mut MetaRegionOwners, paddr: Paddr)
Expand description
requires
old(regions).inv(),
old(regions).slots.contains_key(frame_to_index(paddr)),
old(regions).slot_owners[frame_to_index(paddr)].inner_perms.ref_count.value() == 1,
old(regions).slot_owners[frame_to_index(paddr)].usage == PageUsage::Frame,
old(regions).slot_owners[frame_to_index(paddr)].paths_in_pt.is_empty(),
ensures
final(regions).inv(),
final(regions).slots =~= old(regions).slots,
{
    let idx = frame_to_index(paddr);
    let so_old = old(regions).slot_owners[idx];
    let so_new = final(regions).slot_owners[idx];
    &&& so_new.inner_perms.ref_count.value() == REF_COUNT_UNIQUE
    &&& so_new.usage == so_old.usage
    &&& so_new.paths_in_pt == so_old.paths_in_pt
    &&& so_new.inner_perms.in_list == so_old.inner_perms.in_list
    &&& so_new.inner_perms.storage == so_old.inner_perms.storage
    &&& so_new.slot_vaddr == so_old.slot_vaddr

},
forall |i: usize| {
    i != frame_to_index(paddr)
        ==> final(regions).slot_owners[i] == old(regions).slot_owners[i]
},
forall |c: CursorOwner<'_, UserPtConfig>| {
    c.metaregion_sound(*old(regions)) ==> c.metaregion_sound(*final(regions))
},

Mirror of crate::mm::frame::UniqueFrame::try_from_shared’s success path (the CAS 1 → REF_COUNT_UNIQUE succeeded). The slot transitions from a sole-reference shared frame (rc == 1, usage == Frame, no PTE) to an exclusive UNIQUE one, with usage, paths_in_pt (empty), in_list (0), storage, vtable_ptr, and slot_vaddr preserved. (The failure path — rc != 1 — leaves regions untouched and is modeled in the step as a no-op.)