Review: preserve registers in ExitCriticalSection - #21
Conversation
|
@cubic-dev-ai review this PR |
@Alexbeav I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Requires human review: Auto-approval blocked by 1 unresolved issue from a previous review of this commit.
Re-trigger cubic
|
Both compiler-coverage comments are addressed in I chose the documented, verified-toolchain gate requested in the second comment: Windows x64 MinGW GCC 16.1.0. The test still calls the real Every other configuration registers the same CTest name with The runtime fix and the source-owned fixture are unchanged. Please re-review the updated head. |
|
Merged upstream as RetroPortingToolKit#322 (Alexbeav:codex/fix-exit-critical-section, merged 2026-09-05T17:16:15Z). Closing this internal review PR as complete; the branch is preserved. |
Summary
Preserve the caller's registers in SYS(02h) ExitCriticalSection. The handler currently clears
v0, although the BIOS contract gives this service no return value. A wrapper can return an earlier BIOS result through ExitCriticalSection; clearing that value turns success into a false failure.Ghost in the Shell PAL SCES-01050 exposed this when movie startup entered cleanup while disc audio was already streaming. Removing the unwanted write lets the caller enter its video decode loop. The interrupt-enable update and host continuation behavior remain unchanged.
Reference: PSX-SPX SYS(02h).
Scope
17f49ad3b20dc30917a881a02baaa25374c13d18.49d5f6233c330c39346fda008c82c59675c8cbc2.runtime/src/traps.c,runtime/tests/test_exit_critical_section.c,runtime/CMakeLists.txt,docs/accuracy/bios_exit_critical_section.md.Validation
v0and status-register state and compares the full CPU state. It uses no BIOS or retail fixture.dirty_text_continuation_guardsexpectation,aot_overlay_discovery, and the Windows newline expectation inrelease_zip.check_interior_fragment_contractassertion. No AOT source is changed here.git diff --checkand the accuracy-document link check pass.The same runtime correction was tested in a local GITS PAL SCES-01050 build using retail SCPH5552: the opening, menu and New Game movie render in digital and analog routes; the digital route reaches the first mission and its normal death/menu return. A Silent Bomber PAL SLES-02792 frontend control passes before and after. The operator accepted the corrected GITS build. These retail observations belong to that tested local integration; they are not a new gameplay run on this upstream-base build.
The real-handler test runs on its verified Windows x64 MinGW GCC 16.1.0 toolchain. Other configurations register an explicit CTest skip, with the compiler and reason. Clang/MSVC register-preservation coverage and full-campaign compatibility are not claimed.
Review corrections
Skippedwith the reason. This validates the coverage report, not the register contract on Clang.Review request
Please review the SYS(02h) register contract, host continuation behavior, and the real-handler regression. This fork PR is the review step before submitting the exact reviewed commit upstream.
Developed with AI assistance; validated as described (test evidence in PR body). AI writes the code and the PR, but I always test before I send something up. Happy to iterate on this process with your feedback.