PCSX2 / pcsx2

PCSX2 - The Playstation 2 Emulator
https://pcsx2.net
Other
10.48k stars 1.51k forks source link

[BUG]: Crash when LoadExecPS2 is called in 128MB mode using old BIOS #11234

Open DaZombieKiller opened 2 weeks ago

DaZombieKiller commented 2 weeks ago

Describe the Bug

Note this is not necessarily a bug in the emulator itself, but it's a crash that can potentially be fixed emulator-side. This issue is intended to discuss an appropriate fix before a PR is prepared.

When a game switches ELFs using LoadExecPS2 with 128MB RAM mode enabled, the emulator may crash if the user has an older BIOS version. This is because some older BIOS versions do not have an entry for syscall 0x82 (_InitTLB)*. When the userland InitTLB function is run, it branches on the result of GetMemorySize(), calling InitTLB32MB when it is 0x2000000 or invoking the _InitTLB syscall otherwise.

* Despite _InitTLB not being present in the syscall table, the function itself does seem to exist within the BIOS.

This issue is currently confirmed to occur with BIOS 1.60, but it presumably occurs in all prior versions too. It is not yet known if any later versions exhibit the problem.

After determining affected BIOS versions or finding a way to tell if the _InitTLB syscall is missing, possible solutions could be:

Reproduction Steps

Option 1

  1. Enable 128MB RAM mode.
  2. Boot up a game that switches the running ELF.
  3. Reach a point where the ELF switch occurs.
  4. Observe the crash.

Option 2

  1. Enable 128MB RAM mode.
  2. Enable Host Filesystem.
  3. Boot main.elf (with load.elf next to it) from the samples provided in https://github.com/PCSX2/pcsx2/pull/11195.
  4. Observe the crash.

Expected Behavior

No response

PCSX2 Revision

v1.7.5801

Operating System

Windows 11

If Linux - Specify Distro

No response

CPU

Ryzen 9 3900X

GPU

GTX 2080 Super

GS Settings

No response

Emulation Settings

No response

GS Window Screenshots

No response

Logs & Dumps

No response