Page MenuHomeFreeBSD

arm64: Add BTI landing pads to assembly functions
ClosedPublic

Authored by andrew on Oct 4 2023, 3:23 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Jul 17, 6:09 PM
Unknown Object (File)
Wed, Jul 17, 5:56 AM
Unknown Object (File)
Mon, Jul 15, 5:47 AM
Unknown Object (File)
Mon, Jul 8, 4:54 AM
Unknown Object (File)
Mon, Jul 8, 4:52 AM
Unknown Object (File)
Mon, Jul 8, 4:50 AM
Unknown Object (File)
Mon, Jul 1, 10:51 PM
Unknown Object (File)
Thu, Jun 27, 3:44 PM
Subscribers

Details

Summary

When we enable BTI iboth the first instruction in a function that could
be called indirectly, and a branch within a function need a valid
landing pad instruction.

There are three options for these instructions:

  1. A breakpoint instruction
  2. A pointer authentication PACIASP/PACIBSP
  3. A BTI instruction

Option 1 will raise a breakpoint exception so isn't useable in either
cases. Option 2 could be used in some function entry cases, but needs
to be paired with an authentication instruction, and is normally only
used in non-leaf functions we can't use it in this case. This leaves
option 3.

There are four variants of the instruction, the C variant is used on
function entry and the J variant is for jumping within a function.
There is also a JC that works with both and one with no target that
works with neither.

Sponsored by: Arm Ltd
Sponsored by: The FreeBSD Foundation (earlier version)

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

andrew requested review of this revision.Oct 4 2023, 3:23 PM
sys/arm64/arm64/locore.S
107

Does the need for BTI_J apply only to unconditional branches?

sys/arm64/include/asm.h
117

Could you please add a comment explaining how and when to use these macros?

sys/arm64/arm64/locore.S
107

It is used as a target for a BR/BRA* instruction to reduce where the instruction can branch to in the case the register value is corrupted.

Add a comment on usage of BRI_C/BTI_J

markj added inline comments.
sys/arm64/include/asm.h
120
This revision is now accepted and ready to land.Oct 9 2023, 2:33 PM