Skip to content

Commit

Permalink
libutils: asm.S : Introduce BTI in macros for functions
Browse files Browse the repository at this point in the history
When the TEE core, TA's or user space libraries are built for BTI,
add a BTI landing pad to the start of all functions, ensuring that
they are BTI safe.

Signed-off-by: Ruchika Gupta <[email protected]>
Reviewed-by: Jerome Forissier <[email protected]>
Reviewed-by: Jens Wiklander <[email protected]>
  • Loading branch information
ruchi393 authored and jforissier committed Dec 22, 2021
1 parent 3991ef1 commit af432c4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/libutils/ext/include/asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
* Copyright (c) 2020, Linaro Limited
*/

#if defined(__aarch64__) && ((defined(__KERNEL__) && defined(CFG_CORE_BTI)) || \
(!defined(__KERNEL__) && defined(CFG_TA_BTI)))
#define BTI(...) __VA_ARGS__
#else
#define BTI(...)
#endif

#if defined(CFG_UNWIND) && defined(__arm__)
#define UNWIND(...) __VA_ARGS__
#else
Expand All @@ -21,6 +28,7 @@
.balign \align
\name \colon
UNWIND( .fnstart)
BTI( bti c)
.endm

.macro LOCAL_FUNC name colon section=default align=4
Expand All @@ -33,6 +41,7 @@ UNWIND( .fnstart)
.balign \align
\name \colon
UNWIND( .fnstart)
BTI( bti c)
.endm

.macro WEAK_FUNC name colon section=default align=4
Expand All @@ -46,6 +55,7 @@ UNWIND( .fnstart)
.balign \align
\name \colon
UNWIND( .fnstart)
BTI( bti c)
.endm

.macro END_FUNC name
Expand Down

0 comments on commit af432c4

Please sign in to comment.