Documentation/arch/powerpc/syscall64-abi.rst

Source file repositories/reference/linux-study-clean/Documentation/arch/powerpc/syscall64-abi.rst

File Facts

System
Linux kernel
Corpus path
Documentation/arch/powerpc/syscall64-abi.rst
Extension
.rst
Size
6600 bytes
Lines
154
Domain
Support Tooling And Documentation
Bucket
Documentation
Inferred role
Support Tooling And Documentation: syscall or user/kernel boundary
Status
core implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

===============================================
Power Architecture 64-bit Linux system call ABI
===============================================

syscall
=======

Invocation
----------
The syscall is made with the sc instruction, and returns with execution
continuing at the instruction following the sc instruction.

If PPC_FEATURE2_SCV appears in the AT_HWCAP2 ELF auxiliary vector, the
scv 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 ABI
specification C function calling sequence, including register preservation
rules, with the following differences.

.. [1] Some syscalls (typically low-level management functions) may have
       different 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 is
  clear, 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 to
  errno).

- 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's
stack frame LR and CR save fields are not used.

Register preservation rules
---------------------------
Register preservation rules match the ELF ABI calling sequence with some
differences.

For the sc instruction, the differences from the ELF ABI are as follows:

+--------------+--------------------+-----------------------------------------+
| Register     | Preservation Rules | Purpose                                 |
+==============+====================+=========================================+
| 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   | Nonvolatile        |                                         |
+--------------+--------------------+-----------------------------------------+
| lr           | Nonvolatile        |                                         |
+--------------+--------------------+-----------------------------------------+

For the scv 0 instruction, the differences from the ELF ABI are as follows:

Annotation

Implementation Notes