mmap on x64
map or unmap files or devices into memory
sys_mmap(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long off)
| number | 9 (0x9) |
|---|---|
| abi | common |
| entry point | sys_mmap |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | mmap(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 9, the syscall number |
rdi | unsigned long addr |
rsi | unsigned long len |
rdx | unsigned long prot |
r10 | unsigned long flags |
r8 | unsigned long fd |
r9 | unsigned long off |
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 90
- arm64 222
- riscv64 222
- ia32 90
- x32 1073741833
- loongarch64 222
- ppc64 90
- ppc 90
- s390x 90
- mips64 5009
- mipsn32 6009
- mipso32 4090
- alpha 71
- cris 90, removed in 4.17
- ia64 1151, removed in 6.7
- m68k 90
- microblaze 90
- mn10300 90, removed in 4.17
- parisc 90
- score 1058, removed in 4.17
- sh 90
- sparc 71
- sparc64 71
- tilegx 222, removed in 4.17
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/mmap