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, May 8, 9:39 PM
Unknown Object (File)
Mon, May 6, 1:24 PM
Unknown Object (File)
Sun, May 5, 5:52 PM
Unknown Object (File)
Wed, May 1, 12:15 AM
Unknown Object (File)
Sun, Apr 21, 3:29 AM
Unknown Object (File)
Apr 8 2024, 11:10 AM
Unknown Object (File)
Mar 27 2024, 10:36 AM
Unknown Object (File)
Feb 9 2024, 4:20 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