sild
https://quick-bench.com/q/314Z81FskTlcDqMCUHFVhWmDz8Q
Update 1: After moving some constants around, I get the 40% result:
https://quick-bench.com/q/lPrpQTAyDQuOoKS9MBWCTBXk1TE
No idea why it made such a big difference to the benchmark.
Update 2: If the test order is reversed, the result goes back to being only slightly faster for the sentinel version:
When our team first arrived in the office, a colleague walked over to them and said something along the lines of `let's get some sunlight in here' before opening them to reveal the deception.
[1] https://access.redhat.com/documentation/en-us/red_hat_enterp...
A page fault is used as a way of executing the trampoline without the page having to be made executable/writable---the page fault handler recognises the page as a special trampoline page and handles the jump to the trampolines target address (which was previously registered using the new syscall).
Note that AFAICS this is unrelated to Spectre. The intended use is for constructing closures for use in FFI libraries such as libffi.
EDIT: I think I perhaps misunderstood your query---are you saying why not just make a system call where the kernel creates the page for you with the desired trampoline code and execute permissions?