mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-18 04:49:57 -04:00
Let a shadow write-back clear the write watch's protection of its range in one call on Linux (shadow_bulk_write = 1).
On Linux the write watch protects pages, so a write-back from shadow storage into guest memory took a fault at the first store into every page. plat_mem_prepare_write clears the protection of a range with one UFFDIO_WRITEPROTECT call; the pages count as written, as they would after the faults. Off by default; Windows has nothing to clear. Pull request #327 by theurbanninja1993-sketch (a draft on GitHub). The platform function and its Linux test are taken as they are. The call moved: the write-back it was written for is now shadow_write_back in runtime/vk_memory.c (a file other sessions are changing), where it covers the runs of pages a submission changed, and the setting is registered in cfg.c and described in nx2navi.ini.example, which also says that the lazy write-back stays off with shadow storage. The Windows files compile; the Linux code and its test are not compiled or run here. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -1191,6 +1191,14 @@ int plat_mem_census(uint64_t *priv, uint64_t *wc, uint64_t *wc_allocs) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int plat_mem_prepare_write(uint64_t addr, uint64_t n) {
|
||||
if (ww_fd < 0 || !n || addr >= PS_LIMIT || n > PS_LIMIT - addr) return 0;
|
||||
uint64_t lo = addr & ~(PG - 1), hi = (addr + n + PG - 1) & ~(PG - 1);
|
||||
struct uffdio_writeprotect wp = {.range = {lo, hi - lo}, .mode = 0};
|
||||
// PAGEMAP_SCAN observes cleared protection as written, just as after an asynchronous write fault.
|
||||
return ioctl(ww_fd, UFFDIO_WRITEPROTECT, &wp) == 0;
|
||||
}
|
||||
|
||||
uint64_t plat_mem_written(uint64_t addr, uint64_t n, uint64_t *pages, uint64_t max, int reset) {
|
||||
if (!max || !n) return 0;
|
||||
if (ww_fd < 0) return UINT64_MAX;
|
||||
|
||||
Reference in New Issue
Block a user