2

From Robert Love's book, (in system call implementation)

Somehow, user-space must relay the parameters to the kernel during the trap. The easiest way to do this is via the same means that the syscall number is passed: The parameters are stored in registers. On x86-32,the registers ebx, ecx, edx, esi, and edi contain, inorder, the first five arguments.In the unlikely case of six or more argu- ments, a single register is used to hold a pointer to user-space where all the parameters are stored.

But asymlinkage is prefixed for each and every system call which will expect the parameters to be in system stack. And also when the mode-switch happens how the parameters are copied into kernel stack ?

viji
  • 2,706
  • 5
  • 28
  • 34

1 Answers1

3

The parameters are placed onto the stack by the system call glue logic. All system calls are made through a single interrupt trap (int 0x80 on x86, I believe). The kernel code for this interrupt handler does the necessary work to put the parameters onto the stack for the system call handlers.

Check out this FAQ to answer the very question: http://kernelnewbies.org/FAQ/asmlinkage

chmeee
  • 3,608
  • 1
  • 21
  • 28
  • "system call glue logic" -> tatz exactly my question. Can you point me the code in the kernel that does this logic ? – viji Jul 20 '12 at 13:46
  • That can be found in http://fxr.watson.org/fxr/source/arch/x86/kernel/entry_32.S?v=linux-2.6 – chmeee Jul 20 '12 at 13:54
  • Note that on x86-32 you have two valid system call ways: `int 0x80` and `sysenter`. On x86-64 there may be up to four ways: `int 0x80`, `sysenter`, `syscall32` and `syscall`. – Ilya Matveychikov Jul 24 '12 at 04:06