Skip to content

Fix EE FCSR preservation and add fail-closed preemptive-stop tests - #15

Draft
fjtrujy wants to merge 10 commits into
masterfrom
fix/ee-fcsr-preservation
Draft

fjtrujy wants to merge 10 commits into
masterfrom
fix/ee-fcsr-preservation

Conversation

@fjtrujy

@fjtrujy fjtrujy commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Goal (Draft)

True preemptive EE Ctrl-C without application polling, alongside the FCSR correctness fix. Preemptive interruption is not implemented or safe to enable yet.

Included

  • Correct COP1 FCSR/FIR capture and FCSR restore; add an opt-in FCSR diagnostic and regression tests.
  • Add host-tested fail-closed stop ownership and complete-context validity checks (never wired to live EE stops).
  • Add isolated EE thread-identity, scheduling and target-suspension diagnostics. CI cross-builds them but never runs them on real hardware. No production exception vector or comparator is changed.

Findings

  • Real PS2: interrupt-time thread IDs matched 12/12 in both controlled CPU loops; an equal-priority observer was starved by an unyielding priority-1 target.
  • Real PS2 priority-64 target experiment: console marker timed out, but two identical read-only BSS snapshots confirmed 26 observer ticks while the busy loop was active. Actual priorities were not independently printed.
  • PCSX2 recompiler and interpreter: a priority-0 observer advanced while the target remained at priority 1 (26/24 ticks), with the effective priority independently checked.
  • PCSX2 recompiler and interpreter: from the priority-0 observer, SuspendThread(target_id) froze the target iteration counter, and ResumeThread(target_id) resumed its progress. Emulator only; priority 0 is also used by PS2SDK kernel machinery and may not be safe on a physical console.
  • Native/GNU GDB tests, cross-builds and static analysis run in CI. Hardware and emulator evidence is recorded with limitations in the research documentation.

Remaining safety gates

Show priority-0 reception and targeted suspension do not disturb PS2Link/kernel on real hardware; obtain the complete saved EE GPR/k0/k1/HI/LO/FPU context and exact PC for a suspended thread; guarantee correct branch-delay and ErrorEPC/BD2 resume; handle wrong-thread/disconnect/repeated Ctrl-C; and pass real-hardware end-to-end GDB stop/continue tests. Do not merge as completed preemptive Ctrl-C until those gates are met.

@fjtrujy fjtrujy changed the title Fix EE COP1 FCSR capture and restore in GDB exceptions Fix EE FCSR preservation and add fail-closed preemptive-stop tests Nov 16, 2026
@fjtrujy
fjtrujy marked this pull request as draft November 17, 2026 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant