如何将参数传递给Linux系统调用?通过寄存器还是堆栈?

I trying to understand the internals of the Linux kernel by reading Robert Love's Linux Kernel Development.

On page 74 he says the easiest way to pass arguments to a syscall is via :

在某种程度上,用户空间必须将参数中继到内核   陷阱。最简单的方法是通过syscall的相同方法   传递数字:参数存储在寄存器中。在x86-32上,   寄存器ebx,ecx,edx,esi和edi按顺序包含第一个   五个论点。

现在,这使我感到困扰,原因有很多:

  1. All syscalls are defined with the asmlinkage option. Which implies that the arguments are always to be found on the stack and not the register. So what is all this business with the registers ?
  2. It may be possible that before the syscall is performed the values are copied on to the kernel stack. I have no idea why that would be efficient but it might be a possibility.
评论