abi: realign SysV host entries on Windows #990
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!990
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/990/head"
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?
@tsubaki-0x on GitHub · 2026-10-02 23:33 UTC · original
suzu/hello-kitty-abi-latest→main· +111 −0 · 2 files · 2 commits · closed without mergingPR Title
abi: realign SysV host entries on Windows
Problem
On Windows, a guest SysV call can enter a Kyty host function with a stack alignment that does not match what Clang expects for a normal SysV call.
When that host function later calls code using the Windows/MS ABI, the misalignment can propagate and cause aligned stack operations such as
movapsto fault.This was reproduced while investigating Hello Kitty Island Adventure (PPSA18176), related to #610.
On current
main, the game could reach a host access violation during normal execution. Applyingforce_align_arg_pointerto SysV host entries prevented the alignment fault and allowed execution to continue.Change
On Windows x86-64, make
KYTY_SYSV_ABIuse:Other platforms keep the existing
sysv_abidefinition unchanged.Regression test
Added a Windows-only regression test that:
A/B result:
With the fix:
Testing
virtual_memory_allocation_tests --sysv-align-only: PASSThe remaining three failures were reproduced unchanged without this patch:
kernel_file_systemshader_recompiler_computepm4_context_stateThe change was also tested with the guest workload that originally exposed the alignment problem, where execution continued normally after applying the fix.
Scope
This change does not contain any game-specific workaround.
The regression test reproduces the stack-alignment condition independently of any guest binary or game data.
AI use
AI assistance was used during debugging, investigation, and regression-test development.
I reviewed the resulting code, reproduced the failure with and without the fix, built the affected targets, ran the regression tests locally, and manually validated the change against the workload that originally exposed the issue.
@coderabbitai[bot] on GitHub · 2026-10-02 23:38 UTC · original · edited 2026-10-03 00:07 UTC
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
0a17c702-cc8b-4243-964d-e4de1d052366📥 Commits
Reviewing files that changed from the base of the PR and between
82193ca55cand617e728c93.📒 Files selected for processing (1)
tests/VirtualMemoryAllocationTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
📝 Walkthrough
Walkthrough
KYTY_SYSV_ABInow addsforce_align_arg_pointeron Windows x86-64 and retainssysv_abion other platforms. A new test exercises a Windows-ABI trampoline calling a SysV function with a misaligned stack. The test checks target execution, nested Windows-ABI stack alignment, and memory cleanup. Windows builds can run the test with--sysv-align-only; non-Windows builds report it as skipped.Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Bug fix
Merge Risk: ⚪ Minimal · up to
617e7The Windows alignment change has no identified merge-blocking issue in the supplied evidence; it is ready for normal checks.
Security Architecture Review
Security architecture risk: 🔵 Low · up to
617e7The change is a narrowly scoped alignment correction, not a new access or authorization mechanism. The new execution path is confined to a regression test. Risk is low because the shared attribute affects existing Windows host functions, whose production behavior has not been exhaustively verified.
Retained concerns
No architecture-level concerns identified.
Security review details
Security Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 helpto get the list of available commands.@coderabbitai[bot] on GitHub · 2026-10-02 23:38 UTC · original · edited 2026-10-03 00:02 UTC
On
tests/VirtualMemoryAllocationTests.cppline 309 (outdated):🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 3638
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 43182
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 43857
Preserve Windows nonvolatile state across the SysV call.
MisalignedSysvHostEntryTargetuses the SysV ABI. That ABI permits the target to clobberrsiandxmm6–xmm15. The Windows-ABI caller expects these registers to survive, but the trampoline saves onlyrdiandr12.This test runs in the normal Windows test sequence. A target/compiler that uses these registers can corrupt live caller state after the trampoline returns. Save and restore
rsiandxmm6–xmm15while retaining the deliberate stack misalignment.The impact is limited to this Windows test executable, so classify this as a minor issue rather than a major production stability issue.
✅ Addressed in commit
617e728@coderabbitai[bot] on GitHub · 2026-10-02 23:38 UTC · original · reviewed
Actionable comments posted: 1
🧹 Nitpick comments (1)
ℹ️ Review info
⚙️ Run configuration
69546bec-de84-4903-b0b8-5f15017fc81f📥 Commits
Reviewing files that changed from the base of the PR and between
e317465d8aand82193ca55c.📒 Files selected for processing (2)
src/common/abi.htests/VirtualMemoryAllocationTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
@theantipopau on GitHub · 2026-10-07 23:47 UTC · original
Integrated into our fork (theantipopau/KytyPS5
main, cherry-picks324c6b52+475a42b0) on Windows x64 against current upstream/main (420bb51d):alltarget).virtual_memory_allocation_testspasses with the hardened alignment cases, both via ctest and a direct run:VirtualMemoryAllocationTests: all cases passed.agc: new abi(67d7db68) and the SysV/DLC scalar work without conflicts.We exercise host-entry calls through real guest titles locally, so the Windows SysV realign matters on our path — confirmed no regression after integration.
@Nmzik on GitHub · 2026-10-08 14:44 UTC · original
Invalid fix. Bug is somewhere else. Game is working fine
Pull request closed