ProjectScarlett: clwb crashes on CPUs without CLWB (pre-Ice Lake Intel), clflushopt rewrite fixes it #71
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/brcly--TuxBox#71
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?
@jessebuffington on GitHub · 2026-11-24 16:22 UTC · original
Summary
On an Intel Core i9-9900 (Coffee Lake), ProjectScarlett exits about 5 seconds after launch with
EXCEPTION_ILLEGAL_INSTRUCTION. The faulting instruction isclwb. The Xbox Series CPU (Zen 2) supports it, but Intel desktop CPUs before Ice Lake/Tiger Lake don't. The window opens, flashes white and closes. Exit code 29.Affected sites
The executable has 8
clwbinstructions. All of them are in the same cache-line write-back loop (clwbover 64-byte lines up to an end pointer). File offsets of the66prefix:0x4e4aa8066 0f ae 31(%rcx)0x4ecbc4a66 41 0f ae 31(%r9), the first one hit0x50f69f566 41 0f ae 30(%r8)0x532e5b066 0f ae 30(%rax)0x532e5f066 0f ae 30(%rax)0x532e63066 0f ae 30(%rax)0x532e68066 0f ae 30(%rax)0x532e6ba66 0f ae 30(%rax)Workaround (verified)
clflushopthas the same encoding except for the ModRM reg field (/7instead of/6), so it's a same-length, 1-byte change per site: set bit 3 of the ModRM byte (0x30→0x38,0x31→0x39). Likeclwb, it writes the line back to memory, and it also evicts the line from cache. It is available on Intel Skylake and newer and on every Zen CPU. Haswell/Broadwell have neither instruction, so they would need plainclflush(0F AE /7without the66prefix) or a skip.With all 8 sites rewritten in a copy of the exe, the illegal-instruction crash is gone. The game gets further: it creates the 3840×2160 display surfaces and starts creating pipelines. On my GPU it then hits a separate crash (see the other issue).
Patched exe SHA-256:
1ed21635cea46d7e095ea6614219b0b225da29d65d7f854ae7e5b819e9469ed3Suggested fix
Instead of requiring users to patch the exe, TuxBox could:
clwb→clflushoptin the loaded image when CPUID leaf 7 EBX bit 24 (CLWB) is clear, orSTATUS_ILLEGAL_INSTRUCTIONwith a vectored exception handler that recognises66 [REX] 0F AE /6and emulates it (or skips it, since it's only a write-back hint).Environment
RockstarGamesInc.28872443D20A71.0.2.1,game_scarlett_master.exeSHA-256e95020b2fa4a721db3df59fdecf75621730ac559d8835252f6c3b658d5a08993clwbin/proc/cpuinfo; hasclflushopt)02953b0(also reproduced on3086e0b)unshare --user --map-current-user --net, as in the docsscarlett.log