fix(vk): preserve CPU write watches during pool imports #1434
No reviewers
Labels
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
testing wanted
wontfix
No milestone
No assignees
1 participant
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Hookshot!1434
Loading…
Reference in a new issue
No description provided.
Delete branch "codex/preserve-import-write-watches"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What this fixes
CPU write diagnostics can miss a write immediately after a GPU memory pool is imported when a built-in watch mode is enabled. This hides the write being investigated until the watcher rearms.
Why merge
Change
gpu/vk/vk_memory.cpp: select the existing query walk when CPU write watching is requested.tests/test_import_write_watch.py: check real Windows page protection and write exceptions on synthetic pages.tests/run_all.py: register the check.Tested
python -I -B tests/test_import_write_watch.py --cxx clang++covers all four watch modes, ordinary commits and forced commit failure.vk_memory.cppsyntax check pass.Not covered
Looks right to me. On Windows,
MEM_COMMITover pages that are already committed does reset their protection, so the one-call commit could quietly unprotect a watched page untilwts_rearmput it back (up to about 2 ms later). The old walk skips anything that isn'tMEM_RESERVE, so watched pages stay read-only.I checked the switch list against main. All four switches reach
hos_watch_guest_writesorwatch_texels_source:RX_NVN_WATCH_TEXandRX_NVN_WATCH_TEXELS_SRCdirectly in nvn_native.c, andRX_VK_WATCH_CPU(vk_replay.cpp) andRX_VK_VERIFY_DIM(vk_texture.cppverify_report) throughhost->watch_guest_writes. Nothing else callsVirtualProtecton guest memory, so the list is complete today. Linux doesn't change: the posixVirtualAllocreturns early for commits inside the guest window, andVirtualQueryreports that window as a single committed region.The new test runs and passes on the windows-2022 CI job (not just a skip), and it's registered in run_all.py. CI is green. No overlap with #1127 (its vk_memory.cpp hunks are the includes and
mirror_make) or with #1353's run_all.py line.Two small optional things:
hos_watch_guest_writes/watch_texels_source("some guest page is protected") would be exact, and it would keep the fast path until a watch is actually armed. Your comment already says this, and the static list is fine for a diagnostics-only path.#ifdef __linux__. If someone rewords that comment, the test fails with a bareValueError. A clearer error message there would help whoever hits it.@ -358,3 +357,4 @@if (page_watches || VirtualAlloc(ptr, (SIZE_T)bytes, MEM_COMMIT, PAGE_READWRITE) != ptr)for (uint8_t* q = ptr; q < ptr + bytes;) {MEMORY_BASIC_INFORMATION mi{};if (VirtualQuery(q, &mi, sizeof mi) != sizeof mi) break;nit:
ponytail:looks like a leftover tag. Nothing else in the tree uses it. Maybe just(add new page-watch switches here; ...).