loader: protect frame pointer red-zone accesses in the guest patcher #1510

Open
github-bot wants to merge 2 commits from github-bot/gh-1510 into main AGit
Owner

@⁠EmK530 on GitHub · 2026-10-14 15:22 UTC · original
EmK530:fix/sysv-patcher → main · +370 −49 · 2 files · 2 commits · open

Summary

On Windows, the guest instruction patcher only recognized red-zone accesses addressed relative to the stack pointer ([rsp - x]). Red-zone accesses relative to the frame pointer ([rbp - x]) were missed, so functions using them were left unprotected.

Tetris Effect: Connected (PPSA07923) has such a function in RenderThread 1 that crashes right after the logos:
Unhandled host exception: type=1 code=3221225477 pc=0x00000009041b57ee access=1 address=0x0000000000000002

This PR makes the patcher also recognize red-zone accesses made relative to the frame pointer, so these functions get the same protection.

Changes

When a function sets the frame pointer from the stack pointer (mov rbp, rsp), the patcher now tracks how far rbp is above rsp following pushes, pops and stack adjustments to detect when a [rbp - x] access falls below rsp, treating it as a red-zone access.

Functions that restore rsp from rbp (mov rsp, rbp, leave) are now tracked too. Previously the patcher would give up on them and patch every memory instruction in the function, not just the ones that need it.

Testing

  • Tetris Effect: Connected (PPSA07923) now boots past logos on Windows with red-zone protection enabled.
    • Observed a 17% increase in patch time (eboot.bin: 7.46s -> 8.74s).
  • virtual_memory_allocation tests pass.
  • Unit tests implemented for frame pointer red-zone accesses, which fail without the fix: WindowsGuestFramePointerRedZoneStaticPatcher

AI usage

AI was involved in the process of debugging, identifying and writing a fix for the issue including the tests. I have reviewed the changes in post and wrote this PR myself.

**@⁠EmK530** on GitHub · 2026-10-14 15:22 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1510) `EmK530:fix/sysv-patcher` → `main` · +370 −49 · 2 files · 2 commits · open ## Summary On Windows, the guest instruction patcher only recognized red-zone accesses addressed relative to the stack pointer (`[rsp - x]`). Red-zone accesses relative to the frame pointer (`[rbp - x]`) were missed, so functions using them were left unprotected. Tetris Effect: Connected (PPSA07923) has such a function in `RenderThread 1` that crashes right after the logos: `Unhandled host exception: type=1 code=3221225477 pc=0x00000009041b57ee access=1 address=0x0000000000000002` This PR makes the patcher also recognize red-zone accesses made relative to the frame pointer, so these functions get the same protection. ## Changes When a function sets the frame pointer from the stack pointer (`mov rbp, rsp`), the patcher now tracks how far `rbp` is above `rsp` following pushes, pops and stack adjustments to detect when a `[rbp - x]` access falls below `rsp`, treating it as a red-zone access. Functions that restore `rsp` from `rbp` (`mov rsp, rbp`, `leave`) are now tracked too. Previously the patcher would give up on them and patch every memory instruction in the function, not just the ones that need it. ## Testing - Tetris Effect: Connected (PPSA07923) now boots past logos on Windows with red-zone protection enabled. - Observed a 17% increase in patch time (eboot.bin: 7.46s -> 8.74s). - `virtual_memory_allocation` tests pass. - Unit tests implemented for frame pointer red-zone accesses, which fail without the fix: `WindowsGuestFramePointerRedZoneStaticPatcher` ## AI usage AI was involved in the process of debugging, identifying and writing a fix for the issue including the tests. I have reviewed the changes in post and wrote this PR myself.
The Windows red-zone patcher only recognized red-zone slots addressed as
[rsp - disp]. Frame-pointer functions can address the same slots through
RBP: after `push rbp; mov rbp, rsp; push r15..rbx`, [rbp - 0x38] lies
below RSP. Those functions were never treated as using the red zone, so
faults taken inside them still let the Windows exception frame overwrite
live guest data.

Tetris Effect Connected (PPSA07923) crashes this way after the logos:
an index-buffer builder on RenderThread 1 spills a table pointer to
[rbp - 0x38], takes handled write faults on GPU-tracked pages while
filling the buffer, then reloads the zeroed pointer and faults at
pc=0x9041b57ee reading address 0x2 * index.

