upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/shims/xmem.cpp
diff options
context:
space:
mode:
authorZack <zmasi21@gmail.com>2026-11-26 02:02:47 -0800
committerZack <zmasi21@gmail.com>2026-11-26 02:02:47 -0800
commitd088ea79b8394c04a46ec19efb2922a7cd3faae3 (patch)
tree47526a94199ce24c66f9436a46886173914628a1 /runtime/shims/xmem.cpp
parenta73a57e1339be072baf5522351c8ec7f1482b56b (diff)
Sync title texture readability with map journal between refresh passes
Between periodic refresh_title_textures passes, synchronous slot-70 view creation and the async fill worker checked TextureReadability with a constant generation, missing title_memory_map range changes since the last pass. Track the map generation on TextureReadability and consult title_memory_map::changes_since outside refresh passes so unmapped or decommitted pages defer before hashing and newly mapped pages publish immediately without waiting for a submission. Also mark mix_words and hash_bytes LEONIDA_GUARDED_NO_BUILTIN using an unaligned 64-bit load so clang-cl cannot emit CRT memcpy calls inside the __try frame, and classify non-title read faults over unmapped title pages in xmem::physical_page_fault as FaultExit::passed_guarded.
Diffstat (limited to 'runtime/shims/xmem.cpp')
-rw-r--r--runtime/shims/xmem.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/runtime/shims/xmem.cpp b/runtime/shims/xmem.cpp
index 384f7bd27..964cc9216 100644
--- a/runtime/shims/xmem.cpp
+++ b/runtime/shims/xmem.cpp
@@ -1575,7 +1575,7 @@ LONG CALLBACK physical_page_fault(EXCEPTION_POINTERS* info) {
1575 MEMORY_BASIC_INFORMATION seen{}; // the page as the decision saw it 1575 MEMORY_BASIC_INFORMATION seen{}; // the page as the decision saw it
1576 char read_note[1024]; 1576 char read_note[1024];
1577 DWORD read_note_size = 0; 1577 DWORD read_note_size = 0;
1578 bool plant_read = false, promote = false; 1578 bool plant_read = false, promote = false, from_title = false;
1579 bool queried = false; 1579 bool queried = false;
1580 { 1580 {
1581 const FaultLockShared lock; 1581 const FaultLockShared lock;
@@ -1594,7 +1594,8 @@ LONG CALLBACK physical_page_fault(EXCEPTION_POINTERS* info) {
1594 if (where != kNoReservation || access == 1) 1594 if (where != kNoReservation || access == 1)
1595 queried = VirtualQuery(reinterpret_cast<const void*>(accessed), &seen, sizeof(seen)) != 0; 1595 queried = VirtualQuery(reinterpret_cast<const void*>(accessed), &seen, sizeof(seen)) != 0;
1596 const auto pc = reinterpret_cast<uintptr_t>(record->ExceptionAddress); 1596 const auto pc = reinterpret_cast<uintptr_t>(record->ExceptionAddress);
1597 if (access == 0 && result == PageCommit::not_ours && title_code(pc)) { 1597 from_title = access == 0 && result == PageCommit::not_ours && title_code(pc);
1598 if (from_title) {
1598 if (!queried) queried = VirtualQuery(reinterpret_cast<const void*>(accessed), &seen, sizeof(seen)) != 0; 1599 if (!queried) queried = VirtualQuery(reinterpret_cast<const void*>(accessed), &seen, sizeof(seen)) != 0;
1599 read_note_size = describe_read(read_note, pc, accessed, seen); 1600 read_note_size = describe_read(read_note, pc, accessed, seen);
1600 plant_read = where == kInWindow && g_pool_zero_pages; 1601 plant_read = where == kInWindow && g_pool_zero_pages;
@@ -1670,7 +1671,8 @@ LONG CALLBACK physical_page_fault(EXCEPTION_POINTERS* info) {
1670 exit = FaultExit::committed; 1671 exit = FaultExit::committed;
1671 } else if (answered) { 1672 } else if (answered) {
1672 exit = FaultExit::answered; 1673 exit = FaultExit::answered;
1673 } else if (result == PageCommit::committed_before && !escalated) { 1674 } else if ((result == PageCommit::committed_before && !escalated) ||
1675 (title_page && access == 0 && result == PageCommit::not_ours && !from_title)) {
1674 exit = FaultExit::passed_guarded; // a guard's (the D3D12 layer's), routine: not noted 1676 exit = FaultExit::passed_guarded; // a guard's (the D3D12 layer's), routine: not noted
1675 } else if (title_page || reserved_write) { 1677 } else if (title_page || reserved_write) {
1676 note_fault(kRefused, accessed, access, result, where, seen); 1678 note_fault(kRefused, accessed, access, result, where, seen);