[syscall]kernel v7.2 · arch/x86/entry/● stable

System Calls

Syscall table dispatch, entry_SYSCALL_64, VDSO, seccomp BPF, and the audit framework — the kernel/user boundary dissected.

Subsystem Overview

System calls are the fundamental interface between user-space programs and the kernel. On x86-64, a syscall is initiated with the SYSCALL instruction, which atomically switches to ring 0, loads the kernel stack pointer from the per-CPU TSS, and jumps to entry_SYSCALL_64 — the single entry point for all 64-bit system calls.

The entry path saves the full register state (pt_regs), validates the syscall number against NR_syscalls, runs seccomp BPF filters, and dispatches through the sys_call_table array of function pointers. On return, the path restores registers and executes SYSRET to return to user space at ring 3.

Linux 7.2 extended the seccomp subsystem with SECCOMP_RET_USER_NOTIF_ADDFD for file descriptor injection into supervised processes, and hardened the VDSO against Spectre-v2 by switching to IBPB-based mitigation on affected microarchitectures.

// x86-64 syscall ABI — argument registers

RAXsyscall nr / return
RDIarg 1
RSIarg 2
RDXarg 3
R10arg 4
R8arg 5

Diagrams

// interactive · click nodes to explore

SYSCALLuser space · ring 31MSR_LSTARentry_SYSCALL_64 addr2SWAPGS + RSPper-CPU kernel stack3PUSH pt_regssave all registers4do_syscall_64()C entry · seccomp · audit5sys_call_table[]dispatch by RAX index6syscall handlerksys_read / ksys_write …7SYSRETrestore RIP/RFLAGS · ring 38click any step to highlight

Syscall Entry Path

Step-by-step x86-64 path from SYSCALL instruction through entry_SYSCALL_64, do_syscall_64, and back via SYSRET.

RAXsyscall numberNRsys_call_table[NR]0sys_read1sys_write2sys_open9sys_mmap56sys_clone59sys_execve60sys_exit231sys_exit_groupclick a row to trace dispatch

sys_call_table Dispatch

How RAX indexes the sys_call_table array to dispatch to the correct kernel handler function.

yesnosyscall entrydo_syscall_64()seccomp filter?thread_info flagsrun BPF programseccomp_run_filters()ALLOWcontinue dispatchERRNOreturn -errno to userTRAPdeliver SIGSYSKILLSIGKILL / core dumpno filterdispatch directlyclick a node to highlight

Seccomp BPF Decision Tree

BPF filter evaluation flow: ALLOW, ERRNO, TRAP (SIGSYS), and KILL outcomes from seccomp_run_filters().

Key Concepts

SYSCALL / SYSRET

The fast syscall mechanism on x86-64. SYSCALL saves RIP into RCX and RFLAGS into R11, then jumps to the address in MSR_LSTAR (entry_SYSCALL_64). SYSRET restores RIP from RCX and RFLAGS from R11. This avoids the overhead of the legacy INT 0x80 / IRET path.

pt_regs

The register save area pushed onto the kernel stack at syscall entry. Contains all general-purpose registers, RIP, CS, RFLAGS, RSP, and SS. Syscall arguments are passed in RDI, RSI, RDX, R10, R8, R9 — note R10 instead of RCX (which is clobbered by SYSCALL).

sys_call_table

An array of function pointers indexed by syscall number, defined in arch/x86/entry/syscall_64.c. Each entry points to the kernel implementation (e.g. sys_read, sys_write). The table is read-only after boot and protected by CONFIG_STRICT_KERNEL_RWX.

seccomp BPF

Secure Computing mode 2. A BPF program attached to a thread that inspects each syscall's number and arguments before dispatch. Can return ALLOW, KILL_PROCESS, TRAP (SIGSYS), ERRNO, TRACE (ptrace), LOG, or USER_NOTIF. Used by container runtimes and sandboxes.

VDSO (Virtual Dynamic Shared Object)

A small shared library mapped into every process by the kernel. Implements frequently called syscalls (clock_gettime, gettimeofday, getcpu) entirely in user space by reading kernel-maintained data in the vvar page — avoiding the ring-transition overhead entirely.

Audit Framework

The kernel audit subsystem records syscall events (entry, exit, arguments, return value) into an in-kernel ring buffer consumed by auditd. Enabled per-thread via audit_context. Adds overhead only when rules match; the fast path is a single branch on audit_dummy_context.

Source References

// arch/x86/entry/ · kernel/ · annotated entry points

arch/x86/entry/entry_64.Sentry_SYSCALL_64: assembly entry point, register save/restore, SWAPGS, SYSRETelixir ↗
arch/x86/entry/common.cdo_syscall_64(): C-level dispatch, seccomp, audit hooks, syscall tracingelixir ↗
arch/x86/entry/syscall_64.csys_call_table[]: 64-bit syscall dispatch table, NR_syscalls boundary checkelixir ↗
kernel/seccomp.cseccomp_run_filters(): BPF filter evaluation, USER_NOTIF fd injection, TSYNCelixir ↗
arch/x86/entry/vdso/vdso.lds.SVDSO linker script: clock_gettime, gettimeofday, getcpu, time symbol exportselixir ↗
kernel/audit.caudit_syscall_entry/exit(): audit context lifecycle, ring buffer, netlink relayelixir ↗
include/linux/syscalls.hSYSCALL_DEFINE macros, __SYSCALL_DEFINEx expansion, compat syscall wrapperselixir ↗
include/uapi/asm/unistd_64.hx86-64 syscall number definitions: __NR_read, __NR_write, __NR_mmap, etc.elixir ↗

Linux 7.2 Changes

// recent arch/x86/entry/ · kernel/seccomp.c commits

seccomp: add SECCOMP_RET_USER_NOTIF_ADDFD for file descriptor injection into supervised processes
x86/entry: switch VDSO Spectre-v2 mitigation to IBPB on Zen 4 and Raptor Lake microarchitectures
audit: convert syscall audit ring buffer to per-CPU lockless structure, reducing contention

// related tutorial

Syscall Entry Path — full annotated walkthrough

7 steps from SYSCALL instruction to SYSRET, with ARM64 comparison table and knowledge checks.

Read tutorial →