Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 13: System Calls


Calling the code stored there (withcall 0xffffe000) allows the standard library to automati-
cally select the method that matches the processor used.
❑ Alpha processors provide a privileged system mode (PAL,privileged architecture level)inwhich
various system kernel routines can be stored. The kernel employs this mechanism by including
in the PAL code a function that must be activated in order to execute system calls.call_pal
PAL_callsystransfers control flow to the desired routine.v0is used to pass the system call
number, and the five possible arguments are held ina0toa4(note that register naming is more
systematic in recent architectures than in earlier architectures such as IA-32...).
❑ PowerPC processors feature an elegant assembly language instruction calledsc(system call).
This is used specifically to implement system calls. Registerr3holds the system call number,
while parameters are held in registersr4tor8inclusive.
❑ The AMD64 architecture also has its own assembly language instruction with the revealing name
ofsyscallto implement system calls. The system call number is held in therawregister, param-
eters inrdi,rsi,rdx,r10,r8,andr9.

Once the application program has switched to kernel mode with the help of the standard library, the
kernel is faced with the task of finding the matching handler function for the system call and supplying
it with the passed parameters. A table namedsys_call_table, which holds a set of function pointers
to handler routines, is available for this purpose on all (!) platforms. Because the table is generated with
assembly language instructions in the data segment of the kernel, its contents differ from platform to
platform. The principle, however, is always the same: by reference to the system call number, the kernel
finds the appropriate position in the table at which a pointer points to the desired handler function.

System Call Table


Let us take a look at thesys_call_tableof an Sparc64 system as defined inarch/sparc/kernel/
systlbs.S(System call tables for other systems can be found in a file often calledentry.Sin the cor-
responding directory for the processor type.)

arch/sparc64/kernel/systbls.S
sys_call_table64:
sys_call_table:
/0/ .word sys_restart_syscall, sparc_exit, sys_fork, sys_read, sys_write
/5/ .word sys_open, sys_close, sys_wait4, sys_creat, sys_link
/10/ .word sys_unlink, sys_nis_syscall, sys_chdir, sys_chown, sys_mknod
/15/ .word sys_chmod, sys_lchown, sparc_brk, sys_perfctr, sys_lseek
/20/ .word sys_getpid, sys_capget, sys_capset, sys_setuid, sys_getuid
/25/ .word sys_vmsplice, sys_ptrace, sys_alarm, sys_sigaltstack, sys_nis_syscall
/30/ .word sys_utime, sys_nis_syscall, sys_nis_syscall, sys_access, sys_nice
.word sys_nis_syscall, sys_sync, sys_kill, sys_newstat, sys_sendfile64
/40/ .word sys_newlstat, sys_dup, sys_pipe, sys_times, sys_nis_syscall
.word sys_umount, sys_setgid, sys_getgid, sys_signal, sys_geteuid
/50/ .word sys_getegid, sys_acct, sys_memory_ordering, sys_nis_syscall, sys_ioctl
.word sys_reboot, sys_nis_syscall, sys_symlink, sys_readlink, sys_execve
/60/ .word sys_umask, sys_chroot, sys_newfstat, sys_fstat64, sys_getpagesize


...
/280/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
.word sys_mkdirat, sys_mknodat, sys_fchownat, sys_futimesat, sys_fstatat64
/290/ .word sys_unlinkat, sys_renameat, sys_linkat, sys_symlinkat, sys_readlinkat
.word sys_fchmodat, sys_faccessat, sys_pselect6, sys_ppoll, sys_unshare

Free download pdf