Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) ===============================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) Power Architecture 64-bit Linux system call ABI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) ===============================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) syscall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) =======
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) Invocation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) ----------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) The syscall is made with the sc instruction, and returns with execution
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) continuing at the instruction following the sc instruction.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) If PPC_FEATURE2_SCV appears in the AT_HWCAP2 ELF auxiliary vector, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) scv 0 instruction is an alternative that may provide better performance,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) with some differences to calling sequence.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) syscall calling sequence\ [1]_ matches the Power Architecture 64-bit ELF ABI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) specification C function calling sequence, including register preservation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) rules, with the following differences.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) .. [1] Some syscalls (typically low-level management functions) may have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)        different calling sequences (e.g., rt_sigreturn).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) Parameters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) ----------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) The system call number is specified in r0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) There is a maximum of 6 integer parameters to a syscall, passed in r3-r8.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) Return value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) ------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) - For the sc instruction, both a value and an error condition are returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)   cr0.SO is the error condition, and r3 is the return value. When cr0.SO is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)   clear, the syscall succeeded and r3 is the return value. When cr0.SO is set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)   the syscall failed and r3 is the error value (that normally corresponds to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)   errno).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) - For the scv 0 instruction, the return value indicates failure if it is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)   -4095..-1 (i.e., it is >= -MAX_ERRNO (-4095) as an unsigned comparison),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)   in which case the error value is the negated return value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) Stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) -----
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) System calls do not modify the caller's stack frame. For example, the caller's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) stack frame LR and CR save fields are not used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) Register preservation rules
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) ---------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) Register preservation rules match the ELF ABI calling sequence with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) following differences:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) +------------------------------------------------------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) |        For the sc instruction, differences with the ELF ABI		 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) +--------------+--------------+------------------------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) | r0           | Volatile     | (System call number.)			 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) | rr3          | Volatile     | (Parameter 1, and return value.)	 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) | rr4-r8       | Volatile     | (Parameters 2-6.)			 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) | rcr0         | Volatile     | (cr0.SO is the return error condition.)	 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) | rcr1, cr5-7  | Nonvolatile  |						 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) | rlr          | Nonvolatile  |						 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) +--------------+--------------+------------------------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) |      For the scv 0 instruction, differences with the ELF ABI		 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) +--------------+--------------+------------------------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) | r0           | Volatile     | (System call number.)			 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) | r3           | Volatile     | (Parameter 1, and return value.)	 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) | r4-r8        | Volatile     | (Parameters 2-6.)			 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) +--------------+--------------+------------------------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) All floating point and vector data registers as well as control and status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) registers are nonvolatile.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) Transactional Memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) --------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) Syscall behavior can change if the processor is in transactional or suspended
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) transaction state, and the syscall can affect the behavior of the transaction.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) If the processor is in suspended state when a syscall is made, the syscall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) will be performed as normal, and will return as normal. The syscall will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) performed in suspended state, so its side effects will be persistent according
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) to the usual transactional memory semantics. A syscall may or may not result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) in the transaction being doomed by hardware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) If the processor is in transactional state when a syscall is made, then the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) behavior depends on the presence of PPC_FEATURE2_HTM_NOSC in the AT_HWCAP2 ELF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) auxiliary vector.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) - If present, which is the case for newer kernels, then the syscall will not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)   be performed and the transaction will be doomed by the kernel with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)   failure code TM_CAUSE_SYSCALL | TM_CAUSE_PERSISTENT in the TEXASR SPR.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) - If not present (older kernels), then the kernel will suspend the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)   transactional state and the syscall will proceed as in the case of a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)   suspended state syscall, and will resume the transactional state before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)   returning to the caller. This case is not well defined or supported, so this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)   behavior should not be relied upon.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) scv 0 syscalls will always behave as PPC_FEATURE2_HTM_NOSC.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) ptrace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) ------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) When ptracing system calls (PTRACE_SYSCALL), the pt_regs.trap value contains
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) the system call type that can be used to distinguish between sc and scv 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) system calls, and the different register conventions can be accounted for.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) If the value of (pt_regs.trap & 0xfff0) is 0xc00 then the system call was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) performed with the sc instruction, if it is 0x3000 then the system call was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) performed with the scv 0 instruction.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) vsyscall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) ========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) vsyscall calling sequence matches the syscall calling sequence, with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) following differences. Some vsyscalls may have different calling sequences.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) Parameters and return value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) ---------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) r0 is not used as an input. The vsyscall is selected by its address.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) Stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) -----
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) The vsyscall may or may not use the caller's stack frame save areas.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) Register preservation rules
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) ---------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) =========== ========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) r0          Volatile
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) cr1, cr5-7  Volatile
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) lr          Volatile
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) =========== ========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) Invocation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) ----------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) The vsyscall is performed with a branch-with-link instruction to the vsyscall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) function address.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) Transactional Memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) --------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) vsyscalls will run in the same transactional state as the caller. A vsyscall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) may or may not result in the transaction being doomed by hardware.