-
Notifications
You must be signed in to change notification settings - Fork 16
prove axiom fn in tlb.rs #570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
f7e968d
4da431b
900695a
17e471c
e6ecd08
67869ac
8f648f9
928b6cd
5bdb5d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,9 +9,9 @@ use vstd_extra::ownership::*; | |
|
|
||
| verus! { | ||
|
|
||
| pub ghost struct TlbModel { | ||
| pub pending: Seq<TlbFlushOp>, | ||
| pub mappings: Set<Mapping>, | ||
| pub tracked struct TlbModel { | ||
| pub ghost pending: Seq<TlbFlushOp>, | ||
| pub ghost mappings: Set<Mapping>, | ||
| } | ||
|
|
||
| impl Inv for TlbModel { | ||
|
|
@@ -38,27 +38,33 @@ impl TlbModel { | |
| TlbModel { pending: self.pending, mappings: self.mappings.insert(m) } | ||
| } | ||
|
|
||
| pub axiom fn tracked_update(&mut self, pt: PageTableView, va: Vaddr) | ||
| pub proof fn tracked_update(tracked &mut self, pt: PageTableView, va: Vaddr) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idiomatic way for doing so is to define a pure function, e.g., Because this |
||
| requires | ||
| old(self).inv(), | ||
| forall|m: Mapping| | ||
| old(self).mappings has m ==> !(m.va_range.start <= va < m.va_range.end), | ||
| exists|m: Mapping| pt.mappings has m ==> m.va_range.start <= va < m.va_range.end, | ||
| exists|m: Mapping| pt.mappings has m && m.va_range.start <= va < m.va_range.end, | ||
| ensures | ||
| *final(self) == old(self).update(pt, va), | ||
| ; | ||
| { | ||
| let m = pt.mappings.filter(|m: Mapping| m.va_range.start <= va < m.va_range.end).choose(); | ||
| self.mappings = self.mappings.insert(m); | ||
| } | ||
|
|
||
| pub open spec fn flush(self, va: Vaddr) -> Self { | ||
| let m = self.mappings.filter(|m: Mapping| m.va_range.start <= va < m.va_range.end); | ||
| TlbModel { pending: self.pending, mappings: self.mappings - m } | ||
| } | ||
|
|
||
| pub axiom fn tracked_flush(&mut self, va: Vaddr) | ||
| pub proof fn tracked_flush(tracked &mut self, va: Vaddr) | ||
| requires | ||
| old(self).inv(), | ||
| ensures | ||
| *final(self) == old(self).flush(va), | ||
| ; | ||
| { | ||
| let m = self.mappings.filter(|m: Mapping| m.va_range.start <= va < m.va_range.end); | ||
| self.mappings = self.mappings - m; | ||
| } | ||
|
|
||
| pub open spec fn consistent_with_pt(self, pt: PageTableView) -> bool { | ||
| self.mappings <= pt.mappings | ||
|
|
@@ -116,7 +122,7 @@ impl TlbModel { | |
| *final(self) == old(self).issue_tlb_flush(op), | ||
| final(self).inv(), | ||
| { | ||
| self.pending.tracked_push(op); | ||
| self.pending = self.pending.push(op); | ||
| } | ||
|
|
||
| pub open spec fn dispatch_tlb_flush_spec(self) -> Self { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks weird to me, why do you want to keep
ghostinsidetracked?