mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:40:52 +01:00
[PR #826] cpu: handle reserved XMem backing during CLZERO emulation #863
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#863
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/826
Author: @moffington
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:submit/xmem-clzero-first-touch📝 Commits (2)
44f4dc3Commit XMem backing for emulated CLZERO writesd62aa5bCover batched XMem CLZERO across a protected boundary📊 Changes
5 files changed (+235 additions, -15 deletions)
View changed files
📝
runtime/CMakeLists.txt(+5 -1)📝
runtime/shims/xmem.cpp(+20 -2)📝
runtime/shims/xmem.h(+4 -0)📝
runtime/src/cpu_emulation.h(+11 -2)📝
runtime/test/cpu_emulation_test.cpp(+195 -10)📄 Description
Claimed in the coordination issue as: RT-CLZERO-XMEM
What and why
Emulated CLZERO raised a false write access violation on XMem pages that were untouched or that Wine still reported as reserved after a successful CPU write. The handler now checks the exact faulting subpage, commits its XMem backing when eligible, then rechecks live protection before zeroing the cache line. Initially read-only and unrelated mappings stay reserved. Read-only, no-access, and one-shot guard protections still apply.
Tested
d0da7dadeand passed with this change, including 20 repeat runs. It covers concurrent first touches and partially committed XMem pages.d3d12_xmem_placedpassed on an NVIDIA GeForce RTX 3060 with driver 615.78.08. Stockxmemreproduced the same five Wine failures before and after: two metadata checks, one commit-accounting check, and two protection-setup checks.SEC_RESERVEand Wine’s defaultSEC_COMMITmode. Both CPU test cases passed three consecutive runs each on the rebased branch.SEC_RESERVEmode when built against the CPU-emulation header from eithermainor #2035.AI-assisted with OpenAI Codex.
Known limitation
The protection check and the zeroing write are separate operations, so there is no atomicity guarantee against a concurrent remap or protection change.
Overlap with other open PRs
writable()change here. Whichever lands second needs the XMem first-touch check carried intowritable_region().writable(); clang-cl keeps the check. The test entry points conflict. A clang-cl/Wine control with its SEH write helper still passed the batch checks. Native MSVC is untested.main. If its fault-ahead commit is applied to emulated writes, the adjacent-page reservation assertion may need updating; the protected-boundary and byte-preservation assertions should still hold.CI
CI pending on the rebased commit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.