back

Adding system call to the Linux kernel

created: 16/6/2022

the following tutorial is broken:
https://medium.com/anubhav-shrimal/adding-a-hello-world-system-call-to-linux-kernel-dad32875872

using desktop Ubuntu 22.04 minimal installation.

kernel version that matches Ubuntu 22.04:
https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/linux-5.15.39.tar.xz

missing apt packages:
make

gcc-multilib
g++-multilib
	- multilib needed for building 32 bit parts

dwarves
	- pahole is not available error


https://stackoverflow.com/questions/70223135/error-while-implementing-hello-world-system-call-in-lunix
need to use
SYSCALL_DEFINE0
instead of
asmlinkage long sys_hello
	- doesn't work out of the box (something to do with CONFIG_ARCH_HAS_SYSCALL_WRAPPER).
	can hardcode __x64_sys_hello instead.


need to execute in the kernel root dir:
scripts/config --disable SYSTEM_TRUSTED_KEYS
scripts/config --disable SYSTEM_REVOCATION_KEYS
	- https://askubuntu.com/questions/1329538/compiling-the-kernel-5-11-11