ProjectScarlett: clwb crashes on CPUs without CLWB (pre-Ice Lake Intel), clflushopt rewrite fixes it #71

Closed
opened 2026-11-26 06:29:12 +00:00 by github-bot · 0 comments
Owner

@⁠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 is clwb. 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.

01d8:warn:seh:dispatch_exception EXCEPTION_ILLEGAL_INSTRUCTION exception (code=c000001d) raised
01d8:warn:seh:virtual_unwind backtrace: 0000000144ECC84A: L"game_scarlett_master.exe" + 0000000004ECC84A.
01d8:warn:seh:virtual_unwind backtrace: 000000014247905F: L"game_scarlett_master.exe" + 000000000247905F.
01d8:warn:seh:virtual_unwind backtrace: 00000001419F4F54: L"game_scarlett_master.exe" + 00000000019F4F54.
4ecbc4a:  66 41 0f ae 31    clwb   (%r9)     ; file offset; RVA 0x4ECC84A
4ecbc4f:  49 83 c1 40       add    $0x40,%r9
4ecbc53:  49 39 c1          cmp    %rax,%r9
4ecbc56:  76 f2             jbe    4ecbc4a

Affected sites

The executable has 8 clwb instructions. All of them are in the same cache-line write-back loop (clwb over 64-byte lines up to an end pointer). File offsets of the 66 prefix:

File offset Encoding
0x4e4aa80 66 0f ae 31 (%rcx)
0x4ecbc4a 66 41 0f ae 31 (%r9), the first one hit
0x50f69f5 66 41 0f ae 30 (%r8)
0x532e5b0 66 0f ae 30 (%rax)
0x532e5f0 66 0f ae 30 (%rax)
0x532e630 66 0f ae 30 (%rax)
0x532e680 66 0f ae 30 (%rax)
0x532e6ba 66 0f ae 30 (%rax)

Workaround (verified)

clflushopt has the same encoding except for the ModRM reg field (/7 instead of /6), so it's a same-length, 1-byte change per site: set bit 3 of the ModRM byte (0x30→0x38, 0x31→0x39). Like clwb, 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 plain clflush (0F AE /7 without the 66 prefix) 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: 1ed21635cea46d7e095ea6614219b0b225da29d65d7f854ae7e5b819e9469ed3

Suggested fix

Instead of requiring users to patch the exe, TuxBox could:

  • patch clwb → clflushopt in the loaded image when CPUID leaf 7 EBX bit 24 (CLWB) is clear, or
  • handle STATUS_ILLEGAL_INSTRUCTION with a vectored exception handler that recognises 66 [REX] 0F AE /6 and emulates it (or skips it, since it's only a write-back hint).

Environment

  • Package RockstarGamesInc.28872443D20A7 1.0.2.1, game_scarlett_master.exe SHA-256 e95020b2fa4a721db3df59fdecf75621730ac559d8835252f6c3b658d5a08993
  • CPU: Intel Core i9-9900 (no clwb in /proc/cpuinfo; has clflushopt)
  • GPU: NVIDIA GeForce RTX 2060, driver 615.71.09
  • Proton: 1793301796 experimental-11.0-20261027b-x86_64, umu-launcher 1.4.4
  • OS: Manjaro, kernel 6.12.112
  • TuxBox: 02953b0 (also reproduced on 3086e0b)
  • Launched offline with unshare --user --map-current-user --net, as in the docs

scarlett.log

**@⁠jessebuffington** on GitHub · 2026-11-24 16:22 UTC · [original](https://github.com/brcly/TuxBox/issues/71) ## Summary On an Intel Core i9-9900 (Coffee Lake), ProjectScarlett exits about 5 seconds after launch with `EXCEPTION_ILLEGAL_INSTRUCTION`. The faulting instruction is `clwb`. 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. ``` 01d8:warn:seh:dispatch_exception EXCEPTION_ILLEGAL_INSTRUCTION exception (code=c000001d) raised 01d8:warn:seh:virtual_unwind backtrace: 0000000144ECC84A: L"game_scarlett_master.exe" + 0000000004ECC84A. 01d8:warn:seh:virtual_unwind backtrace: 000000014247905F: L"game_scarlett_master.exe" + 000000000247905F. 01d8:warn:seh:virtual_unwind backtrace: 00000001419F4F54: L"game_scarlett_master.exe" + 00000000019F4F54. ``` ``` 4ecbc4a: 66 41 0f ae 31 clwb (%r9) ; file offset; RVA 0x4ECC84A 4ecbc4f: 49 83 c1 40 add $0x40,%r9 4ecbc53: 49 39 c1 cmp %rax,%r9 4ecbc56: 76 f2 jbe 4ecbc4a ``` ## Affected sites The executable has 8 `clwb` instructions. All of them are in the same cache-line write-back loop (`clwb` over 64-byte lines up to an end pointer). File offsets of the `66` prefix: | File offset | Encoding | | --- | --- | | `0x4e4aa80` | `66 0f ae 31` (`%rcx`) | | `0x4ecbc4a` | `66 41 0f ae 31` (`%r9`), the first one hit | | `0x50f69f5` | `66 41 0f ae 30` (`%r8`) | | `0x532e5b0` | `66 0f ae 30` (`%rax`) | | `0x532e5f0` | `66 0f ae 30` (`%rax`) | | `0x532e630` | `66 0f ae 30` (`%rax`) | | `0x532e680` | `66 0f ae 30` (`%rax`) | | `0x532e6ba` | `66 0f ae 30` (`%rax`) | ## Workaround (verified) `clflushopt` has the same encoding except for the ModRM reg field (`/7` instead of `/6`), so it's a same-length, 1-byte change per site: set bit 3 of the ModRM byte (`0x30`→`0x38`, `0x31`→`0x39`). Like `clwb`, 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 plain `clflush` (`0F AE /7` without the `66` prefix) 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](https://git.gtahub.st/github/brcly--TuxBox/issues/72)). Patched exe SHA-256: `1ed21635cea46d7e095ea6614219b0b225da29d65d7f854ae7e5b819e9469ed3` ## Suggested fix Instead of requiring users to patch the exe, TuxBox could: - patch `clwb` → `clflushopt` in the loaded image when CPUID leaf 7 EBX bit 24 (CLWB) is clear, or - handle `STATUS_ILLEGAL_INSTRUCTION` with a vectored exception handler that recognises `66 [REX] 0F AE /6` and emulates it (or skips it, since it's only a write-back hint). ## Environment - Package `RockstarGamesInc.28872443D20A7` 1.0.2.1, `game_scarlett_master.exe` SHA-256 `e95020b2fa4a721db3df59fdecf75621730ac559d8835252f6c3b658d5a08993` - CPU: Intel Core i9-9900 (no `clwb` in `/proc/cpuinfo`; has `clflushopt`) - GPU: NVIDIA GeForce RTX 2060, driver 615.71.09 - Proton: 1793301796 experimental-11.0-20261027b-x86_64, umu-launcher 1.4.4 - OS: Manjaro, kernel 6.12.112 - TuxBox: `02953b0` (also reproduced on `3086e0b`) - Launched offline with `unshare --user --map-current-user --net`, as in the docs [scarlett.log](https://github.com/user-attachments/files/35357078/scarlett.log)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:29:12 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.