Skip to content

Commit f8beb06

Browse files
authored
Fix spt_do_not_change (#200)
* Fix spt_do_not_change Signed-off-by: Yonghao Zou <zouyonghao@live.cn> * Format code Signed-off-by: Yonghao Zou <zouyonghao@live.cn> * Format again Signed-off-by: Yonghao Zou <zouyonghao@live.cn>
1 parent 287f235 commit f8beb06

5 files changed

Lines changed: 36 additions & 14 deletions

File tree

lock-protocol/src/mm/page_table/cursor/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ impl<'a, C: PageTableConfig> Cursor<'a, C> {
583583
self.va == old(self).va,
584584
// Path remains unchanged except the one being set
585585
forall|i: PagingLevel|
586-
#![trigger self.path.view().index(path_index_at_level_spec(i))]
586+
#![auto]
587587
old(self).level <= i <= old(self).guard_level ==> {
588588
#[trigger] path_index!(self.path[i]) == path_index!(old(self).path[i])
589589
},

lock-protocol/src/mm/page_table/cursor/spec_helpers.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ pub open spec fn spt_do_not_change_except_modify_pte<C: PageTableConfig>(
4848
&&& spt.wf()
4949
&&& old_spt.wf()
5050
&&& spt.instance.id() == old_spt.instance.id()
51-
&&& spt.instance.root() == old_spt.instance.root()
52-
&&& forward_spt_do_not_change_except(spt, old_spt, pte_addr)
51+
&&& spt.instance.root()
52+
== old_spt.instance.root() // &&& forward_spt_do_not_change_except(spt, old_spt, pte_addr)
53+
// not correct?
5354
&&& forward_spt_do_not_change_except(old_spt, spt, pte_addr)
5455
}
5556

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ impl<'a, 'rcu, C: PageTableConfig> Entry<'a, 'rcu, C> {
478478
map_va: self.va@ as int,
479479
frame_pa: self.node.paddr() as int,
480480
in_frame_index: self.idx as int,
481-
map_to_pa: pt.start_paddr() as int,
481+
map_to_pa: pa as int,
482482
level,
483483
phantom: PhantomData::<C>,
484484
};
@@ -498,7 +498,10 @@ impl<'a, 'rcu, C: PageTableConfig> Entry<'a, 'rcu, C> {
498498
}
499499
assert(spt.frames.value()[self.node.paddr() as int].level as int == level as int);
500500
spt.instance.set_child(i_pte, &mut spt.frames, &mut spt.i_ptes, &spt.ptes);
501-
spt.perms.tracked_insert(pt.start_paddr(), perm);
501+
spt.perms.tracked_insert(pa, perm);
502+
503+
// i_pte.entry_pa() == i_pte.pte_paddr_spec(). @see entry_pa
504+
assert(spt.i_ptes.value().contains_key(self.pte.pte_paddr() as int));
502505
}
503506

504507
assert(spt.wf());
@@ -514,12 +517,10 @@ impl<'a, 'rcu, C: PageTableConfig> Entry<'a, 'rcu, C> {
514517
assert(spt.alloc_model.meta_map.contains_key(pa as int));
515518
assert(spt.alloc_model.meta_map.contains_key(self.pte.frame_paddr() as int));
516519

517-
// assert(spt_do_not_change_except_modify_pte(spt, old(spt), self.pte.pte_paddr() as int));
518-
519520
assert(self.wf(spt));
520-
assume(spt_do_not_change_except_modify_pte(spt, old(spt), self.pte.pte_paddr() as int));
521-
assume(spt_do_not_change_above_level(spt, old(spt), level));
522-
assume(alloc_model_do_not_change_except_add_frame(spt, old(spt), pa));
521+
assert(alloc_model_do_not_change_except_add_frame(spt, old(spt), pa));
522+
assert(spt_do_not_change_above_level(spt, old(spt), level));
523+
assert(spt_do_not_change_except_modify_pte(spt, old(spt), self.pte.pte_paddr() as int));
523524

524525
let node_ref = PageTableNodeRef::borrow_paddr(pa, Tracked(&spt.alloc_model));
525526
assert(node_ref.level_spec(&spt.alloc_model) == level - 1);

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,16 @@ impl<C: PageTableConfig> PageTableNode<C> {
120120
res.0.start_paddr() % page_size_spec::<C>(level) == 0,
121121
// old model does not change
122122
forall|pa: Paddr| #[trigger]
123-
old(model).meta_map.contains_key(pa as int)
124-
==> #[trigger] model.meta_map.contains_key(pa as int)
125-
&& model.meta_map[pa as int] == old(model).meta_map[pa as int],
123+
old(model).meta_map.contains_key(pa as int) <==> {
124+
&&& #[trigger] model.meta_map.contains_key(pa as int)
125+
&&& res.0.start_paddr() != pa
126+
},
127+
forall|pa: Paddr| #[trigger]
128+
model.meta_map.contains_key(pa as int) && old(model).meta_map.contains_key(
129+
pa as int,
130+
) ==> {
131+
&&& model.meta_map[pa as int] == old(model).meta_map[pa as int]
132+
},
126133
{
127134
crate::exec::alloc_page_table(level, Tracked(model))
128135
}

lock-protocol/src/spec/sub_pt/state_machine.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,20 @@ SubPageTableStateMachine<C: PageTableConfig> {
319319
}
320320

321321
#[inductive(set_child)]
322-
pub fn tr_set_child_invariant(pre: Self, post: Self, i_pte: IntermediatePageTableEntryView<C>) {}
322+
pub fn tr_set_child_invariant(pre: Self, post: Self, i_pte: IntermediatePageTableEntryView<C>) {
323+
assert(forall |i|
324+
#[trigger] pre.frames.contains_key(i) ==>
325+
(forall |l| #[trigger] pre.frames[i].ancestor_chain.dom().contains(l)
326+
&& !(#[trigger] pre.frames[i].ancestor_chain.index(l).entry_pa() == i_pte.entry_pa())) ==>
327+
#[trigger] post.frames.contains_key(i)
328+
);
329+
// assert(forall |i|
330+
// #[trigger] post.frames.contains_key(i) ==>
331+
// (forall |l| #[trigger] post.frames[i].ancestor_chain.dom().contains(l)
332+
// && !(#[trigger] post.frames[i].ancestor_chain.index(l).entry_pa() == i_pte.entry_pa())) ==>
333+
// #[trigger] pre.frames.contains_key(i)
334+
// );
335+
}
323336

324337
transition! {
325338
// remove a pte at a given address

0 commit comments

Comments
 (0)