IOP: Reset recompiler and map RAM mirrors on IOP soft reset#14288
Draft
fjtrujy wants to merge 1 commit intoPCSX2:masterfrom
Draft
IOP: Reset recompiler and map RAM mirrors on IOP soft reset#14288fjtrujy wants to merge 1 commit intoPCSX2:masterfrom
fjtrujy wants to merge 1 commit intoPCSX2:masterfrom
Conversation
Contributor
|
Hm this doesn't sound quite right to me, if I make a simple executable that just calls Reading |
When SifIopReset triggers (SBUS_F240 bit 19), psxReset() reloads the IOP BIOS kernel into RAM but does not flush the IOP recompiler cache. The recompiler keeps stale compiled blocks for IOP RAM addresses that now contain different code. When the fresh kernel executes, the recompiler serves old translations, causing the IOP to crash on garbage instructions (psxUNK). Add psxCpu->Reset() after psxReset() in the SBUS_F240 handler to flush all cached recompiler blocks. This forces fresh recompilation from the new RAM contents, allowing IOP soft resets to complete correctly. This fixes SifIopReset as used by ps2link and other PS2 homebrew that perform runtime IOP resets. Additionally, map IOP RAM mirrors throughout kuseg (pages 0x0000- 0x1DFF) in the recompiler lookup table. The PS2 IOP mirrors its 2MB RAM across the entire kuseg address space (0x00000000- 0x1DFFFFFF). The BIOS uses these mirrored addresses during IOP soft resets (e.g. jumping to 0x0d000100 which mirrors to physical 0x00000100). Without the mirrored pages in recLUT, code execution at mirrored addresses would hit unmapped pages.
cd8806b to
f69eeaf
Compare
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.
Summary
Fixes IOP soft reset (
SifIopReset) crashing with stale recompiler blocks.When
SifIopResettriggers (SBUS_F240 bit 19),psxReset()reloads the IOP BIOS kernel into RAM but does not flush the IOP recompiler cache. The recompiler keeps stale compiled x86 blocks for IOP RAM addresses that now contain different code. When the fresh kernel executes, the recompiler serves old translations, causing the IOP to crash on garbage instructions (psxUNK).Changes
psxCpu->Reset()afterpsxReset()in the SBUS_F240 handler — flushes all cached recompiler blocks, forcing fresh recompilation from the new RAM contents. This is the critical fix.Map IOP RAM mirrors in recLUT (kuseg pages 0x0000-0x1DFF) — the PS2 IOP mirrors its 2MB RAM across the entire kuseg address space. The BIOS uses mirrored addresses during soft resets (e.g.
0x0d000100→ physical0x00000100). Without mirrored pages in recLUT, code at mirrored addresses hits unmapped pages.How it was found
Tested with ps2link performing
SifIopResetviaps2client reset. Without the fix:psxReset()reloads the IOP kernelpsxUNK: f0000102crashWith the fix, the recompiler cache is flushed and the IOP reboots cleanly.
Test plan
ps2client resetperforms a clean IOP soft rebootps2client resetcommands workps2client execee+ps2client resetcycle works