Watch: a kernel write into title memory refused by a guard set again is opened and made #1007
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1009"
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?
Imported from fxceless/victory-fork. Originally posted by cmt8 on 2026-11-25T15:57:25Z.
What breaks today
Since
8dd30ab4, a copy over one view of a physical page guards every view of it. Our own writes into title memory go through the kernel (the copy-back'swrite_mapped,copy_mappedinto title memory, a title's synchronousReadFile). A guard set again betweenwritingand the kernel's write makes the kernel refuse it. Under Wine it does not fault into our handler:NtWriteVirtualMemory/NtReadVirtualMemory/NtReadFilecheck the buffer withvirtual_check_buffer_for_writeand copy under their own exception guard (dlls/ntdll/unix/virtual.c, file.c). So a copy-back is lost, andcopy_mapped's piece-by-piece fallback writes zeros over the title's bytes.The change
One commit, cherry-picked from our 738f7148.
watch::kernel_write_refused(at, len)opens whatever is guarded there now and says whether anything was.write_mappedandcopy_mapped(title destination, and its 64 KiB / 4 KiB fallback) retry a refused piece once before writing zeros. A synchronousReadFilethat fails withERROR_NOACCESS/ERROR_INVALID_USER_BUFFERwhile a guard lay over its buffer is made again, up to three times. Overlapped reads are left alone, because a refused one still posts a completion. The refused writes are counted on a status line next to the page-writes one.VICTORY_READ_BESIDE=0turns this off, together with 8dd30ab4's read-beside offreadand DirectStorage file reads, for A/B testing.Evidence
main's newguardsdefault covers part of it and we have not isolated what is left. So this observation does not show this commit's effect on its own.watch::tests::a_kernel_write_refused_under_a_guard_set_again_is_made: a copy-back write into a view that was opened, then guarded again through the other view, lands. It passes under Wine. WithVICTORY_READ_BESIDE=0it fails ("the write landed"), which is the lost write.wine-testxtask from Marvisak/VIctory #1218 (not part of this PR): thewatch::tests pass on this commit. The full run was made with the held-back commit on top: victory-gpu 164 passed, 8 failed, the same 8 that fail on0b0074e0; victory-hle 97 passed, 1 failed, unchanged.Not verified
Related
main, which has 8dd30ab4's form of the same report.mainnow reads beside instead. This PR coversReadFile,write_mappedandcopy_mapped.VICTORY_COPY_PLAINcopy in-process so writes fault into the guard. That is another way around the same refusal, off by default.AI-assisted (Claude Code); no game data.
Pull request closed