madvise on x64
give advice about use of memory
sys_madvise(unsigned long start, size_t len, int behavior)
| number | 28 (0x1c) |
|---|---|
| abi | common |
| kconfig | CONFIG_ADVISE_SYSCALLS |
| entry point | sys_madvise |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | madvise(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 28, the syscall number |
rdi | unsigned long start |
rsi | size_t len |
rdx | int behavior |
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 219
- arm64 233
- arm 220
- riscv64 233
- ia32 219
- x32 1073741852
- loongarch64 233
- ppc64 205
- ppc 205
- s390x 219
- mips64 5027
- mipsn32 6027
- mipso32 4218
- alpha 75
- arc 233
- cris 219, removed in 4.17
- csky 233
- frv 219, removed in 4.17
- hexagon 233
- ia64 1209, removed in 6.7
- m32r 219, removed in 4.17
- m68k 238
- metag 233, removed in 4.17
- microblaze 219
- mn10300 219, removed in 4.17
- nds32 233, removed in 5.18
- nios2 233
- openrisc 233
- parisc 119
- score 233, removed in 4.17
- sh 219
- sparc 75
- sparc64 75
- tilegx 233, removed in 4.17
- tilepro 233, removed in 4.17
- xtensa 91
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/madvise