2
votes

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 ?

1

1 Answers

3
votes

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