Repository navigation
Conversation
kernel_will_write only opened the guarded blocks of view memory a ReadFile, fread or DirectStorage read was about to write. The next refresh on any other thread guarded them again, and if that came before the kernel wrote, the read failed with ERROR_NOACCESS. Announced blocks are now counted until the runtime reports the read done (kernel_wrote); guard() reports them written but leaves them open while the count is not zero. An overlapped ReadFile still pending keeps its blocks open. Fixes Marvisak#723.
|
Independent Wine validation of The new Full workspace unit/integration suite, all features, all 14 generated Windows test executables, offline and offscreen:
GPU: 53 passed / 1 failed / 1 ignored; HLE: 93 passed / 1 failed. The failures are unchanged from baseline: empty pipeline library (#347), missing Wine Winsock export (#217), the shader-checksum rejection expectation, the nested Cargo fixture build, and Windows xtask's attempt to launch host Git. Native Linux xtask separately passes all 4 tests. The runtime/DLL configuration was identical in both full runs; native Windows-target workspace Clippy with all targets/features and Not tested: gameplay, pending/overlapped I/O completion, native Windows/WARP, or Wine doctests. Aggregate counts include existing tests that return early when optional console compilers or the DXIL validator are missing; the new memory-guard regression has no such skip. AI-assisted testing with Codex. |
|
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 8d7e3a0: Tested with AI assistance (Claude). |
|
Thanks for this, holding the blocks open until the read lands makes sense. One defect at 8d7e3a0, found by reading, not run:
Suggestions: keep the announced reads as ranges (a list of A smaller point, already marked as a shortcut: an overlapped AI-assisted (Claude Code). |
kernel_will_write and kernel_wrote touched a map entry per 64 KiB block of the announced range, under the guards lock. fread announces the title's size times count, saturated, so a saturated length meant about 2^48 iterations and a map growing with them. One block range is now kept per announcement, and guard() checks a block against the ranges in flight (few at a time).
|
@TG0000 good catch, thanks: confirmed and fixed in
On the pending overlapped |
…t lands Head 8d7e3a0 (Dufftwt). Merged without conflicts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thank you for this, @Dufftwt! Many pull requests here are still waiting to be merged, so I've ported this one to 465d6a0eac/AgentRecompVI, a VIctory fork where AI agents review and merge each other's work: https://github.com/465d6a0eac/AgentRecompVI/pull/36. You're credited as the author there. This stays the original. Test results
|
… it is remapped Head 6739366 (TG0000). Conflicts in watch.rs: guard() asks our allocation-type query (`mapped`, now `mapped_until`, which also gives the view region's end) once per block until a remap, outside the lock, and keeps #1025's announced blocks open. title_memory_remapped keeps our empty-range return, placed-texture eviction and bindless refresh, and counts remaps and forgets the remembered views. xmem.rs: every unmapping of a view, the undo of a failed mapping too, goes through unmap_title_view (reported after the unmapping). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Automated triage for the maintainers. Closing because this change is already in Already in main: an announced kernel write returns a guard that keeps its blocks open until dropped (watch::Writing, used by files.rs and dstorage.rs). If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution. |
Fixes #723.
What's wrong
View memory (xmem's physical-page views) is tracked by making 64 KiB blocks read-only (
guard,crates/victory-gpu/src/watch.rs). A system call can't write into a read-only block:ReadFilefails withERROR_NOACCESSinstead of faulting into our handler. So the runtime announces its kernel reads first withvictory_gpu::kernel_will_write:ReadFileandfreadinfiles.rs, raw DirectStorage reads indstorage.rs.kernel_will_writeonly opened the blocks. The nextguard()covering them, from any thread, made them read-only again, and the submitting thread calls it at every refresh. If that came between the announcement and the kernel's write, the read failed. DirectStorage then returned the error to the title, andfreadcame back short. The window lasts as long as the read.What the fix does
watch.rskeeps one block range per announced read still to land (Guards::announced).kernel_will_writeopens the blocks and records the range.kernel_wroteremoves it.guard()still reports a block in a recorded range as written, but leaves it open.freadannounces the title's size times count, saturated, so a length can span the address space. The cost doesn't depend on the length, and few reads are in flight at a time.kernel_wroteonce each read returns: afterReadFileandfreadinfiles.rs, and after the raw DirectStorage fill indstorage.rs.shortcut:an overlappedReadFilethat returnsERROR_IO_PENDINGkeeps its range for good, since its end isn't seen. They're then copied at every refresh, which is correct, just slower. Grand Theft Auto VI's reads go through the synchronous path.watch::writing, which our own copy-back and texture writes use from the submitting thread, is unchanged and nowpub(crate).How it behaves after the fix
A kernel read into guarded view memory succeeds however many refreshes run on other threads before it lands. Once it's done, the next refresh guards the block again and copies what the read wrote.
Tests
an_announced_kernel_read_survives_a_refresh_before_it(watch.rs) replays the two threads' order on one thread, with a real pagefile view and a real file read:kernel_will_write.guard(), as another thread's refresh does for view memory.kernel_wrote: the nextguard()must report the block and guard it again, so a further unannounced read fails.an_announcement_as_long_as_the_address_space_is_cheap(watch.rs) announces and lands a read of saturated length, above user space so that no other test's blocks are in it.I ran
cargo test -p victory-gpu -p victory-hle -- --test-threads=1on GitHub'swindows-latestwith Rust 1.98.1 fromrust-toolchain.toml:victory-gpu: 52 passed, 1 ignored;victory-hle: 94 passed), also with the default parallel test threads.main(ffe310e, announcing with today'skernel_will_write): the read fails:the refresh guarded the block again under the read.8d7e3a0, one map entry per block): it hadn't finished when the step timed out after 5 minutes. TG0000 found this by reading.cargo clippy -p victory-gpu -p victory-hle --all-targets -- -D warningsis clean, with and without--all-features.Not tested: a title run, and overlapped reads (none known in the title).
Related: #393, #413, #464 and #490 change
guardortitle_memory_remappedwithout keeping an announced block open. #991 changeswatch::openon nearby lines, so whichever merges second needs a rebase.