ProjectScarlett: insertq (SSE4a) crashes on Intel CPUs when the start screen comes up #152

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

@⁠3kynox on GitHub · 2026-11-25 08:56 UTC · original

Summary

With clzero, monitorx and mwaitx handled (#146), ProjectScarlett 1.0.2.1 still executes one more AMD-only instruction on an Intel host: insertq, from SSE4a. Zen 2 implements SSE4a. No Intel CPU does, so the instruction raises EXCEPTION_ILLEGAL_INSTRUCTION. The first site is reached at about the time the player-selection prompt is first presented.

1402e7ff1:  f2 0f 78 c1 10 10    insertq xmm0, xmm1, 0x10, 0x10

insertq xmm1, xmm2, imm8, imm8 copies a bit field from the low quadword of the source into the low quadword of the destination. The first immediate is the field length and the second is its bit index.

On 24 November, with a local build that already served the other three instructions but not this one, two launches exited with code 29 after 68 s and 85 s. Both logs contain:

warn:seh:dispatch_exception EXCEPTION_ILLEGAL_INSTRUCTION exception (code=c000001d) raised
warn:seh:virtual_unwind backtrace: 00000001402E7FF1: L"game_scarlett_master.exe" + 00000000002E7FF1.

I have not reproduced the exit on unmodified main: my one launch of main at 0a8d2ee ended after 144 s, before the prompt was presented. The same commit with the handler from the pull request reaches the site and logs emulated unsupported insertq at RVA 0x2e7ff1, so the instruction is executed on that path.

Affected sites

A byte scan of .text for the immediate form with register operands (F2 [REX] 0F 78 /r ib ib) finds 19 candidates. It finds none for extrq (66 0F 78, 66 0F 79) or for insertq without immediates (F2 0F 79). A scan is not a disassembly, so some candidates may be data.

RVAs: 0x27C8F2, 0x27E9F1, 0x2E7FF1, 0x7F1AC9, 0x7F1B29, 0x7F1B38, 0x7F1B44, 0xF75FB3, 0xF762B7, 0xF765B5, 0xF768B0, 0x269DCB2, 0x32BC150, 0x43D440E, 0x43D491B, 0x455BAC7, 0x5084782, 0x546D4A2, 0x55B1811.

Three of them have been executed on this machine so far:

RVA Bytes Instruction
0x2E7FF1 f2 0f 78 c1 10 10 insertq xmm0, xmm1, 16, 16
0x5084782 f2 0f 78 c0 08 18 insertq xmm0, xmm0, 8, 24
0x27C8F2 f2 44 0f 78 cf 08 00 insertq xmm9, xmm7, 8, 0

System

  • OS: NixOS 26.11, Linux 7.2.11-zen1
  • CPU: Intel Core i9-12900K
  • GPU: GeForce RTX 4070 Ti SUPER, driver 595.112.07
  • Proton: Experimental 11.0-20261112, vkd3d-proton 3.2.0
  • TuxBox: main at 0a8d2ee for the launches above
**@⁠3kynox** on GitHub · 2026-11-25 08:56 UTC · [original](https://github.com/brcly/TuxBox/issues/152) ## Summary With `clzero`, `monitorx` and `mwaitx` handled (#146), ProjectScarlett 1.0.2.1 still executes one more AMD-only instruction on an Intel host: `insertq`, from SSE4a. Zen 2 implements SSE4a. No Intel CPU does, so the instruction raises `EXCEPTION_ILLEGAL_INSTRUCTION`. The first site is reached at about the time the player-selection prompt is first presented. ``` 1402e7ff1: f2 0f 78 c1 10 10 insertq xmm0, xmm1, 0x10, 0x10 ``` `insertq xmm1, xmm2, imm8, imm8` copies a bit field from the low quadword of the source into the low quadword of the destination. The first immediate is the field length and the second is its bit index. On 24 November, with a local build that already served the other three instructions but not this one, two launches exited with code 29 after 68 s and 85 s. Both logs contain: ``` warn:seh:dispatch_exception EXCEPTION_ILLEGAL_INSTRUCTION exception (code=c000001d) raised warn:seh:virtual_unwind backtrace: 00000001402E7FF1: L"game_scarlett_master.exe" + 00000000002E7FF1. ``` I have not reproduced the exit on unmodified `main`: my one launch of `main` at 0a8d2ee ended after 144 s, before the prompt was presented. The same commit with the handler from the pull request reaches the site and logs `emulated unsupported insertq at RVA 0x2e7ff1`, so the instruction is executed on that path. ## Affected sites A byte scan of `.text` for the immediate form with register operands (`F2 [REX] 0F 78 /r ib ib`) finds 19 candidates. It finds none for `extrq` (`66 0F 78`, `66 0F 79`) or for `insertq` without immediates (`F2 0F 79`). A scan is not a disassembly, so some candidates may be data. RVAs: 0x27C8F2, 0x27E9F1, 0x2E7FF1, 0x7F1AC9, 0x7F1B29, 0x7F1B38, 0x7F1B44, 0xF75FB3, 0xF762B7, 0xF765B5, 0xF768B0, 0x269DCB2, 0x32BC150, 0x43D440E, 0x43D491B, 0x455BAC7, 0x5084782, 0x546D4A2, 0x55B1811. Three of them have been executed on this machine so far: | RVA | Bytes | Instruction | | --- | --- | --- | | 0x2E7FF1 | `f2 0f 78 c1 10 10` | `insertq xmm0, xmm1, 16, 16` | | 0x5084782 | `f2 0f 78 c0 08 18` | `insertq xmm0, xmm0, 8, 24` | | 0x27C8F2 | `f2 44 0f 78 cf 08 00` | `insertq xmm9, xmm7, 8, 0` | ## System - OS: NixOS 26.11, Linux 7.2.11-zen1 - CPU: Intel Core i9-12900K - GPU: GeForce RTX 4070 Ti SUPER, driver 595.112.07 - Proton: Experimental 11.0-20261112, vkd3d-proton 3.2.0 - TuxBox: `main` at 0a8d2ee for the launches above
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:34:43 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.