blob: 426f26d3de8781a9170cee546580da86db53aee4 [file] [log] [blame]
Ruchika Gupta55583eb2022-01-25 12:47:07 +05301.. _arm_security_extensions:
2
3#######################
4Arm Security Extensions
5#######################
6
7.. _bti:
8
9Branch Target Identification
10****************************
11
12Branch Target Identification (BTI) is an ARMv8.5 extension that provides
13Control Flow Integrity (CFI) around indirect branches and their targets, thus helping
14to limit the JOP (Jump Oriented Programming) attacks.
15
16With this extension, ARM8.5-A introduces Branch Target Instructions (BTIs).
17BTIs are also called landing pads. The processor can be configured so that
18indirect branches (BR and BLR) only allows target landing pad instructions.
19If the target of an indirect branch is not a landing pad, a Branch Target Exception
20is generated.
21
22How to enable BTI for OP-TEE core
23==================================
24
25To make use of BTI in TEE core on CPU's that support it, enable the option
26``CFG_CORE_BTI``.
27
28OP-TEE core makes use of some built-ins in the GCC/clang toolchains. So, in order
29to use the option ``CFG_CORE_BTI``, make sure that GCC toolchain has been built with
30``--enable-standard-branch-protection`` is used else OP-TEE will fail to build.
31By default libraries such as libgcc.a are built with flags (``-mbranch-protection=none``),
32hence are incompatible with branch protection enabled. The Arm GNU compiler team
33is looking for ways of providing users easy access to BTI-enabled libraries.
34In the short-term, they plan to create documentation to make it easier for users to
35build BTI-enabled libraries themselves. Longer-term, they will begin discussions
36on how to ensure BTI-enabled libraries are available automatically to users.
Jerome Forissier2f11d802022-01-26 10:08:27 +010037Please contact GCC team for more information on same. In the meantime, building a
38BTI-enabled GCC toolchain is possible as decribed in :ref:`faq_gcc_bti`.
Ruchika Gupta55583eb2022-01-25 12:47:07 +053039
40The same problem is also there with clang toolchain. So, when using clang to build
41OP-TEE with ``CFG_CORE_BTI=y``, builtins (found in llvm's "compiler-rt"
42project) must be built with BTI protection enabled. We have some instructions on
Jerome Forissier2f11d802022-01-26 10:08:27 +010043how to build the compiler-rt with BTI enabled. These are available in
44:ref:`faq_llvm_bti`.
Ruchika Gupta55583eb2022-01-25 12:47:07 +053045
46
47How to enable BTI for TA's
48===========================
49
50To make use of BTI support for TA's and user mode libraries, enable the option
51``CFG_TA_BTI``. This will ensure that all libraries provided by OP-TEE to the TA's
52as well as the TA's are built with BTI option.
53
54When the TA's are loaded by ldelf, they are checked at run time for the BTI NOTE
55property in ELF before enabling the protection for the TA.
56
57When building TA's, you need to ensure that any external library used has been
58built with branch-protection. This can be done by checking the library using readelf
59command with option ``-n``. The BTI enabled libraries will have BTI NOTE property in
60``.note.gnu.property`` section. If that is not the case, compilation will stop with a
61warning. This is done intentionally to warn the user.
62
63
64.. note::
65
66 The BTI support is currently not compatible with options ``CFG_VIRTUALIZATION`` and
67 ``CFG_WITH_PAGER``.