Track RBP - RSP through each function once RBP is set from RSP, follow
pushes, pops and RSP adjustments, and record RBP-based operands below
RSP at their RSP-relative offsets so the existing liveness analysis
protects them. RSP restores from RBP (mov rsp, rbp; lea rsp, [rbp + d];
leave) get a known RSP delta instead of forcing conservative tracking,
and known-frame RBP accesses count as stack accesses like RSP-relative
ones.

With --redzone, Tetris Effect Connected now runs past the crash point.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Nearly every function in Tetris Effect Connected's eboot sets up RBP as
a frame pointer, so the per-function std::map/std::set state of the
frame-pointer pass cost about as much as decoding itself and doubled
red-zone patching time (eboot.bin 7.46 s -> 14.43 s).

Run the dataflow over flat per-function vectors with precomputed
successor indices, reuse those buffers across functions, and skip
functions that never set RBP from RSP. Patch results are unchanged
(eboot.bin: red_zone=2410, patched=48268, unrelocatable=579).

Red-zone patching time with --redzone, mean of three runs:
  eboot.bin                7.46 s before the frame-pointer pass, now 8.74 s
  eossdk-ps5-shipping.prx  1.46 s -> 1.70 s
  libc.prx                 62 ms  -> 73 ms

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:58:24 +00:00
Author
Owner

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

Review in Change Stack →

📝 Walkthrough

The patcher now tracks frame-pointer offsets through instruction successors and models supported RBP-relative red-zone accesses. It runs this analysis before red-zone liveness analysis. A Windows test checks patching for four stack-restoring epilogues and verifies that the value remains intact.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: 🔵 Low · up to 03475

