Skip to content

Commit f5ec705

Browse files
tom-cosgrove-armpaulidale
authored andcommitted
aarch64: Fix async_fibre_swapcontext() on clang BTI builds
Reverting to using swapcontext() when compiling with clang on BTI-enabled builds fixes the BTI setjmp() failure seen when running asynctest. The issue with setjmp/longjmp is a known clang bug: see llvm/llvm-project#48888 Change-Id: I6eeaaa2e15f402789f1b3e742038f84bef846e29 Reviewed-by: Matt Caswell <[email protected]> Reviewed-by: Paul Dale <[email protected]> (Merged from #17698) (cherry picked from commit d2d2401)
1 parent f609d94 commit f5ec705

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

crypto/async/arch/async_posix.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@
3636
*/
3737
# define USE_SWAPCONTEXT
3838
# endif
39+
# if defined(__aarch64__) && defined(__clang__) \
40+
&& defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT == 1
41+
/*
42+
* setjmp/longjmp don't currently work with BTI on all libc implementations
43+
* when compiled by clang. This is because clang doesn't put a BTI after the
44+
* call to setjmp where it returns the second time. This then fails on libc
45+
* implementations - notably glibc - which use an indirect jump to there.
46+
* So use the swapcontext implementation, which does work.
47+
* See https://github.com/llvm/llvm-project/issues/48888.
48+
*/
49+
# define USE_SWAPCONTEXT
50+
# endif
3951
# include <ucontext.h>
4052
# ifndef USE_SWAPCONTEXT
4153
# include <setjmp.h>

0 commit comments

Comments
 (0)