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)
Thu, Nov 7, 10:45 PM
Unknown Object (File)
Thu, Nov 7, 12:05 AM
Unknown Object (File)
Fri, Oct 25, 1:57 PM
Unknown Object (File)
Fri, Oct 18, 5:31 AM
Unknown Object (File)
Oct 16 2024, 8:53 PM
Unknown Object (File)
Oct 16 2024, 12:25 PM
Unknown Object (File)
Oct 14 2024, 11:25 PM
Unknown Object (File)
Oct 14 2024, 9:26 AM
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