3 ms·
On m1 switch RX to RW and back does not require a syscall The mprotect call will fail as that isn’t a valid mechanism to toggle rw/rx
by olliej 5y ago
On m1 switch RX to RW and back does not require a syscall
The mprotect call will fail as that isn’t a valid mechanism to toggle rw/rx
- monocasa 5y agoCan you give a citation that mprotect will fail? Yes there's the new, faster mechanism, but I'm surprised that they broke mprotect.
- olliej 5y agoit's possible the old mprotect call will work if you use the appropriate initial mmap flag to get a jit region, but I would be surprised. The rules for rwx regions are already very restrictive compared to mmap/mprotect/etc APIs on other platforms. I don't have an M1 Mac to test myself, but the "faster" mechanism doesn't involve anything in the pagetables, so I think toggling pagetable walks into the existing restrictions on RWX allocations.
- monocasa 5y agoIt certainly looks like mprotect is still supported (if occasionally broken) as of 11.2 on apple silicon. Qemu and v8 both seem to rely on it. https://developer.apple.com/forums/thread/672804 https://developer.apple.com/forums/thread/672804
- saagarjha 5y agoI haven’t tested on a Mac recently, but I’m pretty sure that mprotect will change the base page permissions but SPRR will continue to apply (and you’ll need to call pthread_jit_write_protect_np).