pkey_alloc on x64
allocate or free a protection key
sys_pkey_alloc(unsigned long flags, unsigned long init_val)
| number | 330 (0x14a) |
|---|---|
| abi | common |
| kconfig | CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS |
| family | pkeys see the whole family on x64 |
| entry point | sys_pkey_alloc |
| since | Linux 4.9 |
| man page | pkey_alloc(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 330, the syscall number |
rdi | unsigned long flags |
rsi | unsigned long init_val |
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 381
- arm64 289
- arm 395
- riscv64 289
- ia32 381
- x32 1073742154
- loongarch64 289
- ppc64 384
- ppc 384
- s390x 385
- mips64 5324
- mipsn32 6328
- mipso32 4364
- alpha 525
- arc 289
- csky 289
- hexagon 289
- ia64 1355, removed in 6.7
- m68k 382
- metag 289, removed in 4.17
- microblaze 396
- nds32 289, removed in 5.18
- nios2 289
- openrisc 289
- parisc 352
- score 289, removed in 4.17
- sh 385
- sparc 363
- sparc64 363
- tilegx 289, removed in 4.17
- tilepro 289, removed in 4.17
- xtensa 349
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/pkey_alloc