Fix PROT_EXEC restrictions on Apple Silicon#77
Closed
Techcable wants to merge 1 commit intoRavenbrook:masterfrom
Closed
Fix PROT_EXEC restrictions on Apple Silicon#77Techcable wants to merge 1 commit intoRavenbrook:masterfrom
Techcable wants to merge 1 commit intoRavenbrook:masterfrom
Conversation
Calling mmap(PROT_WRITE | PROT_EXEC) will fail due to restrictions on marking memory executable & writable at the same time. See apple developer documentation on this new restriction: https://developer.apple.com/documentation/apple-silicon/porting-just-in-time-compilers-to-apple-silicon This workaround simply stops requesting PROT_EXEC entirely on Apple Silicon. This is not a complete solution, because it does not allow clients to use seamlessly garbage collection to manage their executable memory. See issue Ravenbrook#75 (which is not fully resolved by this) Note that any "proper" solution would still require signficant work to interact with the new Apple APIs for JIT. This means that it is almost certinally going to require some effort on the part of the client, and possibly more APIs on the part of the MPS. This commit does manage to get basic support for the Apple Silicon chips working, and it works fine as long as you don't use the MPS to allocate executable memory (it's fine if you do it seperately). The example scheme interpreter builds and runs correctly on my Apple M1 :)
Member
|
@Techcable Can you say whether #93 meets your requirements? |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, on Apple Silicon chips, calling
mmap(PROT_WRITE | PROT_EXEC)will fail due to restrictions on marking memory executable & writable at the same time.See apple developer documentation on this new restriction:
https://developer.apple.com/documentation/apple-silicon/porting-just-in-time-compilers-to-apple-silicon
This workaround simply stops requesting PROT_EXEC entirely on Apple Silicon. This is not a complete solution, because it does not allow clients to use seamlessly garbage collection to manage their executable memory.
However, it does get basic support working. IT works fine as long as you don't use the MPS to directly allocate executable memory.
See also issue #75 (which is not fully resolved by this)
Note that any "proper" solution would still require signficant work to interact with the new Apple APIs for JIT.
This means that it is almost certainly going to require some effort on
the part of the client, and possibly new APIs on the part of the MPS.
After this commit, the example scheme interpreter builds and runs correctly on my Apple M1 :)
Note the
./configurescript still doesn't work correctly on Apple Silicon, but I figure that's an issue for another PR 😉