syscall64-abi.txt 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. ===============================================
  2. Power Architecture 64-bit Linux system call ABI
  3. ===============================================
  4. syscall
  5. =======
  6. syscall calling sequence[*] matches the Power Architecture 64-bit ELF ABI
  7. specification C function calling sequence, including register preservation
  8. rules, with the following differences.
  9. [*] Some syscalls (typically low-level management functions) may have
  10. different calling sequences (e.g., rt_sigreturn).
  11. Parameters and return value
  12. ---------------------------
  13. The system call number is specified in r0.
  14. There is a maximum of 6 integer parameters to a syscall, passed in r3-r8.
  15. Both a return value and a return error code are returned. cr0.SO is the return
  16. error code, and r3 is the return value or error code. When cr0.SO is clear,
  17. the syscall succeeded and r3 is the return value. When cr0.SO is set, the
  18. syscall failed and r3 is the error code that generally corresponds to errno.
  19. Stack
  20. -----
  21. System calls do not modify the caller's stack frame. For example, the caller's
  22. stack frame LR and CR save fields are not used.
  23. Register preservation rules
  24. ---------------------------
  25. Register preservation rules match the ELF ABI calling sequence with the
  26. following differences:
  27. r0: Volatile. (System call number.)
  28. r3: Volatile. (Parameter 1, and return value.)
  29. r4-r8: Volatile. (Parameters 2-6.)
  30. cr0: Volatile (cr0.SO is the return error condition)
  31. cr1, cr5-7: Nonvolatile.
  32. lr: Nonvolatile.
  33. All floating point and vector data registers as well as control and status
  34. registers are nonvolatile.
  35. Invocation
  36. ----------
  37. The syscall is performed with the sc instruction, and returns with execution
  38. continuing at the instruction following the sc instruction.
  39. Transactional Memory
  40. --------------------
  41. Syscall behavior can change if the processor is in transactional or suspended
  42. transaction state, and the syscall can affect the behavior of the transaction.
  43. If the processor is in suspended state when a syscall is made, the syscall
  44. will be performed as normal, and will return as normal. The syscall will be
  45. performed in suspended state, so its side effects will be persistent according
  46. to the usual transactional memory semantics. A syscall may or may not result
  47. in the transaction being doomed by hardware.
  48. If the processor is in transactional state when a syscall is made, then the
  49. behavior depends on the presence of PPC_FEATURE2_HTM_NOSC in the AT_HWCAP2 ELF
  50. auxiliary vector.
  51. - If present, which is the case for newer kernels, then the syscall will not
  52. be performed and the transaction will be doomed by the kernel with the
  53. failure code TM_CAUSE_SYSCALL | TM_CAUSE_PERSISTENT in the TEXASR SPR.
  54. - If not present (older kernels), then the kernel will suspend the
  55. transactional state and the syscall will proceed as in the case of a
  56. suspended state syscall, and will resume the transactional state before
  57. returning to the caller. This case is not well defined or supported, so this
  58. behavior should not be relied upon.
  59. vsyscall
  60. ========
  61. vsyscall calling sequence matches the syscall calling sequence, with the
  62. following differences. Some vsyscalls may have different calling sequences.
  63. Parameters and return value
  64. ---------------------------
  65. r0 is not used as an input. The vsyscall is selected by its address.
  66. Stack
  67. -----
  68. The vsyscall may or may not use the caller's stack frame save areas.
  69. Register preservation rules
  70. ---------------------------
  71. r0: Volatile.
  72. cr1, cr5-7: Volatile.
  73. lr: Volatile.
  74. Invocation
  75. ----------
  76. The vsyscall is performed with a branch-with-link instruction to the vsyscall
  77. function address.
  78. Transactional Memory
  79. --------------------
  80. vsyscalls will run in the same transactional state as the caller. A vsyscall
  81. may or may not result in the transaction being doomed by hardware.