Repository navigation
Conversation
On a host without CLWB every execution of the instruction raised #UD and the vectored handler emulated it. The retail title's GPU upload worker flushes whole buffers with CLWB in a 64-byte loop (exe+0x532f1b0 on 1.0.2.1), so a buffer cost one exception per cache line; under Wine that kept the worker busy for minutes and the main thread polling its event in session 0xd, so the boot never left the first-run pages. The handler now rewrites the instruction at its first #UD: 66 0F AE /6 becomes 66 0F AE /7 (CLFLUSHOPT), the same operand and length, which also writes the line back; a host without CLFLUSHOPT gets 66 0F 1F /0, a NOP of the same length. LEONIDA_CLWB_PATCH=0 keeps the old per-execution emulation. Tested: cpu_emulation_test under Wine 11.21 on an i9-9900KF (no CLWB, has CLFLUSHOPT): both sites rewritten, SIB and displacement kept, the code runs again. Retail boot on the same machine with ProjectLeonida#984 + ProjectLeonida#968 (RTX 2070 SUPER, Fedora 44): the worker that sat in the CLWB loop at 420, 540 and 660 s now moves on, and the title gets past the first-run pages into the story load. AI-assisted: yes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RBZntAmGCDe3LdLjbzZzuc
|
Tested 85b8f5b on AMD Ryzen 5 7500F (Zen 4) + NVIDIA GeForce RTX 4060, driver 617.42, Windows 11 Pro build 26200, native Windows (not Wine): pass. Built at this head with
AI-assisted (Claude Code ran the build and tests). No game files. |
|
Independent verification (CPU-only change): built |
|
Confirmed on another Intel CPU without CLWB, on native Windows: i5-9400F (6 threads; no SSE4a, CLZERO, MONITORX or CLWB), RTX 2060 SUPER, NVIDIA 617.14, Windows 11 26300, retail 1.0.2.1. I compared two 600 s boots of the same tree:
So on this CPU the "freeze at 0xd" was the per-cache-line #UD of the CLWB flush loops, plus first-run input. AI-assisted: yes (Claude Code, Opus 5.5) |
|
Tested 85b8f5b on an Intel i7-10700K (no SSE4a, CLZERO, MONITORX or CLWB), RTX 3080 10 GB, NVIDIA 610.88, Windows 11 Pro 26200, retail 1.0.2.1, native Windows. AI-assisted (Claude Code, Claude Opus 5.5). On this CPU it is the difference between a stuck and a working loading screen. Same tree (main 88479ff + #2138 + #1914 + #1886 + #2179), same scripted presses (A at 60/75/90 s),
|
Claimed in #14 as
RT-CLWB-PATCH.What and why
On a CPU without CLWB (Intel desktop before Ice Lake, AMD before Zen 2) every execution of CLWB raises #UD and the vectored handler in
cpu_emulation.hemulates it. The retail title's GPU upload worker flushes whole buffers with CLWB in a 64-byte loop (exe+0x532f1b0on 1.0.2.1), so each buffer costs one exception per cache line. Under Wine an exception costs tens of microseconds, and in thread snapshots (LEONIDA_STACKS) that worker sat in the same loop at 420, 540 and 660 s while the main thread polled its event (WaitForSingleObject(h, 0)in a 1 ms loop) in session0xd. The first-run pages never finished.The handler now rewrites the instruction at its first #UD:
66 0F AE /6(CLWB) becomes66 0F AE /7(CLFLUSHOPT): the same operand and length (only the ModRM reg field changes), and it also writes the line back (and then evicts it);66 0F 1F /0, a NOP of the same length that touches no memory.Each site then faults once.
LEONIDA_CLWB_PATCH=0keeps the per-execution emulation.Tested
cpu_emulation_testunder Wine 11.21 (Staging) on an i9-9900KF (no CLWB, has CLFLUSHOPT): all checks pass, including the new ones (both sites rewritten, SIB and displacement kept, the rewritten code runs again).0xdto0) into the story load. Without it, the same setup stays in0xd.No game data in the change or in this text.
AI-assisted: yes
🤖 Generated with Claude Code
https://claude.ai/code/session_01RBZntAmGCDe3LdLjbzZzuc