This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt][aarch64] Add PAC-RET/BTI support to TSan.
Needs ReviewPublic

Authored by danielkiss on Apr 8 2021, 2:42 PM.

Details

Summary

Support for -mbranch-protection on aarch64.

Diff Detail

Event Timeline

danielkiss created this revision.Apr 8 2021, 2:42 PM
danielkiss requested review of this revision.Apr 8 2021, 2:42 PM

I am not much knowledgeable about PAC and would otherwise leave this to somebody else.

compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S
42

Since this is a compile-time check, are we supposed to provide 2 builds of tsan runtime after this change? If yes, should this also include some cmake changes?

yln added a reviewer: qikon.Apr 13 2021, 9:28 AM
qikon resigned from this revision.Apr 13 2021, 10:01 AM
qikon edited reviewers, added: ab; removed: qikon.
ab added inline comments.May 11 2021, 10:47 AM
compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S
42

Yeah, I would go further: the instructions are hints and no-ops, can't they always be used? Though it would need a mechanism to disable it by default: I see PAC_FLAG is based on the new PAC/BTI feature macros; we'd want to disable this for darwin.

I'm not familiar with the contract around the GNU property and the CFI info and all that, so maybe there's some complication there.

pbarrio added inline comments.Jul 27 2021, 9:39 AM
compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S
43

Minor comment: if this is only meant to work with the clang integrated assembler (i.e. compatibility with other assemblers such as GNU not needed), then you can just use PACIASP directly. Same for the other hints. The integrated assembler should understand all the PAC mnemonics as an *input*, even at Armv8.0-A. Obviously, it will only emit them as an *output* above Armv8.3-A. This decision was made to ensure assembly code was as understandable as possible.