about summary refs log tree commit diff
path: root/sysdeps/aarch64
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2020-04-01 10:31:41 +0100
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2020-07-08 15:02:37 +0100
commitfddbd7c0ef4960fc0a17712a95a146dd3f43de0a (patch)
tree51c6b9fad2ff3fc3da502de2a5bbcf014ff8ca57 /sysdeps/aarch64
parent91181954f94917b1e1ae591c60cbadf0321d35af (diff)
downloadglibc-fddbd7c0ef4960fc0a17712a95a146dd3f43de0a.tar.gz
glibc-fddbd7c0ef4960fc0a17712a95a146dd3f43de0a.tar.xz
glibc-fddbd7c0ef4960fc0a17712a95a146dd3f43de0a.zip
aarch64: fix swapcontext for BTI
setcontext returns to the specified context via an indirect jump,
so there should be a BTI j.

In case of getcontext (and all other returns_twice functions) the
compiler adds BTI j at the call site, but swapcontext is a normal
c call that is currently not handled specially by the compiler.

So we change swapcontext such that the saved context returns to a
local address that has BTI j and then swapcontext returns to the
caller via a normal RET. For this we save the original return
address in the slot for x1 of the context because x1 need not be
preserved by swapcontext but it is restored when the context saved
by swapcontext is resumed.

The alternative fix (which is done on x86) would make swapcontext
special in the compiler so BTI j is emitted at call sites, on
x86 there is an indirect_return attribute for this, on AArch64
we would have to use returns_twice. It was decided against because
such fix may need user code updates: the attribute has to be added
when swapcontext is called via a function pointer and it breaks
always_inline functions with swapcontext.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'sysdeps/aarch64')
0 files changed, 0 insertions, 0 deletions