Back to home page

OSCL-LXR

 
 

    


0001 ===============================================
0002 Power Architecture 64-bit Linux system call ABI
0003 ===============================================
0004 
0005 syscall
0006 =======
0007 
0008 Invocation
0009 ----------
0010 The syscall is made with the sc instruction, and returns with execution
0011 continuing at the instruction following the sc instruction.
0012 
0013 If PPC_FEATURE2_SCV appears in the AT_HWCAP2 ELF auxiliary vector, the
0014 scv 0 instruction is an alternative that may provide better performance,
0015 with some differences to calling sequence.
0016 
0017 syscall calling sequence\ [1]_ matches the Power Architecture 64-bit ELF ABI
0018 specification C function calling sequence, including register preservation
0019 rules, with the following differences.
0020 
0021 .. [1] Some syscalls (typically low-level management functions) may have
0022        different calling sequences (e.g., rt_sigreturn).
0023 
0024 Parameters
0025 ----------
0026 The system call number is specified in r0.
0027 
0028 There is a maximum of 6 integer parameters to a syscall, passed in r3-r8.
0029 
0030 Return value
0031 ------------
0032 - For the sc instruction, both a value and an error condition are returned.
0033   cr0.SO is the error condition, and r3 is the return value. When cr0.SO is
0034   clear, the syscall succeeded and r3 is the return value. When cr0.SO is set,
0035   the syscall failed and r3 is the error value (that normally corresponds to
0036   errno).
0037 
0038 - For the scv 0 instruction, the return value indicates failure if it is
0039   -4095..-1 (i.e., it is >= -MAX_ERRNO (-4095) as an unsigned comparison),
0040   in which case the error value is the negated return value.
0041 
0042 Stack
0043 -----
0044 System calls do not modify the caller's stack frame. For example, the caller's
0045 stack frame LR and CR save fields are not used.
0046 
0047 Register preservation rules
0048 ---------------------------
0049 Register preservation rules match the ELF ABI calling sequence with some
0050 differences.
0051 
0052 For the sc instruction, the differences from the ELF ABI are as follows:
0053 
0054 +--------------+--------------------+-----------------------------------------+
0055 | Register     | Preservation Rules | Purpose                                 |
0056 +==============+====================+=========================================+
0057 | r0           | Volatile           | (System call number.)                   |
0058 +--------------+--------------------+-----------------------------------------+
0059 | r3           | Volatile           | (Parameter 1, and return value.)        |
0060 +--------------+--------------------+-----------------------------------------+
0061 | r4-r8        | Volatile           | (Parameters 2-6.)                       |
0062 +--------------+--------------------+-----------------------------------------+
0063 | cr0          | Volatile           | (cr0.SO is the return error condition.) |
0064 +--------------+--------------------+-----------------------------------------+
0065 | cr1, cr5-7   | Nonvolatile        |                                         |
0066 +--------------+--------------------+-----------------------------------------+
0067 | lr           | Nonvolatile        |                                         |
0068 +--------------+--------------------+-----------------------------------------+
0069 
0070 For the scv 0 instruction, the differences from the ELF ABI are as follows:
0071 
0072 +--------------+--------------------+-----------------------------------------+
0073 | Register     | Preservation Rules | Purpose                                 |
0074 +==============+====================+=========================================+
0075 | r0           | Volatile           | (System call number.)                   |
0076 +--------------+--------------------+-----------------------------------------+
0077 | r3           | Volatile           | (Parameter 1, and return value.)        |
0078 +--------------+--------------------+-----------------------------------------+
0079 | r4-r8        | Volatile           | (Parameters 2-6.)                       |
0080 +--------------+--------------------+-----------------------------------------+
0081 
0082 All floating point and vector data registers as well as control and status
0083 registers are nonvolatile.
0084 
0085 Transactional Memory
0086 --------------------
0087 Syscall behavior can change if the processor is in transactional or suspended
0088 transaction state, and the syscall can affect the behavior of the transaction.
0089 
0090 If the processor is in suspended state when a syscall is made, the syscall
0091 will be performed as normal, and will return as normal. The syscall will be
0092 performed in suspended state, so its side effects will be persistent according
0093 to the usual transactional memory semantics. A syscall may or may not result
0094 in the transaction being doomed by hardware.
0095 
0096 If the processor is in transactional state when a syscall is made, then the
0097 behavior depends on the presence of PPC_FEATURE2_HTM_NOSC in the AT_HWCAP2 ELF
0098 auxiliary vector.
0099 
0100 - If present, which is the case for newer kernels, then the syscall will not
0101   be performed and the transaction will be doomed by the kernel with the
0102   failure code TM_CAUSE_SYSCALL | TM_CAUSE_PERSISTENT in the TEXASR SPR.
0103 
0104 - If not present (older kernels), then the kernel will suspend the
0105   transactional state and the syscall will proceed as in the case of a
0106   suspended state syscall, and will resume the transactional state before
0107   returning to the caller. This case is not well defined or supported, so this
0108   behavior should not be relied upon.
0109 
0110 scv 0 syscalls will always behave as PPC_FEATURE2_HTM_NOSC.
0111 
0112 ptrace
0113 ------
0114 When ptracing system calls (PTRACE_SYSCALL), the pt_regs.trap value contains
0115 the system call type that can be used to distinguish between sc and scv 0
0116 system calls, and the different register conventions can be accounted for.
0117 
0118 If the value of (pt_regs.trap & 0xfff0) is 0xc00 then the system call was
0119 performed with the sc instruction, if it is 0x3000 then the system call was
0120 performed with the scv 0 instruction.
0121 
0122 vsyscall
0123 ========
0124 
0125 vsyscall calling sequence matches the syscall calling sequence, with the
0126 following differences. Some vsyscalls may have different calling sequences.
0127 
0128 Parameters and return value
0129 ---------------------------
0130 r0 is not used as an input. The vsyscall is selected by its address.
0131 
0132 Stack
0133 -----
0134 The vsyscall may or may not use the caller's stack frame save areas.
0135 
0136 Register preservation rules
0137 ---------------------------
0138 
0139 =========== ========
0140 r0          Volatile
0141 cr1, cr5-7  Volatile
0142 lr          Volatile
0143 =========== ========
0144 
0145 Invocation
0146 ----------
0147 The vsyscall is performed with a branch-with-link instruction to the vsyscall
0148 function address.
0149 
0150 Transactional Memory
0151 --------------------
0152 vsyscalls will run in the same transactional state as the caller. A vsyscall
0153 may or may not result in the transaction being doomed by hardware.