2 ms·
"System calls in Linux are done through int 0x80. (actually there's a kernel patch allowing system calls to be done via the syscall (sysenter) instruction on ne
by praptak 16y ago
"System calls in Linux are done through int 0x80. (actually there's a kernel patch allowing system calls to be done via the syscall (sysenter) instruction on newer CPUs, but this thing is still experimental)."
This is no longer the case. While int 0x80 still works, this is not how well behaved binaries should syscall on Linux.
The proper way is to call a magic address on a magic page in own process space, which contains the proper code to do the system call. It will execute int 0x80 on CPUs that don't support sysenter/sysexit and sysenter on those that do.
The page (vdso) is inserted in all processes' address space by the kernel. Although its address is probably fixed, the proper way to find it is to examine the ELF auxilliary vector, which in turn is passed by the kernel via the initial process stack.
- xtacy 16y agoIntel archs have support for call gates that allow jumps to privileged code (ring 0/1/2). It maps nicely to the notion of syscalls, but I wonder why it hasn't been used.
- praptak 16y agoNot sure about the times before the sysenter mechanism (maybe int 0x80 was more portable?), but now that sysenter is in place it is faster than call gates, because most of its behaviour is hardcoded in the CPU itself.