Define a two-argument syscall with SYSCALL_DEFINE2
SYSCALL_DEFINE2() declares a system call with two arguments, builds its wrapper, and needs one line in the syscall table (Linux 6.12, x86-64).
A new system call is a C function, a table entry and a number. SYSCALL_DEFINE2() is the macro for a call with two arguments: it names the call, takes each argument as a type and a name, and generates the entry point the architecture needs, including the argument handling. This is for Linux 6.12 on x86-64.
/* kernel/demo.c */
#include <linux/syscalls.h>
SYSCALL_DEFINE2(demo_add, int, a, int, b)
{
return a + b;
}463 common demo_add sys_demo_addThe text line goes into arch/x86/entry/syscalls/syscall_64.tbl, using the next free number. On a 6.12 tree the last common call is mseal at 462, so the new entry is 463. The name in the table is sys_demo_add, which the macro creates from the first argument. Write the types and names in pairs separated by commas, and do not put a comma between a type and its name.
The macro does more than a plain function would: on x86-64 it generates a __x64_sys_demo_add wrapper that reads the arguments from the saved registers, and it makes the arguments sign-extend correctly. It also adds the call to the syscall metadata used by tracing. You must also add the prototype to include/linux/syscalls.h when the call is used elsewhere. See adding a new system call.