loader: enable Windows red zone protection by default (GTA V car-entry crash, #829) #1421

Closed
github-bot wants to merge 1 commit from gh-pr/1421/head into gh-pr/1421/base
Owner

@⁠overlordxrz-source on GitHub · 2026-10-11 15:21 UTC · original
overlordxrz-source:fix/windows-redzone-default → main · +9 −6 · 4 files · 1 commits · closed without merging

Ports TheCruZ's 840a5442 from TheCruZ/KytyPS5-GTA (with his permission on #1241, 2026-10-10). Authorship kept.

Bug: GTA V (PPSA04264/04263) on Windows crashes in the "[RAGE] HDD Streamer" thread, e.g. when getting into a car (#829). The game keeps temporaries below its stack pointer, and Windows overwrites that area while handling the emulator's memory-tracking faults, so the thread later reads 0xffffffffffffffff. --redzone already fixes it, but it is off by default. TheCruZ on #829 (2026-10-02): --redzone is needed "to prevent a crash when you get into the car".

Change: red zone protection is on by default on Windows. --no-redzone turns it off. Linux and macOS are unchanged.

Same flag is reported as required for: Stray (#595, #1368), Sifu (#575, #739), Borderlands 3 (#1002), Viewfinder (#1064). On #1096: "Should be most of the time ON for Unreal Engine games."

Trade-off: guest instruction patching and an 8 MiB trampoline are now active by default on Windows. Existing saved launcher configs keep their stored value.

Fixes the car-entry crash in #829.

AI-assisted: yes (port and description; code is TheCruZ's commit unchanged).

**@⁠overlordxrz-source** on GitHub · 2026-10-11 15:21 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1421) `overlordxrz-source:fix/windows-redzone-default` → `main` · +9 −6 · 4 files · 1 commits · closed without merging Ports TheCruZ's 840a5442 from TheCruZ/KytyPS5-GTA (with his permission on #1241, 2026-10-10). Authorship kept. **Bug:** GTA V (PPSA04264/04263) on Windows crashes in the "[RAGE] HDD Streamer" thread, e.g. when getting into a car (#829). The game keeps temporaries below its stack pointer, and Windows overwrites that area while handling the emulator's memory-tracking faults, so the thread later reads 0xffffffffffffffff. `--redzone` already fixes it, but it is off by default. TheCruZ on #829 (2026-10-02): `--redzone` is needed "to prevent a crash when you get into the car". **Change:** red zone protection is on by default on Windows. `--no-redzone` turns it off. Linux and macOS are unchanged. **Same flag is reported as required for:** Stray (#595, #1368), Sifu (#575, #739), Borderlands 3 (#1002), Viewfinder (#1064). On #1096: "Should be most of the time ON for Unreal Engine games." **Trade-off:** guest instruction patching and an 8 MiB trampoline are now active by default on Windows. Existing saved launcher configs keep their stored value. Fixes the car-entry crash in #829. AI-assisted: yes (port and description; code is TheCruZ's commit unchanged).
Guest code follows the SysV ABI, which lets leaf code keep data in the
128 bytes below rsp. Windows writes exception frames there, and the
emulator raises exceptions constantly for memory tracking. GTA V
(PPSA04263) keeps inflate_fast locals in the red zone; when a tracked
page faulted during its loop, the "[RAGE] HDD Streamer" thread reloaded
a clobbered input pointer and crashed reading 0xffffffffffffffff, late
in the prologue.

Protect the red zone unless --no-redzone is given. The launcher passes
its checkbox state explicitly, and new configurations default to on.

(cherry picked from commit 840a544236009fcfee134a1e79e9b7bab0ef072d)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:56:25 +00:00
github-bot closed this pull request 2026-11-26 09:56:25 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-11 15:23 UTC · original

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7aba0a5c-169a-478b-b8ad-8d4197f9ce35

📥 Commits

Reviewing files that changed from the base of the PR and between 16a7fe689a and 8c984301cd.


📒 Files selected for processing (4)
  • src/common/emulatorConfig.h
  • src/launcher/include/configuration.h
  • src/launcher/src/mainDialog.cpp
  • src/main.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.



📝 Walkthrough

Walkthrough

On Windows, red-zone protection now defaults to enabled in the emulator and launcher configurations. The launcher emits --redzone when protection is enabled and --no-redzone when it is disabled. Command-line help documents both options, and parsing --no-redzone disables protection.

Suggested reviewers: nmzik


Priority: ⬆️ High

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 8c984

Windows red-zone protection defaults to enabled, and the launcher’s enable and disable options match the CLI behavior.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly identifies the main change: enabling Windows red zone protection by default. It also provides relevant context about the GTA V car-entry crash and issue #829.
Description check Passed The description directly explains the crash, the Windows-only behavior change, the new --no-redzone option, affected games, trade-offs, and configuration behavior. It is clearly related to the changes…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-11 15:23 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1421#issuecomment-6110551338) <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1421?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary><strong>ℹ️ Recent review info</strong></summary> <dl> <dd> <details> <summary><strong>⚙️ Run configuration</strong></summary> <dl> <dd> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `7aba0a5c-169a-478b-b8ad-8d4197f9ce35` <hr> </dd> </dl> </details> <details> <summary><strong>📥 Commits</strong></summary> <dl> <dd> Reviewing files that changed from the base of the PR and between 16a7fe689a642deeeef85a706e7da305eca6fb85 and 8c984301cd46a918ff9a2ef0b5700ad1be022d09. <hr> </dd> </dl> </details> <details> <summary><strong>📒 Files selected for processing (4)</strong></summary> <dl> <dd> * `src/common/emulatorConfig.h` * `src/launcher/include/configuration.h` * `src/launcher/src/mainDialog.cpp` * `src/main.cpp` <hr> </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. <hr> </dd> </dl> </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> ## Walkthrough On Windows, red-zone protection now defaults to enabled in the emulator and launcher configurations. The launcher emits `--redzone` when protection is enabled and `--no-redzone` when it is disabled. Command-line help documents both options, and parsing `--no-redzone` disables protection. **Suggested reviewers:** `nmzik` <hr> </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬆️ High <!-- change_assessment_commit:"8c984301cd46a918ff9a2ef0b5700ad1be022d09" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** **⚪ Minimal** · up to `8c984` <!-- final_review_risk_coverage:{"sourceCommitId":"8c984301cd46a918ff9a2ef0b5700ad1be022d09","coveredCommitId":"8c984301cd46a918ff9a2ef0b5700ad1be022d09","kind":"reviewed"} --> Windows red-zone protection defaults to enabled, and the launcher’s enable and disable options match the CLI behavior. <!-- final_review_risk_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks | <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v1.svg" width="14" height="17" align="middle" alt="Passed" title="Passed"></picture></sup> 4 | <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v1.svg" width="14" height="17" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary> <dl> <dd> ### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :---------------- | :----------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 4 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong>✅ Passed checks (4 passed)</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly identifies the main change: enabling Windows red zone protection by default. It also provides relevant context about the GTA V car-entry crash and issue `#829`. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the crash, the Windows-only behavior change, the new --no-redzone option, affected games, trade-offs, and configuration behavior. It is clearly related to the changes… | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | </dd> </dl> </details> <hr> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1421)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) <hr> </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠theantipopau on GitHub · 2026-10-12 11:03 UTC · original · approved these changes

Verified the single PR commit 8c984301 (cherry-picked from TheCruZ's 840a5442) against current main:

  • Consistent default flip: both ConfigOptions.red_zone_protection_enabled (emulatorConfig.h) and the launcher's Configuration default flip to true, so Config::RedZoneProtectionEnabled() (read by runtimeLinker.cpp:1675 on the guest-instruction-patch path) now defaults on, matching patch_guest_instructions = protect_memory_faults || emulate_amd.
  • New --no-redzone inverse-flag is symmetric with --redzone, usage text updated, and CreateEmulatorArgs now always passes one of the two flags explicitly instead of only-on — that fixes the latent launcher bug where a stored false config silently booted with protection on after this change.
  • Saved configs unaffected: configuration.cpp reads red_zone_protection_enabled with the (new) default only as fallback for older keys.
  • Off-switch preserved for regressions, non-Windows untouched, and the trampoline/patching cost is documented.

CI green on Windows/Linux/macOS (5/5). Fixes #829.

**@⁠theantipopau** on GitHub · 2026-10-12 11:03 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1421#pullrequestreview-5489824767) · **approved these changes** Verified the single PR commit `8c984301` (cherry-picked from TheCruZ's 840a5442) against current main: - Consistent default flip: both `ConfigOptions.red_zone_protection_enabled` ([emulatorConfig.h](https://github.com/KytyPS5/KytyPS5/blob/main/src/common/emulatorConfig.h)) and the launcher's `Configuration` default flip to `true`, so `Config::RedZoneProtectionEnabled()` (read by `runtimeLinker.cpp:1675` on the guest-instruction-patch path) now defaults on, matching `patch_guest_instructions = protect_memory_faults || emulate_amd`. - New `--no-redzone` inverse-flag is symmetric with `--redzone`, usage text updated, and `CreateEmulatorArgs` now *always* passes one of the two flags explicitly instead of only-on — that fixes the latent launcher bug where a stored `false` config silently booted with protection on after this change. - Saved configs unaffected: `configuration.cpp` reads `red_zone_protection_enabled` with the (new) default only as fallback for older keys. - Off-switch preserved for regressions, non-Windows untouched, and the trampoline/patching cost is documented. CI green on Windows/Linux/macOS (5/5). Fixes #829.
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-18 21:58 UTC · original

Another game that looks like it needs this: Demon's Souls (PPSA01341) on Windows, RX 6700 XT and Ryzen 7 5700X (#821), on a build of 099de8d with #1152 and #1630 (f3996a4).

  • Without the protection, it crashed when the gameplay in the fog started, in the game's thread BPE JobWorkerThread CPU4: mov rax, [rsp-0x10] followed by mov [rax+0x18], ebp with rax = 0, so the function reloaded a pointer from 16 bytes below rsp and got 0 (log).
  • With "Windows SysV red zone crash protection" checked, volan3 reports that the game no longer crashes there (comment).

Written with Claude Code (AI): it read the crash log and found this PR; I read this before posting.

**@⁠Nawid3333** on GitHub · 2026-10-18 21:58 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1421#issuecomment-6255650319) Another game that looks like it needs this: Demon's Souls (PPSA01341) on Windows, RX 6700 XT and Ryzen 7 5700X (#821), on a build of 099de8d with #1152 and #1630 ([f3996a4](https://github.com/Nawid3333/KytyPS5/actions/runs/39159723040)). - Without the protection, it crashed when the gameplay in the fog started, in the game's thread `BPE JobWorkerThread CPU4`: `mov rax, [rsp-0x10]` followed by `mov [rax+0x18], ebp` with rax = 0, so the function reloaded a pointer from 16 bytes below rsp and got 0 ([log](https://git.gtahub.st/github/KytyPS5--KytyPS5/issues/821)). - With "Windows SysV red zone crash protection" checked, volan3 reports that the game no longer crashes there ([comment](https://git.gtahub.st/github/KytyPS5--KytyPS5/issues/821)). Written with Claude Code (AI): it read the crash log and found this PR; I read this before posting.
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-19 15:43 UTC · original · edited 2026-10-19 16:13 UTC

Follow-up to my Demon's Souls comment above: I measured what Windows writes below rsp on a handled access violation, and what the protection costs.

1. What Windows writes below rsp (standalone probe; the vectored handler reads where Windows put each XSAVE feature with LocateXStateFeature; Ryzen 5 7600X = Zen 4, Windows 11 26200; one run, the offsets shift by up to 0x30 with rsp alignment)

region offset from the faulting rsp
CONTEXT (x87/SSE inside it) starts at -0xd68
AVX (feature 2) -0x768 .. -0x668
opmask (5) -0x668 .. -0x628
ZMM_Hi256 (6) -0x628 .. -0x428
Hi16_ZMM (7) -0x428 .. -0x28

A feature's bytes are written only when it is in the context mask. So the 128-byte red zone is overwritten when the highest feature in the frame is in use at the fault. On this Zen 4 that is zmm16-31 (nearest overwritten slot rsp-0x20 to rsp-0x40 across runs), which guest code built for Zen 2 never uses; AVX alone stops at about rsp-0x650. Prediction, not yet measured: on a CPU without AVX-512, AVX is the top feature, so any fault with live ymm upper halves overwrites the red zone. vzeroupper clears that state; a VEX.128 instruction after AVX code does not (the context mask still has AVX).

2. CPUs named in these reports (#1421's list, plus Demon's Souls)

report game CPU AVX-512
#829 GTA V Core Ultra 7 265K no
#595 / #1368 Stray i5-12400F, Ryzen 5600X / i7-12700KF no
#575 / #739 Sifu Ryzen 5600X / 5800X no
#1002, #1064 Borderlands 3, Viewfinder Ryzen 5600X no
#821 Demon's Souls Ryzen 7 5700X no
#1512 (two commenters: same pc and mov [rax+0x18], ebp with rax = 0 as #821; not yet tried with the option) Demon's Souls Ryzen 9 5900X no

All of these are CPUs without AVX-512, which fits the prediction. That alone would not make a CPU-based default safe: host code that leaves zmm16-31 live on a guest thread would expose AVX-512 hosts too, and I have not checked for that.

Edit: an earlier version of this comment listed #1512's reporter (Ryzen 9 9950X3D) here. That log ends in a failed Vulkan call (result != vk::Result::eSuccess, masterSemaphore.cpp:53) with red-zone protection already on, so it is a different crash; the row now lists the two #1512 commenters whose crash matches.

3. Cost (lab harness that loads SysV x86-64 ELF code - Ubuntu's libLLVM, and zstd built with clang -O2 -march=znver2 - and runs Kyty's PatchGuestInstructions as --redzone does; same 7600X, Release build)

load time relocated instr. time
libLLVM (62.3 MiB of code), main 0 3.74 s (60 ms/MiB)
libLLVM, with #1510 9,975 4.14 s (66.5 ms/MiB)
zstd 1.5.7 (0.46 MiB), main 2,728 77 ms
run time (zstd, 8 MiB, median of 15 calls, 9 for the fault row) unpatched patched ratio
control: second copy loaded, not patched 17.57 ms 17.80 ms 1.01
compress + decompress, level 3 17.67 ms 27.30 ms 1.54
decompress only, x8 47.83 ms 47.92 ms 1.00
level 3 with 4096 write-tracking faults per call 25.10 ms 34.63 ms 1.38

Results were identical in every row. The load cost is the one-time decode of all guest code (--amd-cpu costs about the same, 3.64 s); EmK530 measured 7.46 s -> 8.74 s for Tetris Effect's eboot in #1510. The run-time cost depends on whether hot loops keep data in the red zone: 0% for zstd's decompression, +54% for compression plus decompression, because each relocated access becomes jmp -> lea rsp,[rsp-128] -> access -> lea rsp,[rsp+128] -> jmp. What a game pays is unknown.

4. Could a tester run an FPS A/B with and without the option in a scene that does not crash? That would show the real run-time cost before the default is chosen.

Written with Claude Code (AI): it wrote the probe and the benchmark harness and ran them; I checked the numbers before posting.

**@⁠Nawid3333** on GitHub · 2026-10-19 15:43 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1421#issuecomment-6271182932) · edited 2026-10-19 16:13 UTC Follow-up to my Demon's Souls comment above: I measured what Windows writes below rsp on a handled access violation, and what the protection costs. **1. What Windows writes below rsp** (standalone probe; the vectored handler reads where Windows put each XSAVE feature with `LocateXStateFeature`; Ryzen 5 7600X = Zen 4, Windows 11 26200; one run, the offsets shift by up to 0x30 with rsp alignment) | region | offset from the faulting rsp | |---|---| | CONTEXT (x87/SSE inside it) | starts at -0xd68 | | AVX (feature 2) | -0x768 .. -0x668 | | opmask (5) | -0x668 .. -0x628 | | ZMM_Hi256 (6) | -0x628 .. -0x428 | | Hi16_ZMM (7) | -0x428 .. -0x28 | A feature's bytes are written only when it is in the context mask. So the 128-byte red zone is overwritten when the highest feature in the frame is in use at the fault. On this Zen 4 that is zmm16-31 (nearest overwritten slot rsp-0x20 to rsp-0x40 across runs), which guest code built for Zen 2 never uses; AVX alone stops at about rsp-0x650. Prediction, not yet measured: on a CPU without AVX-512, AVX is the top feature, so any fault with live ymm upper halves overwrites the red zone. `vzeroupper` clears that state; a VEX.128 instruction after AVX code does not (the context mask still has AVX). **2. CPUs named in these reports** (#1421's list, plus Demon's Souls) | report | game | CPU | AVX-512 | |---|---|---|---| | #829 | GTA V | Core Ultra 7 265K | no | | #595 / #1368 | Stray | i5-12400F, Ryzen 5600X / i7-12700KF | no | | #575 / #739 | Sifu | Ryzen 5600X / 5800X | no | | #1002, #1064 | Borderlands 3, Viewfinder | Ryzen 5600X | no | | #821 | Demon's Souls | Ryzen 7 5700X | no | | #1512 (two commenters: same pc and `mov [rax+0x18], ebp` with rax = 0 as #821; not yet tried with the option) | Demon's Souls | Ryzen 9 5900X | no | All of these are CPUs without AVX-512, which fits the prediction. That alone would not make a CPU-based default safe: host code that leaves zmm16-31 live on a guest thread would expose AVX-512 hosts too, and I have not checked for that. Edit: an earlier version of this comment listed #1512's reporter (Ryzen 9 9950X3D) here. That log ends in a failed Vulkan call (`result != vk::Result::eSuccess`, `masterSemaphore.cpp:53`) with red-zone protection already on, so it is a different crash; the row now lists the two #1512 commenters whose crash matches. **3. Cost** (lab harness that loads SysV x86-64 ELF code - Ubuntu's libLLVM, and zstd built with clang -O2 -march=znver2 - and runs Kyty's `PatchGuestInstructions` as `--redzone` does; same 7600X, Release build) | load time | relocated instr. | time | |---|---|---| | libLLVM (62.3 MiB of code), main | 0 | 3.74 s (60 ms/MiB) | | libLLVM, with #1510 | 9,975 | 4.14 s (66.5 ms/MiB) | | zstd 1.5.7 (0.46 MiB), main | 2,728 | 77 ms | | run time (zstd, 8 MiB, median of 15 calls, 9 for the fault row) | unpatched | patched | ratio | |---|---|---|---| | control: second copy loaded, not patched | 17.57 ms | 17.80 ms | 1.01 | | compress + decompress, level 3 | 17.67 ms | 27.30 ms | 1.54 | | decompress only, x8 | 47.83 ms | 47.92 ms | 1.00 | | level 3 with 4096 write-tracking faults per call | 25.10 ms | 34.63 ms | 1.38 | Results were identical in every row. The load cost is the one-time decode of all guest code (`--amd-cpu` costs about the same, 3.64 s); EmK530 measured 7.46 s -> 8.74 s for Tetris Effect's eboot in #1510. The run-time cost depends on whether hot loops keep data in the red zone: 0% for zstd's decompression, +54% for compression plus decompression, because each relocated access becomes jmp -> `lea rsp,[rsp-128]` -> access -> `lea rsp,[rsp+128]` -> jmp. What a game pays is unknown. **4.** Could a tester run an FPS A/B with and without the option in a scene that does not crash? That would show the real run-time cost before the default is chosen. Written with Claude Code (AI): it wrote the probe and the benchmark harness and ran them; I checked the numbers before posting.
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-19 19:48 UTC · original

Update to my measurement above: the prediction is now measured on a CPU without AVX-512. volan3 ran the same probe on his Ryzen 7 5700X (Zen 3, XCR0 0x7) with Windows 10 build 19045 (output):

SIMD state at the fault context mask nearest overwritten slot
no SIMD instruction before it 0x3 rsp-0x130
AVX upper halves in use (vpcmpeqd ymm0) 0x7 rsp-0x30 (red zone)
AVX used, then vzeroupper 0x3 rsp-0x140

Frame layout in that run: CONTEXT at rsp-0x728, AVX (feature 2) at rsp-0x128 .. rsp-0x28, i.e. AVX is the top feature there. So on CPUs without AVX-512 every fault inside 256-bit AVX code overwrites the guest red zone, on Windows 10 as well as 11. That matches the Demon's Souls fog crash on that machine (#821: a pointer reloaded from [rsp-0x10] came back 0, fixed by the protection). Difference to my Zen 4 run: after a VEX.128 instruction his Windows did not save AVX (mask 0x3), mine did (0x7).

Written with Claude Code (AI): it wrote the probe and compared the runs; I checked the numbers before posting.

**@⁠Nawid3333** on GitHub · 2026-10-19 19:48 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1421#issuecomment-6275866111) Update to my measurement above: the prediction is now measured on a CPU without AVX-512. volan3 ran the same probe on his Ryzen 7 5700X (Zen 3, XCR0 0x7) with Windows 10 build 19045 ([output](https://git.gtahub.st/github/KytyPS5--KytyPS5/issues/821)): | SIMD state at the fault | context mask | nearest overwritten slot | |---|---|---| | no SIMD instruction before it | 0x3 | rsp-0x130 | | AVX upper halves in use (`vpcmpeqd ymm0`) | 0x7 | **rsp-0x30** (red zone) | | AVX used, then `vzeroupper` | 0x3 | rsp-0x140 | Frame layout in that run: CONTEXT at rsp-0x728, AVX (feature 2) at rsp-0x128 .. rsp-0x28, i.e. AVX is the top feature there. So on CPUs without AVX-512 every fault inside 256-bit AVX code overwrites the guest red zone, on Windows 10 as well as 11. That matches the Demon's Souls fog crash on that machine (#821: a pointer reloaded from [rsp-0x10] came back 0, fixed by the protection). Difference to my Zen 4 run: after a VEX.128 instruction his Windows did not save AVX (mask 0x3), mine did (0x7). Written with Claude Code (AI): it wrote the probe and compared the runs; I checked the numbers before posting.
Author
Owner

@⁠Nmzik on GitHub · 2026-10-21 19:00 UTC · original

Same it doesnt make sense to auto turn on (it is not 100% reliable)

**@⁠Nmzik** on GitHub · 2026-10-21 19:00 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1421#issuecomment-6324117103) Same it doesnt make sense to auto turn on (it is not 100% reliable)

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.