Open matlo607 opened 2 months ago
Thanks for the report! AFAIK we don't have strict needs around this related to Wasmtime or Cranelift per se, and so long as things work and pass tests changing should be fine. I believe we unfortunately don't have automated testing for this in that our QEMU emulation in CI I don't think has this enabled, but it might not be too too hard to set up.
Description
DWARF for the Arm® 64-bit Architecture (AArch64) specifies that the RA state should be set with
DW_CFA_AARCH64_negate_ra_state
.The same result can be obtained using
DW_CFA_val_expression
.This behavior was added to libgcc to support unwinding when the RA state is set with
DW_CFA_val_expression
(Bug 104689).Current implementation in Wasmtime: https://github.com/bytecodealliance/wasmtime/blob/37ed724c9da2ee5a516923cf221ade19b78f63eb/cranelift/codegen/src/isa/unwind/systemv.rs#L115-L128
Issue
Armv9.5-A introduced a new extension to PAC for return address signing: PAuth_LR. It adds a new diversifier PC, aside to SP. The value of PC used by PAC2 algorithm corresponds to its value at the time of signing, i.e. the address of the
paci<k>sppc
instruction, orpaci<k>sp
if NOP-space instructions are used.A new DWARF directive
DW_CFA_AARCH64_negate_ra_state_with_pc
was introduced to record the position of signing and authentication, and to express that PACv2 algorithm was used (vs PACv1 relying onDW_CFA_AARCH64_negate_ra_state
). During unwinding, this directive saves the PC diversifier into the frame state, to later use it to authenticate the return address.In my understanding, the approach based on
DW_CFA_val_expression
is not working anymore in this context, as the libgcc unwinder cannot know the difference between aDW_CFA_val_expression
used for PAC, and another one used for something else, and so cannot save PC at the time of signing.Links