This is an archive of the discontinued LLVM Phabricator instance.

AArch64: Implement support for the shadowcallstack attribute.
ClosedPublic

Authored by pcc on Apr 3 2018, 6:03 PM.

Details

Summary

The implementation of shadow call stack on aarch64 is quite different to
the implementation on x86_64. Instead of reserving a segment register for
the shadow call stack, we reserve the platform register, x18. Any function
that spills lr to sp also spills it to the shadow call stack, a pointer to
which is stored in x18.

Diff Detail

Repository
rL LLVM

Event Timeline

pcc created this revision.Apr 3 2018, 6:03 PM
vlad.tsyrklevich accepted this revision.Apr 4 2018, 2:28 PM
vlad.tsyrklevich added inline comments.
clang/docs/ShadowCallStack.rst
12 ↗(On Diff #140890)

Should also mention aarch64 here.

llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
78 ↗(On Diff #140890)

It's sort of a stretch to construct a scenario where this is likely to happen, but is it possible that a runtime function marked with __attribute__((no_sanitize("shadowcallstack"))) would spill x18 across a function call because of this mask if it's referenced before and after? If that was a concern, we could make this test hasAttr(SCS) || hasFlag(fFixedx18)

This revision is now accepted and ready to land.Apr 4 2018, 2:28 PM
eugenis added inline comments.Apr 4 2018, 2:30 PM
clang/docs/ShadowCallStack.rst
12 ↗(On Diff #140890)

needs update

llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
1153 ↗(On Diff #140890)

That's way too cryptic, please call it NeedShadowCallStackProlog or something similar.

pcc updated this revision to Diff 141063.Apr 4 2018, 2:44 PM
pcc marked 3 inline comments as done.
  • Addres review comments
eugenis accepted this revision.Apr 4 2018, 2:49 PM
This revision was automatically updated to reflect the committed changes.