From 920c5fd9c84620f5f3724115b6e409568c0db056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vilhelm=20Sj=C3=B6berg?= Date: Thu, 19 Nov 2026 11:42:30 +0100 Subject: [PATCH] Count only owned children in nr_children `count_consistent` said that `nr_children` counts every present PTE of a node. Upstream counts only the children a node owns: a user page table's root borrows the kernel half, so `create_user_page_table` copies those PTEs in without incrementing `nr_children`, and `PageTablePageMeta::on_drop` walks only `TOP_LEVEL_INDEX_RANGE`. The new user root therefore broke `count_consistent`; main did not notice because `create_user_page_table` drops the new page table's owner. - `NodeOwner::owned_range` is `TOP_LEVEL_INDEX_RANGE` for a top-level node and all slots otherwise; `count_owned` counts the present PTEs in it, and `count_consistent` now says `nr_children == count_owned()`. - `count_present_between` and its lemmas replace the whole-array `count_present` helpers. `lemma_count_owned_update`: writing a slot changes the count only if the node owns the slot. - The entry operations that can change a slot's presence (`replace`, `alloc_if_none`, `replace_child`, `alloc_absent_child`, `replace_absent_with_frame`) require the node to own the slot; the cursor shows it with the new `lemma_cur_slot_owned`. - `create_user_page_table` now proves the new user root stays `count_consistent` while the kernel half is copied in. No trusted code is added and no executable code changes. Co-Authored-By: Claude Opus 5.5 --- ostd/specs/mm/page_table/cursor/owners.rs | 20 ++ ostd/specs/mm/page_table/node/owners.rs | 244 ++++++++++++++-------- ostd/specs/mm/page_table/owners.rs | 16 +- ostd/src/mm/page_table/cursor/mod.rs | 9 + ostd/src/mm/page_table/mod.rs | 15 ++ ostd/src/mm/page_table/node/entry.rs | 75 +++---- 6 files changed, 237 insertions(+), 142 deletions(-) diff --git a/ostd/specs/mm/page_table/cursor/owners.rs b/ostd/specs/mm/page_table/cursor/owners.rs index fc5348d168..f9d27fb467 100644 --- a/ostd/specs/mm/page_table/cursor/owners.rs +++ b/ostd/specs/mm/page_table/cursor/owners.rs @@ -1195,6 +1195,26 @@ impl<'rcu, C: PageTableConfig> CursorOwner<'rcu, C> { self.va >= self.barrier_va.end } + /// Inside its range, the cursor's current node owns the slot the cursor + /// points at: at the top level the slot is in the configured index range. + pub proof fn lemma_cur_slot_owned(self) + requires + self.inv(), + self.in_barrier_va(), + !self.popped_too_high, + ensures + self.continuations[self.level - 1].entry_own.node().owns_slot(self.index() as int), + { + C::lemma_paging_consts_properties(); + self.lemma_inv_continuation(self.level - 1); + let node = self.continuations[self.level - 1].entry_own.node(); + node.lemma_owned_range_bounds(); + if node.level() == C::NR_LEVELS { + self.lemma_cur_pte_index(); + self.lemma_in_barrier_va_top_index_bounds(); + } + } + /// Active cursor addresses select a root entry in the configured index range. pub proof fn lemma_in_barrier_va_top_index_bounds(self) requires diff --git a/ostd/specs/mm/page_table/node/owners.rs b/ostd/specs/mm/page_table/node/owners.rs index 903aaef6a5..6c65890790 100644 --- a/ostd/specs/mm/page_table/node/owners.rs +++ b/ostd/specs/mm/page_table/node/owners.rs @@ -25,17 +25,18 @@ verus! { // ─── Present-PTE counting ────────────────────────────────────────────────────── // The intended meaning of `nr_children`: the number of *present* PTEs in the -// node's `children_perm` array. `metaregion_sound_node` ties `nr_children` to -// `count_present(children_perm.value())` (a settled-node invariant), which lets -// the `nr_children_*_slot_bound` boundary facts be proven rather than axiomatized. -/// Number of present PTEs among the first `n` entries of `s`. -pub open spec fn count_present_upto(s: Seq, n: int) -> int - decreases n, +// slots the node owns (`NodeOwner::owned_range`). `metaregion_sound_node` ties +// `nr_children` to that count (`NodeOwner::count_consistent`, a settled-node +// invariant), which lets the `nr_children_*_slot_bound` boundary facts be +// proven rather than axiomatized. +/// Number of present PTEs among entries `lo..n` of `s`. +pub open spec fn count_present_between(s: Seq, lo: int, n: int) -> int + decreases n - lo, { - if n <= 0 { + if n <= lo { 0 } else { - count_present_upto(s, n - 1) + if s[n - 1].is_present() { + count_present_between(s, lo, n - 1) + if s[n - 1].is_present() { 1int } else { 0int @@ -43,118 +44,115 @@ pub open spec fn count_present_upto(s: Seq, n: int) - } } -/// Number of present PTEs in `s`. -pub open spec fn count_present(s: Seq) -> int { - count_present_upto(s, s.len() as int) -} - -/// `count_present_upto` is between `0` and `n`. -pub proof fn lemma_count_present_upto_bound(s: Seq, n: int) +/// `count_present_between` is between `0` and `n - lo`. +pub proof fn lemma_count_present_between_bound(s: Seq, lo: int, n: int) requires - 0 <= n, + lo <= n, ensures - 0 <= count_present_upto(s, n) <= n, - decreases n, + 0 <= count_present_between(s, lo, n) <= n - lo, + decreases n - lo, { - if n > 0 { - lemma_count_present_upto_bound(s, n - 1); + if n > lo { + lemma_count_present_between_bound(s, lo, n - 1); } } -/// An absent slot below `n` makes the count strictly less than `n`. -pub proof fn lemma_count_present_upto_absent(s: Seq, n: int, idx: int) +/// An absent slot in `lo..n` makes the count strictly less than `n - lo`. +pub proof fn lemma_count_present_between_absent( + s: Seq, + lo: int, + n: int, + idx: int, +) requires - 0 <= idx < n, + lo <= idx < n, !s[idx].is_present(), ensures - count_present_upto(s, n) < n, - decreases n, + count_present_between(s, lo, n) < n - lo, + decreases n - lo, { - lemma_count_present_upto_bound(s, n - 1); + lemma_count_present_between_bound(s, lo, n - 1); if idx < n - 1 { - lemma_count_present_upto_absent(s, n - 1, idx); + lemma_count_present_between_absent(s, lo, n - 1, idx); } } -/// A present slot below `n` makes the count at least `1`. -pub proof fn lemma_count_present_upto_present(s: Seq, n: int, idx: int) +/// A present slot in `lo..n` makes the count at least `1`. +pub proof fn lemma_count_present_between_present( + s: Seq, + lo: int, + n: int, + idx: int, +) requires - 0 <= idx < n, + lo <= idx < n, s[idx].is_present(), ensures - count_present_upto(s, n) >= 1, - decreases n, + count_present_between(s, lo, n) >= 1, + decreases n - lo, { - lemma_count_present_upto_bound(s, n - 1); + lemma_count_present_between_bound(s, lo, n - 1); if idx < n - 1 { - lemma_count_present_upto_present(s, n - 1, idx); + lemma_count_present_between_present(s, lo, n - 1, idx); } } -/// Updating slot `idx` (with `idx < n`) shifts the count by the change in that -/// slot's present-indicator. -pub proof fn lemma_count_present_upto_update( +/// If two sequences agree on `lo..n`, their counts there are equal. +pub proof fn lemma_count_present_between_unchanged( s: Seq, + s2: Seq, + lo: int, n: int, - idx: int, - pte: E, ) requires - 0 <= idx < n <= s.len(), - ensures - count_present_upto(s.update(idx, pte), n) == count_present_upto(s, n) - ( - if s[idx].is_present() { - 1int - } else { - 0int - }) + (if pte.is_present() { - 1int - } else { - 0int - }), - decreases n, -{ - let s2 = s.update(idx, pte); - if n - 1 == idx { - // The first `idx` entries are unchanged. - assert(count_present_upto(s2, n - 1) == count_present_upto(s, n - 1)) by { - lemma_count_present_upto_unchanged(s, s2, n - 1); - } - } else { - lemma_count_present_upto_update(s, n - 1, idx, pte); - } -} - -/// A zero present-count up to `n` means every slot below `n` is absent. -pub proof fn lemma_count_present_upto_zero_all_absent(s: Seq, n: int) - requires - count_present_upto(s, n) == 0, - 0 <= n, + forall|k: int| lo <= k < n ==> s[k] == s2[k], ensures - forall|k: int| 0 <= k < n ==> !#[trigger] s[k].is_present(), - decreases n, + count_present_between(s2, lo, n) == count_present_between(s, lo, n), + decreases n - lo, { - if n > 0 { - lemma_count_present_upto_bound(s, n - 1); - lemma_count_present_upto_zero_all_absent(s, n - 1); + if n > lo { + lemma_count_present_between_unchanged(s, s2, lo, n - 1); } } -/// If two sequences agree on `[0, n)`, their counts up to `n` are equal. -pub proof fn lemma_count_present_upto_unchanged( +/// Updating slot `idx` shifts the count over `lo..n` by the change in that +/// slot's present-indicator if `idx` is in `lo..n`, and leaves it unchanged +/// otherwise. +pub proof fn lemma_count_present_between_update( s: Seq, - s2: Seq, + lo: int, n: int, + idx: int, + pte: E, ) requires - 0 <= n, - forall|k: int| 0 <= k < n ==> s[k] == s2[k], + 0 <= lo, + n <= s.len(), + 0 <= idx < s.len(), ensures - count_present_upto(s2, n) == count_present_upto(s, n), - decreases n, + count_present_between(s.update(idx, pte), lo, n) == count_present_between(s, lo, n) + if lo + <= idx < n { + (if pte.is_present() { + 1int + } else { + 0int + }) - (if s[idx].is_present() { + 1int + } else { + 0int + }) + } else { + 0int + }, + decreases n - lo, { - if n > 0 { - lemma_count_present_upto_unchanged(s, s2, n - 1); + let s2 = s.update(idx, pte); + if n > lo { + if n - 1 == idx { + lemma_count_present_between_unchanged(s, s2, lo, n - 1); + } else { + lemma_count_present_between_update(s, lo, n - 1, idx, pte); + } } } @@ -265,7 +263,46 @@ impl NodeOwner { /// `nr_children` equals the number of present PTEs in `children_perm`. pub open spec fn count_consistent(self) -> bool { - self.meta_own.nr_children.value() == count_present(self.children_perm.value()) + self.meta_own.nr_children.value() == self.count_owned() + } + + /// The slots whose children this node owns, `lo..hi`. A top-level node owns + /// only the configuration's [`PageTableConfig::TOP_LEVEL_INDEX_RANGE`]: a user + /// page table borrows the kernel's half, which it does not count or drop + /// (upstream's `PageTablePageMeta::on_drop` walks only this range). Every + /// other node owns all its slots. + pub open spec fn owned_range(self) -> (int, int) { + if self.level() == C::NR_LEVELS { + (C::TOP_LEVEL_INDEX_RANGE.start as int, C::TOP_LEVEL_INDEX_RANGE.end as int) + } else { + (0, NR_ENTRIES as int) + } + } + + /// The node owns the child in slot `i`. + pub open spec fn owns_slot(self, i: int) -> bool { + self.owned_range().0 <= i < self.owned_range().1 + } + + /// The number of present PTEs in the slots the node owns: what `nr_children` + /// counts. + pub open spec fn count_owned(self) -> int { + count_present_between( + self.children_perm.value(), + self.owned_range().0, + self.owned_range().1, + ) + } + + /// The owned range is within the node's slots. + pub proof fn lemma_owned_range_bounds(self) + ensures + 0 <= self.owned_range().0 <= self.owned_range().1 <= NR_ENTRIES, + self.owned_range().1 - self.owned_range().0 < NR_ENTRIES ==> self.level() + == C::NR_LEVELS, + { + C::lemma_page_table_config_constant_properties(); + C::lemma_paging_consts_properties(); } } @@ -284,7 +321,12 @@ impl NodeOwner { ensures self.meta_own.nr_children.value() < NR_ENTRIES, { - lemma_count_present_upto_absent(self.children_perm.value(), NR_ENTRIES as int, idx as int); + let (lo, hi) = self.owned_range(); + self.lemma_owned_range_bounds(); + lemma_count_present_between_bound(self.children_perm.value(), lo, hi); + if lo <= idx < hi { + lemma_count_present_between_absent(self.children_perm.value(), lo, hi, idx as int); + } } /// If a slot in `children_perm` holds a present PTE, then `nr_children > 0`. @@ -296,11 +338,41 @@ impl NodeOwner { self.count_consistent(), self.children_perm.value().len() == NR_ENTRIES, idx < NR_ENTRIES, + self.owns_slot(idx as int), self.children_perm.value()[idx as int].is_present(), ensures self.meta_own.nr_children.value() > 0, { - lemma_count_present_upto_present(self.children_perm.value(), NR_ENTRIES as int, idx as int); + let (lo, hi) = self.owned_range(); + lemma_count_present_between_present(self.children_perm.value(), lo, hi, idx as int); + } + + /// Writing slot `idx` changes the owned count by the change in that slot's + /// present-indicator, if the node owns the slot, and not at all otherwise. + pub proof fn lemma_count_owned_update(self, other: Self, idx: int, pte: C::E) + requires + self.children_perm.value().len() == NR_ENTRIES, + 0 <= idx < NR_ENTRIES, + other.children_perm.value() == self.children_perm.value().update(idx, pte), + other.metadata == self.metadata, + ensures + other.count_owned() == self.count_owned() + if self.owns_slot(idx) { + (if pte.is_present() { + 1int + } else { + 0int + }) - (if self.children_perm.value()[idx].is_present() { + 1int + } else { + 0int + }) + } else { + 0int + }, + { + let (lo, hi) = self.owned_range(); + self.lemma_owned_range_bounds(); + lemma_count_present_between_update(self.children_perm.value(), lo, hi, idx, pte); } } diff --git a/ostd/specs/mm/page_table/owners.rs b/ostd/specs/mm/page_table/owners.rs index 2c98ba2e93..c1b1ba8036 100644 --- a/ostd/specs/mm/page_table/owners.rs +++ b/ostd/specs/mm/page_table/owners.rs @@ -1352,19 +1352,20 @@ impl PageTableOwner { /// A node with `nr_children == 0` has no present PTEs, so all children are /// absent and the subtree contributes no mappings. /// - /// `count_consistent` ties `nr_children` to `count_present(children_perm)`, - /// so `nr_children == 0` forces every PTE absent. `pt_edge_at` (from + /// Below the top level, `count_consistent` ties `nr_children` to the number + /// of present PTEs in all slots, so `nr_children == 0` forces every PTE absent. `pt_edge_at` (from /// `pt_inv`) then forces each ghost child `is_absent` — its `view_rec` is /// `∅` — and `lemma_view_rec_contains` lifts that to the whole node's /// `view_rec`. (At the top level the `borrowed` edge disjunct is ruled out: - /// `borrowed_match_pte` needs a *present* PTE, which `count_present == 0` - /// denies.) + /// `borrowed_match_pte` needs a *present* PTE, which a zero count denies.) pub proof fn lemma_view_rec_nr_children_zero_empty(self, path: TreePath) requires self.pt_inv(), self.0.value().is_node(), self.0.value().node().meta_own.nr_children.value() == 0, self.0.value().node().count_consistent(), + // Below the top level a node owns, and so counts, all its slots. + self.0.value().node().level() < C::NR_LEVELS, path.len() <= C::NR_LEVELS, path.len() == self.0.level(), ensures @@ -1382,11 +1383,12 @@ impl PageTableOwner { path.push_tail(i), ).contains(m); self.pt_inv_unroll(i); - // PTE `i` is absent — else `count_present(cp) >= 1`. + // PTE `i` is absent — else the count would be at least 1. if cp[i].is_present() { - crate::specs::mm::page_table::node::owners::lemma_count_present_upto_present( + crate::specs::mm::page_table::node::owners::lemma_count_present_between_present( cp, - cp.len() as int, + 0, + NR_ENTRIES as int, i, ); } diff --git a/ostd/src/mm/page_table/cursor/mod.rs b/ostd/src/mm/page_table/cursor/mod.rs index 3a7bff4eb3..50b39a719f 100644 --- a/ostd/src/mm/page_table/cursor/mod.rs +++ b/ostd/src/mm/page_table/cursor/mod.rs @@ -1080,6 +1080,11 @@ impl<'rcu, C: PageTableConfig> Cursor<'rcu, C> { owner.continuations[owner.level - 1].lemma_pt_inv_children_unroll( owner.index() as int, ); + // The child is a level below its parent, so not top-level. + owner.continuations[owner.level - 1].lemma_inv_children_rel_unroll( + owner.index() as int, + ); + assert(subtree.value().node().level() < C::NR_LEVELS); PageTableOwner(subtree).lemma_view_rec_nr_children_zero_empty( subtree.value().path, ); @@ -2577,6 +2582,7 @@ impl<'rcu, C: PageTableConfig> CursorMut<'rcu, C> { let ghost guards_pre_none = *guards; proof { self.0.lemma_pte_index_matches_owner(owner_pre_none); + owner.lemma_cur_slot_owned(); } let entry_idx = pte_index::(self.0.va, self.0.level); @@ -3615,6 +3621,9 @@ impl<'rcu, C: PageTableConfig> CursorMut<'rcu, C> { } let entry_idx = pte_index::(self.0.va, self.0.level); + proof { + owner.lemma_cur_slot_owned(); + } let tracked mut continuation = owner.continuations.tracked_remove(owner.level - 1); let ghost cont0 = continuation; diff --git a/ostd/src/mm/page_table/mod.rs b/ostd/src/mm/page_table/mod.rs index fc6f8fcbe9..a9b25f39d9 100644 --- a/ostd/src/mm/page_table/mod.rs +++ b/ostd/src/mm/page_table/mod.rs @@ -937,6 +937,11 @@ impl PageTable { new_node_owner.inv(), new_node_owner.relate_guard(new_node), regions.contains(new_node_owner.slot_index), + // The new root is a user page table's root, which does not own + // the kernel half it borrows, so copying it in keeps + // `nr_children` consistent. + new_node_owner.level() == UserPtConfig::NR_LEVELS, + new_node_owner.count_consistent(), { proof { let kern_node = kernel_owner.0.value().node(); @@ -1019,10 +1024,20 @@ impl PageTable { proof { assert(regions.contains(new_node_owner.slot_index)); } + let ghost new_node_owner0 = new_node_owner; unsafe { #[verus_spec(with Tracked(&mut new_node_owner), Tracked(&*regions))] new_node.write_pte(i, pte) }; + proof { + // Slot `i` is in the kernel half, which the user root does not own. + assert(!new_node_owner0.owns_slot(i as int)); + new_node_owner0.lemma_count_owned_update(new_node_owner, i as int, pte); + } + } + proof { + // The new root stays consistent: its owner could be handed back. + assert(new_node_owner.count_consistent()); } PageTable:: { root: new_root } diff --git a/ostd/src/mm/page_table/node/entry.rs b/ostd/src/mm/page_table/node/entry.rs index a544ccdd95..b3c696fb4a 100644 --- a/ostd/src/mm/page_table/node/entry.rs +++ b/ostd/src/mm/page_table/node/entry.rs @@ -208,11 +208,7 @@ impl<'a, 'rcu, C: PageTableConfig> Entry<'a, 'rcu, C> { // present-status) and never touches `nr_children`, so the present // count and the counter are both unchanged — keeping the parent's // `count_consistent` invariant intact for the caller. - crate::specs::mm::page_table::node::owners::count_present( - final(parent_owner).children_perm.value(), - ) == crate::specs::mm::page_table::node::owners::count_present( - old(parent_owner).children_perm.value(), - ), + final(parent_owner).count_owned() == old(parent_owner).count_owned(), final(parent_owner).meta_own.nr_children.value() == old( parent_owner, ).meta_own.nr_children.value(), @@ -249,6 +245,8 @@ impl<'a, 'rcu, C: PageTableConfig> Entry<'a, 'rcu, C> { Tracked(new_owner): Tracked<&mut EntryOwner>, Tracked(parent_owner): Tracked<&mut NodeOwner>, requires + // The node owns the slot: writing it may change `nr_children`. + old(parent_owner).owns_slot(old(self).idx as int), old(self).invariants(*old(owner), *old(regions)), new_child.invariants(*old(new_owner), *old(regions)), old(self).node_matching(*old(owner), *old(parent_owner), *old(self).node), @@ -436,12 +434,7 @@ impl<'a, 'rcu, C: PageTableConfig> Entry<'a, 'rcu, C> { } }; }; - crate::specs::mm::page_table::node::owners::lemma_count_present_upto_update( - cp0, - NR_ENTRIES as int, - self.idx as int, - new_pte, - ); + old(parent_owner).lemma_count_owned_update(*parent_owner, self.idx as int, new_pte); } old_child @@ -469,6 +462,8 @@ impl<'a, 'rcu, C: PageTableConfig> Entry<'a, 'rcu, C> { Tracked(regions): Tracked<&mut MetaRegionOwners>, Tracked(guards): Tracked<&mut Guards>, requires + // The node owns the slot: writing it may change `nr_children`. + old(parent_owner).owns_slot(old(self).idx as int), old(self).invariants(old(owner).value(), *old(regions)), old(owner).inv(), old(owner).value().path.len() == old(owner).level(), @@ -624,9 +619,8 @@ impl<'a, 'rcu, C: PageTableConfig> Entry<'a, 'rcu, C> { let tracked new_meta_slot = regions.tracked_borrow_mut_slot_owner(new_paddr); new_meta_slot.paths_in_pt = set![owner.value().path]; - crate::specs::mm::page_table::node::owners::lemma_count_present_upto_update( - cp0, - NR_ENTRIES as int, + old(parent_owner).lemma_count_owned_update( + *parent_owner, self.idx as int, self.pte, ); @@ -1087,12 +1081,7 @@ impl<'a, 'rcu, C: PageTableConfig> Entry<'a, 'rcu, C> { let ghost regions_before_registration = *regions; proof { - crate::specs::mm::page_table::node::owners::lemma_count_present_upto_update( - old(parent_owner).children_perm.value(), - NR_ENTRIES as int, - self.idx as int, - self.pte, - ); + old(parent_owner).lemma_count_owned_update(*parent_owner, self.idx as int, self.pte); let tracked new_slot = regions.tracked_borrow_mut_slot_owner( owner.value().meta_slot_paddr().unwrap(), ); @@ -1260,11 +1249,7 @@ impl<'rcu, C: PageTableConfig> PageTableGuard<'rcu, C> { forall|j: int| 0 <= j < NR_ENTRIES && j != idx ==> #[trigger] final(parent_owner).children_perm.value()[j] == old(parent_owner).children_perm.value()[j], - crate::specs::mm::page_table::node::owners::count_present( - final(parent_owner).children_perm.value(), - ) == crate::specs::mm::page_table::node::owners::count_present( - old(parent_owner).children_perm.value(), - ), + final(parent_owner).count_owned() == old(parent_owner).count_owned(), op.ensures((old(owner).frame().prop,), final(owner).frame().prop), *final(self) == *old(self), )] @@ -1304,12 +1289,10 @@ impl<'rcu, C: PageTableConfig> PageTableGuard<'rcu, C> { proof { owner.tracked_set_frame_prop(new_prop); - crate::specs::mm::page_table::node::owners::lemma_count_present_upto_update( - cp_old, - NR_ENTRIES as int, - idx as int, - pte, - ); + // The PTE at `idx` stayed present (only `prop` changed), so the + // present-count is unchanged by the `write_pte` update — preserving + // `count_consistent` for the caller. + old(parent_owner).lemma_count_owned_update(*parent_owner, idx as int, pte); } pte @@ -1322,6 +1305,8 @@ impl<'rcu, C: PageTableConfig> PageTableGuard<'rcu, C> { Tracked(new_owner): Tracked<&mut EntryOwner>, Tracked(parent_owner): Tracked<&mut NodeOwner>, requires + // The node owns the slot: writing it may change `nr_children`. + old(parent_owner).owns_slot(idx as int), old(owner).inv(), old(owner).is_node() ==> old(owner).node_permission is Some, old(owner).metaregion_sound(*old(regions)), @@ -1479,12 +1464,10 @@ impl<'rcu, C: PageTableConfig> PageTableGuard<'rcu, C> { }; proof { - crate::specs::mm::page_table::node::owners::lemma_count_present_upto_update( - cp0, - NR_ENTRIES as int, - idx as int, - new_pte, - ); + old(parent_owner).lemma_count_owned_update(*parent_owner, idx as int, new_pte); + } + + proof { if new_owner.is_node() { let paddr = new_owner.meta_slot_paddr().unwrap(); let tracked mut new_meta_slot = regions.tracked_borrow_mut_slot_owner(paddr); @@ -1538,6 +1521,8 @@ impl<'rcu, C: PageTableConfig> PageTableGuard<'rcu, C> { Tracked(regions): Tracked<&mut MetaRegionOwners>, Tracked(guards): Tracked<&mut Guards>, requires + // The node owns the slot: writing it may change `nr_children`. + old(parent_owner).owns_slot(idx as int), old(owner).inv(), old(owner).value().path.len() == old(owner).level(), old(owner).value().is_absent(), @@ -1697,12 +1682,7 @@ impl<'rcu, C: PageTableConfig> PageTableGuard<'rcu, C> { nr_children.write(Tracked(&mut parent_owner.meta_own.nr_children), old_nr_children + 1); proof { - crate::specs::mm::page_table::node::owners::lemma_count_present_upto_update( - cp0, - NR_ENTRIES as int, - idx as int, - new_pte, - ); + old(parent_owner).lemma_count_owned_update(*parent_owner, idx as int, new_pte); { let tracked new_node_value = new_node_owner.tracked_borrow_mut_value(); new_node_value.parent_level = level as PagingLevel; @@ -1761,6 +1741,8 @@ impl<'rcu, C: PageTableConfig> PageTableGuard<'rcu, C> { Tracked(new_owner): Tracked<&mut EntryOwner>, Tracked(parent_owner): Tracked<&mut NodeOwner>, requires + // The node owns the slot: writing it may change `nr_children`. + old(parent_owner).owns_slot(idx as int), old(owner).inv(), old(owner).is_absent(), old(owner).metaregion_sound(*old(regions)), @@ -1828,12 +1810,7 @@ impl<'rcu, C: PageTableConfig> PageTableGuard<'rcu, C> { }; proof { - crate::specs::mm::page_table::node::owners::lemma_count_present_upto_update( - cp0, - NR_ENTRIES as int, - idx as int, - new_pte, - ); + old(parent_owner).lemma_count_owned_update(*parent_owner, idx as int, new_pte); } } }