Repository navigation
Conversation
`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 <noreply@anthropic.com>
vilhelms
force-pushed
the
vilhelm/nr-children-owned
branch
from
November 23, 2026 18:56
05e6e52 to
920c5fd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
count_consistent(part ofmetaregion_sound_node) saysnr_childrencounts every present PTE of a node. Upstream counts only the children a node owns:create_user_page_tablecopies the kernel half of the top level into a new user root withwrite_pteand does not incrementnr_children; the user root borrows those entries.PageTablePageMeta::on_dropwalks onlyTOP_LEVEL_INDEX_RANGEfor a top-level node, so it never drops them.So after
create_user_page_tablethe new user root breakscount_consistent(256 present PTEs,nr_children == 0). Main does not notice because the function drops the new page table's owner, but anything that later needs a sound owner for that page table would fail.Changes
NodeOwner::owned_range:TOP_LEVEL_INDEX_RANGEfor a top-level node, all slots otherwise.count_ownedcounts the present PTEs in it;count_consistentis nownr_children == count_owned().count_present_betweenand its lemmas replace the whole-arraycount_presenthelpers, which are removed.lemma_count_owned_update: writing a slot changes the count only if the node owns the slot.replace,alloc_if_none,replace_child,alloc_absent_child,replace_absent_with_frame) requireowns_slot(idx). The cursor discharges it with the newCursorOwner::lemma_cur_slot_owned(inside its range, the current node owns the slot it points at).lemma_view_rec_nr_children_zero_emptyrequires a node below the top level, as its one caller has.create_user_page_tablenow proves the new user root stayscount_consistentthrough the copy loop.No trusted code is added and no executable code changes.
cargo dv verify -p ostd: 1491 verified, 0 errors (main: 1489).Noticed but not changed: vostd's trusted
on_dropomits upstream'sif nr_children == 0 { return; }early return.🤖 Generated with Claude Code