Power Architecture 64-bit Linux system call ABI¶
syscall¶
Invocation¶
The syscall is made with the sc instruction, and returns with executioncontinuing at the instruction following the sc instruction.
If PPC_FEATURE2_SCV appears in the AT_HWCAP2 ELF auxiliary vector, thescv 0 instruction is an alternative that may provide better performance,with some differences to calling sequence.
syscall calling sequence[1] matches the Power Architecture 64-bit ELF ABIspecification C function calling sequence, including register preservationrules, with the following differences.
| [1] | Some syscalls (typically low-level management functions) may havedifferent calling sequences (e.g., rt_sigreturn). |
Parameters¶
The system call number is specified in r0.
There is a maximum of 6 integer parameters to a syscall, passed in r3-r8.
Return value¶
- For the sc instruction, both a value and an error condition are returned.cr0.SO is the error condition, and r3 is the return value. When cr0.SO isclear, the syscall succeeded and r3 is the return value. When cr0.SO is set,the syscall failed and r3 is the error value (that normally corresponds toerrno).
- For the scv 0 instruction, the return value indicates failure if it is-4095..-1 (i.e., it is >= -MAX_ERRNO (-4095) as an unsigned comparison),in which case the error value is the negated return value.
Stack¶
System calls do not modify the caller’s stack frame. For example, the caller’sstack frame LR and CR save fields are not used.
Register preservation rules¶
Register preservation rules match the ELF ABI calling sequence with thefollowing differences:
— For the sc instruction, differences with the ELF ABI —=========== ============= ========================================r0 Volatile (System call number.)r3 Volatile (Parameter 1, and return value.)r4-r8 Volatile (Parameters 2-6.)cr0 Volatile (cr0.SO is the return error condition.)cr1, cr5-7 Nonvolatilelr Nonvolatile=========== ============= ========================================
— For the scv 0 instruction, differences with the ELF ABI —=========== ============= ========================================r0 Volatile (System call number.)r3 Volatile (Parameter 1, and return value.)r4-r8 Volatile (Parameters 2-6.)=========== ============= ========================================
All floating point and vector data registers as well as control and statusregisters are nonvolatile.
Transactional Memory¶
Syscall behavior can change if the processor is in transactional or suspendedtransaction state, and the syscall can affect the behavior of the transaction.
If the processor is in suspended state when a syscall is made, the syscallwill be performed as normal, and will return as normal. The syscall will beperformed in suspended state, so its side effects will be persistent accordingto the usual transactional memory semantics. A syscall may or may not resultin the transaction being doomed by hardware.
If the processor is in transactional state when a syscall is made, then thebehavior depends on the presence of PPC_FEATURE2_HTM_NOSC in the AT_HWCAP2 ELFauxiliary vector.
- If present, which is the case for newer kernels, then the syscall will notbe performed and the transaction will be doomed by the kernel with thefailure code TM_CAUSE_SYSCALL | TM_CAUSE_PERSISTENT in the TEXASR SPR.
- If not present (older kernels), then the kernel will suspend thetransactional state and the syscall will proceed as in the case of asuspended state syscall, and will resume the transactional state beforereturning to the caller. This case is not well defined or supported, so thisbehavior should not be relied upon.
scv 0 syscalls will always behave as PPC_FEATURE2_HTM_NOSC.
vsyscall¶
vsyscall calling sequence matches the syscall calling sequence, with thefollowing differences. Some vsyscalls may have different calling sequences.
Parameters and return value¶
r0 is not used as an input. The vsyscall is selected by its address.
Stack¶
The vsyscall may or may not use the caller’s stack frame save areas.
Register preservation rules¶
| r0 | Volatile |
| cr1, cr5-7 | Volatile |
| lr | Volatile |
Invocation¶
The vsyscall is performed with a branch-with-link instruction to the vsyscallfunction address.
Transactional Memory¶
vsyscalls will run in the same transactional state as the caller. A vsyscallmay or may not result in the transaction being doomed by hardware.