Skip to content

Commit

Permalink
aarch64: Fix async_fibre_swapcontext() on clang BTI builds
Browse files Browse the repository at this point in the history
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 <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from #17698)

(cherry picked from commit d2d2401)
  • Loading branch information
tom-cosgrove-arm authored and paulidale committed Feb 28, 2022
1 parent f609d94 commit f5ec705
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions crypto/async/arch/async_posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@
*/
# define USE_SWAPCONTEXT
# endif
# if defined(__aarch64__) && defined(__clang__) \
&& defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT == 1
/*
* setjmp/longjmp don't currently work with BTI on all libc implementations
* when compiled by clang. This is because clang doesn't put a BTI after the
* call to setjmp where it returns the second time. This then fails on libc
* implementations - notably glibc - which use an indirect jump to there.
* So use the swapcontext implementation, which does work.
* See https://github.com/llvm/llvm-project/issues/48888.
*/
# define USE_SWAPCONTEXT
# endif
# include <ucontext.h>
# ifndef USE_SWAPCONTEXT
# include <setjmp.h>
Expand Down

0 comments on commit f5ec705

Please sign in to comment.