kexec_file_load on x64

load a new kernel for later execution

sys_kexec_file_load(int kernel_fd, int initrd_fd, unsigned long cmdline_len, const char *cmdline_ptr, unsigned long flags)
number320 (0x140)
abicommon
kconfigCONFIG_KEXEC_FILE
entry pointsys_kexec_file_load
sinceLinux 3.17
man pagekexec_file_load(2)
sourceelixir.bootlin.com

Registers

registervalue
rax320, the syscall number
rdiint kernel_fd
rsiint initrd_fd
rdxunsigned long cmdline_len
r10const char *cmdline_ptr
r8unsigned long flags
raxthe 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

Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/kexec_file_load