futex on x64
fast user-space locking
sys_futex(u32 *uaddr, int op, u32 val, const struct __kernel_timespec *utime, u32 *uaddr2, u32 val3)
| number | 202 (0xca) |
|---|---|
| abi | common |
| entry point | sys_futex |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | futex(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 202, the syscall number |
rdi | u32 *uaddr |
rsi | int op |
rdx | u32 val |
r10 | const struct __kernel_timespec *utime |
r8 | u32 *uaddr2 |
r9 | u32 val3 |
rax | the return value |
Then run syscall to enter the kernel.
The syscall instruction clobbers rcx (the return address lands in rcx) and r11 (the flags land in r11).
Since Linux 5.14 the kernel reads the syscall number from eax and ignores the upper 32 bits of rax. Older kernels fail with ENOSYS when those bits are not zero, and mov eax, N clears them, so it works on both.
Same syscall on other architectures
- x86 240
- arm64 98
- arm 240
- riscv64 98
- ia32 240
- x32 1073742026
- loongarch64 98
- ppc64 221
- ppc 221
- s390x 238
- mips64 5194
- mipsn32 6194
- mipso32 4238
- alpha 394
- arc 98
- blackfin 240, removed in 4.17
- cris 240, removed in 4.17
- csky 98
- frv 240, removed in 4.17
- hexagon 98
- ia64 1230, removed in 6.7
- m32r 240, removed in 4.17
- m68k 235
- metag 98, removed in 4.17
- microblaze 240
- mn10300 240, removed in 4.17
- nds32 98, removed in 5.18
- nios2 98
- openrisc 98
- parisc 210
- score 98, removed in 4.17
- sh 240
- sparc 142
- sparc64 142
- tilegx 98, removed in 4.17
- tilepro 98, removed in 4.17
- xtensa 191
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/futex