Closed Bug 1837194 Opened 2 years ago Closed 2 years ago

Support MAP_JIT with pthread_jit_write_protect_np on Apple Silicon

Categories

(Core :: JavaScript Engine: JIT, task)

task

Tracking

()

RESOLVED FIXED
116 Branch
Tracking Status
firefox116 --- fixed

People

(Reporter: jandem, Assigned: jandem)

References

Details

(Whiteboard: [sp3])

Attachments

(2 files)

See bug 1835876 comment 5. We can't do RWX on this platform, so we need to use Apple's thread-local permission switching APIs. I have a prototype of this working locally for the JS JITs.

Blocks: 1474447

On Mac ARM64 hardware we still use mprotect and W^X because supporting RWX pages
requires additional changes. This patch makes those changes.

With Apple's fast thread-local writable/executable toggling API for all JIT pages
(pthread_jit_write_protect_np) this is a much more efficient version of W^X.

Using MAP_JIT requires some changes to how we reserve and commit JIT pages because
of additional restrictions the kernel enforces for these regions.

Now that we're using MAP_JIT on Apple Silicon we should also use the allow-jit
entitlement.

The weaker allow-unsigned-executable-memory entitlement is still needed for the Intel
hardware where we don't use MAP_JIT yet. We'll probably be able to use MAP_JIT there
too at some point, but for now this is a step in the right direction.

Depends on D180407

Pushed by jdemooij@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/fa183f58a682 Use MAP_JIT with pthread_jit_write_protect_np on Apple Silicon. r=nbp,mstange,rhunt https://hg.mozilla.org/integration/autoland/rev/1dc3aecfed3a Add com.apple.security.cs.allow-jit entitlement. r=haik
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 116 Branch
Regressions: 1838166
Whiteboard: [sp3]
Regressions: 1838242
No longer regressions: 1838166
Regressions: 1838532
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: