Skip to content

Fix PROT_EXEC restrictions on Apple Silicon#77

Closed
Techcable wants to merge 1 commit intoRavenbrook:masterfrom
Techcable:fix/basic-apple-silicon-support
Closed

Fix PROT_EXEC restrictions on Apple Silicon#77
Techcable wants to merge 1 commit intoRavenbrook:masterfrom
Techcable:fix/basic-apple-silicon-support

Conversation

@Techcable
Copy link

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 ./configure script still doesn't work correctly on Apple Silicon, but I figure that's an issue for another PR 😉

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 :)
@rptb1
Copy link
Member

rptb1 commented Jan 13, 2023

@Techcable Can you say whether #93 meets your requirements?

@rptb1 rptb1 added the arch.a6 Relates to arm64/aarch64 label Jan 17, 2023
@rptb1 rptb1 added the blocked Unable to proceed. See comment for reason. label Feb 14, 2023
@thejayps
Copy link
Contributor

JPH + @rptb1: we believe the issue related to this PR is resolved by PR #93. Raise an issue if not the case.

@thejayps thejayps closed this Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch.a6 Relates to arm64/aarch64 blocked Unable to proceed. See comment for reason.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants