Search code examples
linuxsystem-callsvariadic-functionsioctl

What are hardware "gates" in the context of the linux kernel?


In user space, the ioctl system call has the following prototype:

int ioctl(int fd, unsigned long cmd, ...);

The prototype stands out in the list of Unix system calls because of the dots, which usually mark the function as having a variable number ofarguments. In a real system, however, a system call cannot actually have a variable number of arguments. System calls must have a well-defined prototype, because user programs can access them only through hardware "gates".

So what are these hardware gates? The page numbers are 135 and 136.


Solution

  • Hardware "gates" are specific instructions that allow switching to the kernel's context, usually to let a program request something from the kernel. This might be an instruction like syscall, sysenter, or int 0x80, depending on your system.

    I should note that these aren't usually called "hardware gates" in practice, but rather something like "system calls instructions."