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
F106121797: D42078.id.diff
Wed, Dec 25, 6:34 PM
Unknown Object (File)
Mon, Dec 9, 5:08 PM
Unknown Object (File)
Wed, Dec 4, 6:44 PM
Unknown Object (File)
Nov 25 2024, 11:02 AM
Unknown Object (File)
Nov 24 2024, 5:35 PM
Unknown Object (File)
Nov 22 2024, 8:18 PM
Unknown Object (File)
Nov 22 2024, 6:10 AM
Unknown Object (File)
Nov 16 2024, 2:54 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