Commit Graph

10 Commits (7599fe5ff2fcba4a8f1bc745e74c8c732beb5102)

Author SHA1 Message Date
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
William Pitcock 7b1a302ed4 README: we support s390x now 2018-02-15 05:55:26 +00:00
William Pitcock 79415db5a8 README: update for 0.1.0 2018-02-14 03:06:01 +00:00
William Pitcock 71979e9cf6 arch: ppc64: now working 2018-02-06 08:05:53 +00:00
William Pitcock 8ff8bb3280 README: note that ppc implementation uses kernel assistance 2018-02-02 18:51:55 +00:00
William Pitcock f3fe8ea781 arch: ppc: new port 2018-02-02 18:46:21 +00:00
William Pitcock 66919bb222 README: x86 now supported 2018-02-01 01:28:19 +00:00
William Pitcock 13283f5eba arch: add aarch64 port 2018-01-31 21:23:18 +00:00
William Pitcock e43fc2698a README: we support ARM 2018-01-31 04:13:42 +00:00
William Pitcock 0e437d3fc7 add README 2018-01-30 03:56:01 +00:00