munmap on x64
map or unmap files or devices into memory
sys_munmap(unsigned long addr, size_t len)
| number | 11 (0xb) |
|---|---|
| abi | common |
| entry point | sys_munmap |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | munmap(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 11, the syscall number |
rdi | unsigned long addr |
rsi | size_t len |
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 91
- arm64 215
- arm 91
- riscv64 215
- ia32 91
- x32 1073741835
- loongarch64 215
- ppc64 91
- ppc 91
- s390x 91
- mips64 5011
- mipsn32 6011
- mipso32 4091
- alpha 73
- arc 215
- blackfin 91, removed in 4.17
- cris 91, removed in 4.17
- csky 215
- frv 91, removed in 4.17
- hexagon 215
- ia64 1152, removed in 6.7
- m32r 91, removed in 4.17
- m68k 91
- metag 215, removed in 4.17
- microblaze 91
- mn10300 91, removed in 4.17
- nds32 215, removed in 5.18
- nios2 215
- openrisc 215
- parisc 91
- score 215, removed in 4.17
- sh 91
- sparc 73
- sparc64 73
- tilegx 215, removed in 4.17
- tilepro 215, removed in 4.17
- xtensa 81
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/munmap