Fault handler rebase - #89
Conversation
PR #88 fixed reset_keep_all_work_memory resolving the master's copy-back source through main_memory().safely_at(vaddr), which is only correct for identity-mapped memory. File-backed mmap regions live at MMAP_PHYS_BASE (32GB), so any recorded page backed there was restored from an unrelated identity-mapped page -- in practice zeros -- and the fork came back from reset with silently wrong contents. It shipped without a test. The test maps a 4MB pattern file into a master, forks, writes to the mapping, resets with reset_keep_all_work_memory and requires the pattern back. It fails on the parent of #88 (reads 0x00, expected 0x5A) and passes on #88. mmap_backed_area only installs MMAP_PHYS_BASE-backed memory for the part of the range that is 2MB-aligned and 2MB-sized; a smaller mapping falls back to preadv into ordinary identity-mapped memory, where the bug does not reproduce and the test would pass for the wrong reason. Hence the 4MB file, the 2MB-aligned base, and the explicit page-table check that the leaf really does resolve above MMAP_PHYS_BASE. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ter's live root PR #88 correctly changed fork_reset to resolve the master's copy-back source through the page tables, but it walks from main_memory().page_tables. For a master with working memory that is the banked PML4 the master itself executes on, whose entries have been redirected to bank pages holding writes the master made *after* prepare_copy_on_write(). setup_cow_mode() deliberately roots forks at physbase + PT_ADDR to exclude exactly those pages ("we use the fixed PT_ADDR directly in order to avoid duplicating the memory banked page tables"). So a fork never sees the master's post-prepare writes -- but after #88 a reset_keep_all_work_memory reset did, restoring a state no fresh fork and no full reset produces. Observable as "Fork w/working memory sanity checks" in tests/unit/fork.cpp: after the master runs get_value() once, a fresh fork and a full reset both see value == 0, while a keep-work-memory reset saw 1. Pass the baseline root explicitly. readable_page_at() takes an optional root (0 = memory.page_tables, unchanged for every other caller). #88's actual fix is untouched: mmap regions are installed in the PT_ADDR-rooted tables too, since that is the only view forks ever get. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Post-merge notes from reading the diff (fast-agent will pick this up on the next rebase):
|
|
Thanks, I forgot to run a review on it. These changes are from the before-times, and I found them in an old branch in a submodule on this machine. It was important to get them in before they got lost again! I'll make a review as well and fix the issues already found |
No description provided.