Repository navigation
fix(libc): track never-collected pages in the macOS write watch - #3703
Merged
adriadam10 merged 1 commit intoOct 11, 2026
Merged
Conversation
On macOS, GuestWriteWatchCollectFresh reported nothing and returned true, so MarkWritten took pages no collection had armed yet for clean, and they stayed writable without being tracked. GuestWriteWatchCollectArmed was a full collect, which also took those pages. Pages now carry a fresh bit from registration until a collection takes them, as the Linux watch keeps its fresh ranges: CollectFresh reports and arms only fresh pages, CollectArmed skips them, and Collect takes both. Protection changes, host writes and faults keep the bit. The write_watch fresh and armed tests check both collections.
yabanana
added a commit
to yabanana/AnyPS5
that referenced
this pull request
Oct 11, 2026
Reuse the regression cases from upstream PR boykopovar#3703 at 99ddfa7. The macOS foundation already supplies the fresh-page behavior; run its regression cases against the native graphics closure as well.
This was referenced Oct 11, 2026
Collaborator
|
Checked the diff: the fresh bit is set on every |
Open
mugurc
added a commit
to mugurc/AnyPS5
that referenced
this pull request
Oct 12, 2026
Conflicts: the write watch takes main's fresh-page tracking (boykopovar#3703) in place of the port's own; main's comparison fix replaces the port's ordered not-equal; the kqueue, getc_unlocked and socketpair notes in TechnicalDebt.md and the Rosetta sentence in BUILD.md are kept next to main's new entries; the Apple branches of ModuleInfo.cpp, Stdio.cpp and SharedMemory.cpp stay beside main's additions. The macOS build of what main added follows in the next commit.
ycarogabriel-lgtm
pushed a commit
to ycarogabriel-lgtm/AnyPS5
that referenced
this pull request
Oct 18, 2026
Conflicts: the write watch takes main's fresh-page tracking (boykopovar#3703) in place of the port's own; main's comparison fix replaces the port's ordered not-equal; the kqueue, getc_unlocked and socketpair notes in TechnicalDebt.md and the Rosetta sentence in BUILD.md are kept next to main's new entries; the Apple branches of ModuleInfo.cpp, Stdio.cpp and SharedMemory.cpp stay beside main's additions. The macOS build of what main added follows in the next commit.
11 tasks done
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.
What
On macOS,
GuestWriteWatchCollectFreshreported no pages and still returnedtrue, andGuestWriteWatchCollectArmedwas a fullCollect. The Linux watch treats them differently:CollectFreshreports and arms only the ranges no collection has taken since registration, andCollectArmedleaves those ranges alone. On macOS,MarkWritten(Execution/src/GuestMemory.cpp) therefore counted pages that were never armed as clean, and they stayed writable with no tracking. A laterCollectArmedalso took them, which the caller does not expect.The macOS backend now gives each page a fresh bit, set at registration (including a second registration) and cleared when a collection takes the page:
Collecttakes fresh and armed pages, the same as before.CollectFreshreports and arms only fresh pages and, like the Linux version, does not require the whole range to be covered.CollectArmedskips fresh pages.Without
APS5_NO_WRITE_WATCHnothing else changes. With the watch disabled,CollectFreshnow returnsfalse, the same as Linux; it no longer returnstruewithout collecting anything.New
write_watch_freshandwrite_watch_armedtests in the standalone macOS write-watch suite (core/libs/tests/WriteWatch.cpp) check both collections. They mirrorCheckWriteWatchFreshCollectandCheckWriteWatchArmedCollectincore/libs/tests/GuestMemory.cpp, which run only on Linux.Tested
cmake -S core/libs/tests/write_watch), run natively on arm64 and as x86-64 under Rosetta 2 (CMAKE_OSX_ARCHITECTURES=x86_64). All 8write_watch_*tests, includingwrite_watch_mappedfrom fix(libc): watch direct memory mapped over its reservation on macOS #3478, pass with--repeat until-fail:3.write_watch_freshandwrite_watch_armedfail and the other six pass.agc_driver_graphics. Upstream's full build does not compile on macOS, so that test cannot run on this branch as it is.__APPLE__backend and the macOS-only test.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)