mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-09-13 06:53:22 -06:00
JIT: fastmem: handle W^X codemem in fault handler
Set the protection on the code memory to RW when the fault handler rewrites code, and set it back to RX, the protection prior to the interrupt, after doing so. This fixes a segfault that occurred on NetBSD, due to its PaX MPROTECT policy, when trying to run fastmem. This could potentially be the reason as to why fastmem does not work on Apple Silicon Macs, although I am unable to confirm as I do not possess such a device to test with.
This commit is contained in:
@ -826,7 +826,11 @@ bool ARMJIT_Memory::FaultHandler(FaultDescription& faultDesc, melonDS::NDS& nds)
|
|||||||
rewriteToSlowPath = !nds.JIT.Memory.MapAtAddress(faultDesc.EmulatedFaultAddr);
|
rewriteToSlowPath = !nds.JIT.Memory.MapAtAddress(faultDesc.EmulatedFaultAddr);
|
||||||
|
|
||||||
if (rewriteToSlowPath)
|
if (rewriteToSlowPath)
|
||||||
|
{
|
||||||
|
nds.JIT.JitEnableWrite();
|
||||||
faultDesc.FaultPC = nds.JIT.JITCompiler.RewriteMemAccess(faultDesc.FaultPC);
|
faultDesc.FaultPC = nds.JIT.JITCompiler.RewriteMemAccess(faultDesc.FaultPC);
|
||||||
|
nds.JIT.JitEnableExecute();
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user