semget on x64
get a System V semaphore set identifier
sys_semget(key_t key, int nsems, int semflg)
| number | 64 (0x40) |
|---|---|
| abi | common |
| kconfig | CONFIG_SYSVIPC |
| family | sysvipc see the whole family on x64 |
| entry point | sys_semget |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | semget(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 64, the syscall number |
rdi | key_t key |
rsi | int nsems |
rdx | int semflg |
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 393
- arm64 190
- arm 299
- riscv64 190
- ia32 393
- x32 1073741888
- loongarch64 190
- ppc64 393
- ppc 393
- s390x 393
- mips64 5062
- mipsn32 6062
- mipso32 4393
- alpha 205
- arc 190
- blackfin 332, removed in 4.17
- csky 190
- hexagon 190
- ia64 1106, removed in 6.7
- m68k 393
- metag 190, removed in 4.17
- microblaze 329
- nds32 190, removed in 5.18
- nios2 190
- openrisc 190
- parisc 186
- score 190, removed in 4.17
- sh 393
- sparc 393
- sparc64 393
- tilegx 190, removed in 4.17
- tilepro 190, removed in 4.17
- xtensa 162
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/semget