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 ?

2

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

3 Comments

"system call glue logic" -> tatz exactly my question. Can you point me the code in the kernel that does this logic ?
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.