[PATCH] D135103: RFC: [AArch64] Add SEH_Nop for PAC/BTI instructions in prologues/epilogues

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 3 13:53:31 PDT 2022


mstorsjo created this revision.
mstorsjo added reviewers: efriedma, zzheng, sdesmalen.
Herald added subscribers: hiraditya, kristof.beyls.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a project: LLVM.

This avoids prologue/epilogue instruction mismatches.

However, this probably isn't the right way to go - just posting this
patch for discussion (I haven't made any tests for it yet).

Currently if compiling for Windows with Clang with
-mbranch-protection=standard, it does generate PAC instructions for
e.g. return address signing. However, as long as the Windows unwinder
doesn't have any opcodes for reversing the signing, it's entirely
futile to try to fix it with SEH_Nop - such a function wouldn't be
unwindable anyway.

Thus, I presume we not generate any return address signing instructions
for Windows (either make the -mbranch-protection option error out,
or just not honor it).

The BTI instructions shouldn't be quite as harmful - so we maybe could
keep them (and add SEH_Nop for them to make the SEH opcodes match)?
Although I guess BTI is a feature which needs to be enabled by the
OS for the process at hand, which won't happen on Windows at the
moment, even if the HW would have support for it?

(The Windows native feature corresponding to BTI is CFGuard, which
relies on compiler instrumentation instead of HW features.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135103

Files:
  llvm/lib/Target/AArch64/AArch64BranchTargets.cpp
  llvm/lib/Target/AArch64/AArch64FrameLowering.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135103.464804.patch
Type: text/x-patch
Size: 6139 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221003/48fdde9c/attachment.bin>


More information about the llvm-commits mailing list