libucontext/arch
Bobby Bingham 2610c7faa7 ppc32/64: rewrite get/set/swapcontext in assembly
getcontext cannot be correctly implemented in C.

If this calls another function, as it does to call syscall, it needs to
first spill its return address to the stack.  If, after getcontext returns,
its caller then calls other functions, this saved return address can be
clobbered.  When the context saved by getcontext is later restored, the
(now clobbered) return address will be reloaded from the stack, and the
second return from getcontext will return to the wrong location.

Because the powerpc swapcontext syscall allows either the old context or
new context pointers to be null, it is usable for implementing all of
get/set/swapcontext.

We therefore rewrite swapcontext in assembly, and get/setcontext as simple
assembly function wrappers around swapcontext.

The one piece we keep in C is the code to check the return value of the
system call and to set errno.  This code was actually unnecessary before --
libc does this within syscall.  However, now that the system call is made
directly in assembly, bypassing libc, it is truly necessary.  Because errno
is thread-local and the details of how to set it can vary by libc, this
code remains written in C.
2019-04-05 14:44:54 -05:00
..
aarch64 arch: add aarch64 port 2018-01-31 21:23:18 +00:00
arm arch: arm: add armv6+ port 2018-01-31 04:11:46 +00:00
ppc ppc32/64: rewrite get/set/swapcontext in assembly 2019-04-05 14:44:54 -05:00
ppc64 ppc32/64: rewrite get/set/swapcontext in assembly 2019-04-05 14:44:54 -05:00
s390x arch: add s390x port 2018-02-15 05:54:17 +00:00
x86 x86: trampoline: fix GOT clobbering, pointed out by fabled 2018-02-15 04:32:16 +00:00
x86_64 Reorder registers in other x86_64 assembler files 2018-07-19 17:18:19 -05:00