An uncommon frame-pointer sequence can leave a red-zone access unprotected and corrupt its value. Address that gap before relying on protection for those functions.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 42.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly summarizes the main change: protecting frame-pointer-relative red-zone accesses in the guest patcher.
Description check Passed The description directly explains the missed frame-pointer red-zone accesses, the tracking changes, affected behavior, testing, and performance impact.
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-14 15:27 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1510#issuecomment-6171913499) <!-- 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/1510?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 --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> The patcher now tracks frame-pointer offsets through instruction successors and models supported RBP-relative red-zone accesses. It runs this analysis before red-zone liveness analysis. A Windows test checks patching for four stack-restoring epilogues and verifies that the value remains intact. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"034756baed22728fd44be4a697177f72a04db08c" --> **Change:** Bug fix · **Severity of issue fixed:** Low <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>🔵 Low</strong> · up to <code>03475</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🔵 Low** · up to `03475` --> <!-- final_review_risk_coverage:{"sourceCommitId":"034756baed22728fd44be4a697177f72a04db08c","coveredCommitId":"034756baed22728fd44be4a697177f72a04db08c","kind":"reviewed"} --> An uncommon frame-pointer sequence can leave a red-zone access unprotected and corrupt its value. Address that gap before relying on protection for those functions. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- 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-v2.svg" width="14" height="14" 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-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary> <dl> <dd> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 warning</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :----------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | Docstring coverage is 42.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 2 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 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 summarizes the main change: protecting frame-pointer-relative red-zone accesses in the guest patcher. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the missed frame-pointer red-zone accesses, the tracking changes, affected behavior, testing, and performance impact. | | 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> </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=1510)! 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) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
@ -587,3 +813,4 @@
std::optional<RedZoneMask> TranslateRedZoneMask(const RedZoneMask& mask, s64 stack_pointer_delta) {
if (stack_pointer_delta == 0) {
return mask;
Author
Owner

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '188,330p' src/loader/guestInstructionPatcher.cpp
sed -n '600,825p' src/loader/guestInstructionPatcher.cpp

Repository: KytyPS5/KytyPS5

Length of output: 15370


🏁 Script executed:

nl -ba src/loader/guestInstructionPatcher.cpp | sed -n '330,370p'
printf '%s\n' '--- call sites and state consumers ---'
rg -n -F -e 'AnalyzeFramePointerRedZone' -e 'requires_conservative_red_zone_tracking' -e 'conservative_red_zone' -e 'PatchGuestInstructions' -- src/loader/guestInstructionPatcher.cpp src || test "$?" -eq 1
printf '%s\n' '--- tests ---'
rg -n -F -e 'WindowsGuestFramePointerRedZoneStaticPatcher' -e 'xchg' -e 'XCHG' -- . || test "$?" -eq 1

Repository: KytyPS5/KytyPS5

Length of output: 6841


🏁 Script executed:

printf '%s\n' '--- conservative consumer ---'
nl -ba src/loader/guestInstructionPatcher.cpp | sed -n '820,865p'
printf '%s\n' '--- patching flow ---'
nl -ba src/loader/guestInstructionPatcher.cpp | sed -n '1715,1768p'
printf '%s\n' '--- frame-pointer static test ---'
nl -ba tests/VirtualMemoryAllocationTests.cpp | sed -n '300,365p'

Repository: KytyPS5/KytyPS5

Length of output: 8236


Treat unknown RBP-based operands as unmodeled red-zone accesses.

xchg rbp, reg is detected as an RBP write, so the analysis changes the successor state to Unknown. The later [rbp - displacement] operand then bypasses the FrameState::Known block and is not recorded. If it is the function's only red-zone access, function.uses_red_zone remains false, so AnalyzeRedZoneLiveness returns without protecting the function. A reachable function with this sequence can therefore miss red-zone protection.

Suggested fix
 		auto& decoded = *instructions[instruction_index];
+		if (frame_state[instruction_index] != FrameState::Known) {
+			for (u8 index = 0; index < decoded.instruction.operand_count_visible; ++index) {
+				const auto& operand = decoded.operands[index];
+				if (operand.type == ZYDIS_OPERAND_TYPE_MEMORY &&
+				    operand.mem.base == ZYDIS_REGISTER_RBP) {
+					decoded.has_red_zone_operand           = true;
+					decoded.has_unmodeled_red_zone_operand = true;
+					break;
+				}
+			}
+		}
 		if (frame_state[instruction_index] == FrameState::Known) {
**@⁠coderabbitai[bot]** on GitHub · 2026-10-14 15:27 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1510#discussion_r4272804825) **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash sed -n '188,330p' src/loader/guestInstructionPatcher.cpp sed -n '600,825p' src/loader/guestInstructionPatcher.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 15370 --- 🏁 Script executed: ```bash nl -ba src/loader/guestInstructionPatcher.cpp | sed -n '330,370p' printf '%s\n' '--- call sites and state consumers ---' rg -n -F -e 'AnalyzeFramePointerRedZone' -e 'requires_conservative_red_zone_tracking' -e 'conservative_red_zone' -e 'PatchGuestInstructions' -- src/loader/guestInstructionPatcher.cpp src || test "$?" -eq 1 printf '%s\n' '--- tests ---' rg -n -F -e 'WindowsGuestFramePointerRedZoneStaticPatcher' -e 'xchg' -e 'XCHG' -- . || test "$?" -eq 1 ``` Repository: KytyPS5/KytyPS5 Length of output: 6841 --- 🏁 Script executed: ```bash printf '%s\n' '--- conservative consumer ---' nl -ba src/loader/guestInstructionPatcher.cpp | sed -n '820,865p' printf '%s\n' '--- patching flow ---' nl -ba src/loader/guestInstructionPatcher.cpp | sed -n '1715,1768p' printf '%s\n' '--- frame-pointer static test ---' nl -ba tests/VirtualMemoryAllocationTests.cpp | sed -n '300,365p' ``` Repository: KytyPS5/KytyPS5 Length of output: 8236 --- </details> **Treat unknown RBP-based operands as unmodeled red-zone accesses.** `xchg rbp, reg` is detected as an RBP write, so the analysis changes the successor state to `Unknown`. The later `[rbp - displacement]` operand then bypasses the `FrameState::Known` block and is not recorded. If it is the function's only red-zone access, `function.uses_red_zone` remains false, so `AnalyzeRedZoneLiveness` returns without protecting the function. A reachable function with this sequence can therefore miss red-zone protection. <details> <summary>Suggested fix</summary> ```diff auto& decoded = *instructions[instruction_index]; + if (frame_state[instruction_index] != FrameState::Known) { + for (u8 index = 0; index < decoded.instruction.operand_count_visible; ++index) { + const auto& operand = decoded.operands[index]; + if (operand.type == ZYDIS_OPERAND_TYPE_MEMORY && + operand.mem.base == ZYDIS_REGISTER_RBP) { + decoded.has_red_zone_operand = true; + decoded.has_unmodeled_red_zone_operand = true; + break; + } + } + } if (frame_state[instruction_index] == FrameState::Known) { ``` </details> <!-- fingerprinting:phantom:medusa:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:ae95e74e69cd448c19fa35c1 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-14 15:27 UTC · original · reviewed

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b945798f-092b-4730-8817-0b9ce4001f6d
📥 Commits

Reviewing files that changed from the base of the PR and between 9e41d8320a and 034756baed.

📒 Files selected for processing: 2
  • src/loader/guestInstructionPatcher.cpp
  • tests/VirtualMemoryAllocationTests.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.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-14 15:27 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1510#pullrequestreview-5520395207) · **reviewed** **Actionable comments posted: 1** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `b945798f-092b-4730-8817-0b9ce4001f6d` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 9e41d8320a2774b303fbad344c2347e8d0292e83 and 034756baed22728fd44be4a697177f72a04db08c. </details> <details> <summary>📒 Files selected for processing: 2</summary> * `src/loader/guestInstructionPatcher.cpp` * `tests/VirtualMemoryAllocationTests.cpp` </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. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=c25c2855-9575-4118-9143-f32b83e9d3d1 attempt=26057702-55db-41f0-8673-264ca24dd304 batch=1/1 -->
Author
Owner

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

@⁠EmK530 I measured coverage and cost with and without this PR (method in my #1421 comment):

binary patcher red-zone functions relocated memory instr. unrelocatable load time
libLLVM (frame pointers everywhere) main 1 0 0 3.74 s
libLLVM with #1510 346 9,975 524 4.14 s
zstd built with -fno-omit-frame-pointer main 0 0 0 76 ms
zstd built with -fno-omit-frame-pointer with #1510 42 2,960 128 99 ms

libLLVM's disassembly has 126,181 mov %rsp,%rbp, 2,385,622 negative rbp displacements and 1 negative rsp displacement, so all its red-zone slots are rbp-relative and invisible to main's patcher.

Run time (zstd level 3): the frame-pointer build with #1510 is 1.54x (19.33 -> 29.80 ms), the same as the build without frame pointers on main (1.54x), so the cost per relocated instruction is unchanged; #1510 just finds more of them. With #1510, about 4-5% of the red-zone memory instructions stay unrelocatable (128 of 3,088 and 524 of 10,499 above) and therefore unprotected.

Without #1510, code built with frame pointers got no protection in both binaries (and no run-time cost: 1.02x); the load-time decode is paid either way.

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/1510#issuecomment-6271185777) · edited 2026-10-19 16:13 UTC @⁠EmK530 I measured coverage and cost with and without this PR (method in [my #1421 comment](https://git.gtahub.st/github/KytyPS5--KytyPS5/pulls/1421)): | binary | patcher | red-zone functions | relocated memory instr. | unrelocatable | load time | |---|---|---|---|---|---| | libLLVM (frame pointers everywhere) | main | 1 | 0 | 0 | 3.74 s | | libLLVM | with #1510 | 346 | 9,975 | 524 | 4.14 s | | zstd built with -fno-omit-frame-pointer | main | 0 | 0 | 0 | 76 ms | | zstd built with -fno-omit-frame-pointer | with #1510 | 42 | 2,960 | 128 | 99 ms | libLLVM's disassembly has 126,181 `mov %rsp,%rbp`, 2,385,622 negative rbp displacements and 1 negative rsp displacement, so all its red-zone slots are rbp-relative and invisible to main's patcher. Run time (zstd level 3): the frame-pointer build with #1510 is 1.54x (19.33 -> 29.80 ms), the same as the build without frame pointers on main (1.54x), so the cost per relocated instruction is unchanged; #1510 just finds more of them. With #1510, about 4-5% of the red-zone memory instructions stay unrelocatable (128 of 3,088 and 524 of 10,499 above) and therefore unprotected. Without #1510, code built with frame pointers got no protection in both binaries (and no run-time cost: 1.02x); the load-time decode is paid either way. Written with Claude Code (AI): it wrote the probe and the benchmark harness and ran them; I checked the numbers before posting.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1510/head:github-bot/gh-1510'
git switch 'github-bot/gh-1510'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1510'
git switch 'github-bot/gh-1510'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1510'
git switch 'github-bot/gh-1510'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1510'
git switch 'main'
git merge --squash 'github-bot/gh-1510'
git switch 'main'
git merge --ff-only 'github-bot/gh-1510'
git switch 'main'
git merge 'github-bot/gh-1510'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.