arm64: Redirect syscalls via the vDSO
In preparation for moving parts of the syscall interface to the
vDSO, add a new syscall handler __kernel_syscall to the vDSO, and
redirect to it all syscalls originating from outside the vDSO.
In future, dedicated functions can be added to the vDSO to be
called in place of bare syscalls. Direct call to vDSO functions
will avoid the redirection/return overheads.
All user registers are live at syscall entry, so return state is
saved on the user stack in a special-purpose frame:
: ////// : <-.
+--------+ `- old sp (possibly misaligned)
| pstate |
+--------+
| pc |
+--------+ ...
| old sp |
+--------+ <--- new sp + 8
| x8 |
+--------+ <--- new sp
A quirk of the A64 ISA means that there is no way at EL0 to return
back to the call-site while also restoring all the registers, so
add a flag __REDIRECTED_SYSCALL to the syscall number that requests
removal of the syscall frame and does the return in addition to
doing the requested syscall. This avoids an extra syscall in the
case that the vDSO emulation of a syscall uses syscalls itself:
just set this flag on the last syscall in the emulation.
For syscalls implemented entirely in the vDSO, a syscall is still
needed in order to return to the original call-site. Add a new
dummy syscall number __NR_arm64_nop for this purpose: the vDSO can
use this with __REDIRECTED_SYSCALL when calling back into the
kernel to do the only return, with no other effect.
Signed-off-by:
Dave Martin <Dave.Martin@arm.com>
Loading
Please register or sign in to comment