mlock on x64
lock and unlock memory
sys_mlock(unsigned long start, size_t len)
| number | 149 (0x95) |
|---|---|
| abi | common |
| entry point | sys_mlock |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | mlock(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 149, the syscall number |
rdi | unsigned long start |
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 150
- arm64 228
- arm 150
- riscv64 228
- ia32 150
- x32 1073741973
- loongarch64 228
- ppc64 150
- ppc 150
- s390x 150
- mips64 5146
- mipsn32 6146
- mipso32 4154
- alpha 314
- arc 228
- cris 150, removed in 4.17
- csky 228
- frv 150, removed in 4.17
- hexagon 228
- ia64 1153, removed in 6.7
- m32r 150, removed in 4.17
- m68k 150
- metag 228, removed in 4.17
- microblaze 150
- mn10300 150, removed in 4.17
- nds32 228, removed in 5.18
- nios2 228
- openrisc 228
- parisc 150
- score 228, removed in 4.17
- sh 150
- sparc 237
- sparc64 237
- tilegx 228, removed in 4.17
- tilepro 228, removed in 4.17
- xtensa 84
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/mlock