Repository navigation
Conversation
Rosetta 2 runs VMASKMOVPS / PD and VPMASKMOVD / Q to memory an element at
a time and resumes a fault only on the first element; a fault on a later
one ends the process ("rosetta error: unexpectedly need to EmulateForward
on a synchronous exception"). Under Wine on macOS the write watch keeps
pages protected, so a title's masked store that crosses into a watched
page ends the run. The remedy (later commits) replaces each such store at
image load with a call to a helper that stores one element at a time.
This commit is the first part: `maskmov::insn_len`, the length of an
x86-64 instruction (to walk a function from its start to a candidate
site), and `maskmov::decode`, the four stores with any memory operand.
Nothing calls them yet.
Split out of mac-on-main-wip b51552b (xcl-dev#258).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Regression run of Against the limits in CONTRIBUTING.md: 100 % of AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, AI use: Claude Code (Claude Opus 5.5) built both trees and ran |
|
NVIDIA test report for
Lib tests only; no title run. AI-assisted (Claude Code, Claude Opus 5.5). |
|
Thanks @upipibi for the NVIDIA run. Each part of the masked-store stack now has a run from someone other than me; it waits for a maintainer review and merges cleanly into |
|
merge-check claim |
|
merge-check |
|
merge-check claim |
|
merge-check |
|
#1311, #1313 and #1344 share these lines because they are stacked on this PR (helpers, AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
First of four PRs that bring @Ahmet-Dedeler's masked-store fix for Rosetta 2 from
mac-on-main-wip(b51552b,04e9301) tomain, split by the size rule. Part of #258.Rosetta 2 runs VMASKMOVPS / PD and VPMASKMOVD / Q to memory an element at a time and resumes a fault only on the first element; a fault on a later one ends the process (
rosetta error: unexpectedly need to EmulateForward on a synchronous exception). Under Wine on macOS the write watch keeps pages protected, so a title's masked store that runs into a watched page ends the run. The fix replaces each such store at image load with a call to a helper that stores one element at a time. This PR is only the decoding; nothing calls it yet.Plan for the rest (each its own PR, stacked): 2. the helpers,
call_siteand their unwind data, with the tests that run each helper against the instruction itself; 3.plan, which finds the sites of an image by walking from the start of each function; 4. the loader step (XCL_MASKED_STORES, on only under Rosetta 2), the one runtime change.What is in it
maskmov.rs(new):insn_len(length of an x86-64 instruction,Nonefor what a walk must not guess at),decode/is_candidate(the four stores with any memory operand), and two unit tests,instruction_lengthsanddecodes_the_masked_stores. Code and tests are Ahmet's fromb51552b, unchanged; only the module comment now lists what this PR has. The commit keeps him as its author.lib.rs:pub mod maskmov;.Tested
x86_64-pc-windows-gnuwith mingw-w64 (GCC 16.2.0), Rust 1.100.0, debug; the lib test binary run under CrossOver'swine.maskmov::on this head: 2 passed, 0 failed.b51552bmodule onmain930e8b4(cherry-picked as is):maskmov::7 passed, 1 ignored. The ignored one (the_instruction_itself_across_a_watched_page_boundary), run with--ignored, ends the process here as on Ahmet's M5 Pro: "a fault on the first element was resumed; now one on the fourth", thenrosetta error: unexpectedly need to EmulateForward on a synchronous exception … inst_index=18.Regression run
From @Toons29: AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, Windows 11 build 26300, release builds,
scripts/smoke.ps1, the same retail title for 60 s,main4178e88and this head: 100 % ofmain's frames, 100 % of its peak commit, no crash, no device removal.Nothing calls this code yet, so the pair shows only that the title runs as on
main.Not tested
cargo test --workspaceas a whole (it does not finish under CrossOver, see macOS (Apple Silicon, CrossOver + D3DMetal): the newer retail game reaches its first-run menus at 30 fps #258).insn_lenagainst Capstone on 22.4 million instructions of a retail image (in his HANDOFF notes onmac-on-main-wip); I did not repeat that.AI use
claude-opus-5-5): split the commit, ran the tests above and wrote this description. The code and tests are Ahmet's.