fix(gs): decode sceGsSetDefDBuff trailing args via EABI registers, not o32 stack offsets - #186
Draft
smmathews wants to merge 1 commit into
Draft
fix(gs): decode sceGsSetDefDBuff trailing args via EABI registers, not o32 stack offsets#186smmathews wants to merge 1 commit into
smmathews wants to merge 1 commit into
Conversation
…t o32 stack offsets sceGsSetDefDBuff read ztest/zpsm/clear with readStackU32 at offsets 16/20/24. Under the EABI this runtime targets, arguments 5-8 arrive in $t0-$t3 (GPRs 8-11), so those stack offsets hold caller-frame bytes, not the trailing args. The sibling sceGsSetDefDBuffDc already decodes the same three args correctly with decodeGsTrailingArgs3 (registers first, stack only as an all-zero fallback); this routes sceGsSetDefDBuff through the same helper. Adds a register-ABI regression test that seeds distinct register and stack sentinels and asserts the written ZBUF/TEST fields reflect the register values.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(gs): decode sceGsSetDefDBuff's trailing args via EABI registers, not o32 stack offsets
The bug
sceGsSetDefDBuffreads ztest/zpsm/clear from stack offsets 16/20/24, but under this runtime's EABI those args are register-passed in$t0-$t2(GPRs 8-10), so the reads pick up caller-frame bytes and seed the double buffer's Z-test/Z-format from stale stack data on every call.The fix mirrors an existing sibling
decodeGsTrailingArgs3(registers first, all-zero-register stack fallback) is already used bysceGsSetDefDBuffDcfor the identical three args. This change makessceGsSetDefDBuffconsistent with it. The helper degrades to the exact prior stack reads only when all three registers are zero, so the sole behavioural change is for register-passed nonzero trailing args (the buggy case).Explicit non-fix
sceGifPkRefLoadImagein the same file also usesreadStackU32(offsets 0 and 8) and is correct as written, untouched by this PR: it consumes eight register args first (GPRs 4-11), so its width/height are genuinely the 9th/10th args and belong on the stack. The distinguishing test for anyreadStackU32site is how many register args precede it: under eight is a bug, eight or more is correct.Scope
No repo-wide EABI audit of other
readStackU32sites was done (SIF.cpp and MemoryCard.cpp also call it); flagged as separate follow-up work.Test / repro
A register-ABI regression test seeds distinct sentinels in GPRs 8-10 and at the o32 stack offsets, then asserts the written ZBUF/TEST fields reflect the register values rather than the stack bytes.
Build and run:
Durable mutation claim: revert the three-line helper swap in
sceGsSetDefDBuffand the two new assertions report the stack sentinels instead of the register sentinels.