-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Currently Wasmtime will enable pointer authentication bits on AArch64 when possible, notably for macOS by default. This does not currently work with tail calls which means that cargo test currently fails with various segfaults.
From what I can understand the general pointer authentication scheme right now is:
- When a function is entered, the return address,
lr, is "encrypted" with bothspand the B key - When a function returns, the return address is "decrypted" with
spand the B key
For tail calls this decryption isn't happening currently, meaning that the return address is corrupted for when the tail-called function finally returns.
I've attempted a naive fix for this where I insert an auti*sp instruction before the branch for the ReturnCall instruction, but this does not work because if a function tail calls a function with stack arguments it means that sp is different from the beginning of the function and the end of the function. This means that different values go into the encryption/decryption phases which means that the return address gets corrupted again.
I'm not entirely sure how to fix this myself, but I'm also a little tired right now so may be missing something. cc @fitzgen