Skip to content

Commit 1e5b8bf

Browse files
authored
Describe behavior of alloc_if_none in PTE present case in spec (#201)
* Describe behavior of alloc_if_none in PTE present case in spec * Format code
1 parent f8beb06 commit 1e5b8bf

1 file changed

Lines changed: 46 additions & 33 deletions

File tree

  • lock-protocol/src/mm/page_table/node

lock-protocol/src/mm/page_table/node/entry.rs

Lines changed: 46 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -412,41 +412,54 @@ impl<'a, 'rcu, C: PageTableConfig> Entry<'a, 'rcu, C> {
412412
!old(spt).ptes.value().contains_key(old(self).pte.pte_paddr() as int),
413413
old(self).node.level_spec(&old(spt).alloc_model) > 1,
414414
old(self).node.wf(&old(spt).alloc_model),
415-
!old(self).pte.is_present(),
416415
ensures
417-
self.wf(spt),
418-
self.pte.pte_paddr() == old(self).pte.pte_paddr(),
419-
self.node == old(self).node,
420-
self.node.level_spec(&spt.alloc_model) == old(self).node.level_spec(
421-
&old(spt).alloc_model,
422-
),
423-
self.idx == old(self).idx,
424-
spt.wf(),
425-
res is Some,
426-
spt_do_not_change_except_modify_pte(spt, old(spt), self.pte.pte_paddr() as int),
427-
spt_do_not_change_above_level(spt, old(spt), self.node.level_spec(&spt.alloc_model)),
428-
alloc_model_do_not_change_except_add_frame(spt, old(spt), res.unwrap().paddr()),
429-
res.unwrap().wf(&spt.alloc_model),
430-
spt.i_ptes.value().contains_key(self.pte.pte_paddr() as int),
431-
!old(spt).frames.value().contains_key(res.unwrap().paddr() as int),
432-
spt.frames.value().contains_key(res.unwrap().paddr() as int),
433-
!old(spt).alloc_model.meta_map.contains_key(res.unwrap().paddr() as int),
434-
spt.alloc_model.meta_map.contains_key(res.unwrap().paddr() as int),
435-
res.unwrap().level_spec(&spt.alloc_model) == self.node.level_spec(&spt.alloc_model) - 1,
436-
spt.frames.value()[res.unwrap().paddr() as int].ancestor_chain
437-
== spt.frames.value()[self.node.paddr() as int].ancestor_chain.insert(
438-
self.node.level_spec(&spt.alloc_model) as int,
439-
IntermediatePageTableEntryView {
440-
map_va: self.va as int,
441-
frame_pa: self.node.paddr() as int,
442-
in_frame_index: self.idx as int,
443-
map_to_pa: res.unwrap().paddr() as int,
444-
level: self.node.level_spec(&spt.alloc_model),
445-
phantom: PhantomData,
446-
},
447-
),
416+
if old(self).pte.is_present() {
417+
&&& res is None
418+
&&& spt == old(spt)
419+
&&& self == old(self)
420+
} else {
421+
&&& self.wf(spt)
422+
&&& self.pte.pte_paddr() == old(self).pte.pte_paddr()
423+
&&& self.node == old(self).node
424+
&&& self.node.level_spec(&spt.alloc_model) == old(self).node.level_spec(
425+
&old(spt).alloc_model,
426+
)
427+
&&& self.idx == old(self).idx
428+
&&& spt.wf()
429+
&&& res is Some
430+
&&& spt_do_not_change_except_modify_pte(spt, old(spt), self.pte.pte_paddr() as int)
431+
&&& spt_do_not_change_above_level(
432+
spt,
433+
old(spt),
434+
self.node.level_spec(&spt.alloc_model),
435+
)
436+
&&& alloc_model_do_not_change_except_add_frame(spt, old(spt), res.unwrap().paddr())
437+
&&& res.unwrap().wf(&spt.alloc_model)
438+
&&& spt.i_ptes.value().contains_key(self.pte.pte_paddr() as int)
439+
&&& !old(spt).frames.value().contains_key(res.unwrap().paddr() as int)
440+
&&& spt.frames.value().contains_key(res.unwrap().paddr() as int)
441+
&&& !old(spt).alloc_model.meta_map.contains_key(res.unwrap().paddr() as int)
442+
&&& spt.alloc_model.meta_map.contains_key(res.unwrap().paddr() as int)
443+
&&& res.unwrap().level_spec(&spt.alloc_model) == self.node.level_spec(
444+
&spt.alloc_model,
445+
) - 1
446+
&&& spt.frames.value()[res.unwrap().paddr() as int].ancestor_chain
447+
== spt.frames.value()[self.node.paddr() as int].ancestor_chain.insert(
448+
self.node.level_spec(&spt.alloc_model) as int,
449+
IntermediatePageTableEntryView {
450+
map_va: self.va as int,
451+
frame_pa: self.node.paddr() as int,
452+
in_frame_index: self.idx as int,
453+
map_to_pa: res.unwrap().paddr() as int,
454+
level: self.node.level_spec(&spt.alloc_model),
455+
phantom: PhantomData,
456+
},
457+
)
458+
},
448459
{
449-
assert(!self.pte.is_present());
460+
if self.pte.is_present() {
461+
return None;
462+
}
450463
let level = self.node.level(Tracked(&spt.alloc_model));
451464
let (pt, Tracked(perm)) = PageTableNode::<C>::alloc(
452465
level - 1,

0 commit comments

Comments
 (0)