Skip to content

fix(cpu): preserve executing code during overwrite - #584

Closed
benletchford wants to merge 1 commit into
masterfrom
dev/reserve-code-segments
Closed

fix(cpu): preserve executing code during overwrite#584
benletchford wants to merge 1 commit into
masterfrom
dev/reserve-code-segments

Conversation

@benletchford

Copy link
Copy Markdown
Owner

Closes #580.

Self-decompressing launchers can overwrite the backing bytes of the resident CODE segment they are still executing. The loader placement only changed where the failure occurred because the startup loop intentionally expands through its own segment, while a real 68040 continues from its instruction cache.

This snapshots resident CODE at load time and activates the affected 16-byte instruction-cache line only when an illegal fetch differs from the loaded bytes. Normal guest data reads and writes still observe the decompressed memory, while opcode fetches can finish the active startup line. Both the batch and precise execution paths recover consistently.

Verification:

  • cargo test --lib --quiet (2,950 passed, 3 ignored)
  • cargo check --no-default-features --quiet
  • cargo clippy --lib --quiet
  • cargo fmt --all -- --check
  • Real Alone in the Dark CD installer passes the former 290,305-instruction / 22-trap illegal-opcode halt and reaches 32 Toolbox traps without halting.

Copy link
Copy Markdown
Owner Author

Closed after review because replaying a saved CODE snapshot only after an illegal instruction is neither faithful instruction-cache emulation nor a loader-placement fix. It can selectively execute stale bytes and mask unrelated self-modifying-code faults. #580 remains open for correct heap/segment placement or CPU cache semantics.

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.

Self-decompressing applications can overwrite low-placed CODE segments during startup

1 participant