mupen64plus / mupen64plus-core

Core module of the Mupen64Plus project
1.32k stars 258 forks source link

Debugger: read_memory_32 initiates TLB_refill exception on reading invalid memory #680

Open flagrama opened 5 years ago

flagrama commented 5 years ago

The full offending code path is located at the end of this message.

If you use the debugger to read any memory that isn't "valid" the virtual_to_physical_address function forces a TLB_refill_exception to the emulator. As all of the "readmemory" functions use read_memory_32 they are all affected by this issue. I believe that the `writememory` functions are also affected by this, however I have not tested it.

The debugger should never be causing exceptions to occur. Either the debugger needs to be special case opted out of the passing of the exception, or the debugger needs to use its own memory handler that simply reads the data.

https://github.com/mupen64plus/mupen64plus-core/blob/50a6f321eda9f8cb4397364e2d2842ca83268ec8/src/debugger/dbg_memory.c#L292-L298 https://github.com/mupen64plus/mupen64plus-core/blob/50a6f321eda9f8cb4397364e2d2842ca83268ec8/src/device/r4300/r4300_core.c#L287-L301 https://github.com/mupen64plus/mupen64plus-core/blob/50a6f321eda9f8cb4397364e2d2842ca83268ec8/src/device/r4300/tlb.c#L103-L147

m4xw commented 4 years ago

@Gillou68310 Wanna just add a ignore tlb param or ifdef the prototype for DBG or dupe code?