ablog

不器用で落着きのない技術者のメモ

システムコールの際のユーザ空間とカーネル空間のパラメータの受け渡しにはレジスタが使われる

Linux Kernel Development (Developer's Library)

Linux Kernel Development (Developer's Library)

P. 74

Parameter Passing
In addition to the systemcall number, most syscalls require that one or more parameters be passed to them. 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 in order, the first five arguments. In the unlikely case of six or more arguments, a single register is used to hold a pointer to user-space where all the parameters are stored.
The return value is sent to user-space also via register. On x86, it is written into the eax register.

やはり、システムコールの際のユーザ空間とカーネル空間のパラメータの受け渡しにはレジスタが使われるのか。


追記(2011/09/14):

Linuxカーネル2.6解読室

Linuxカーネル2.6解読室

P.96
あたりを読んでいて気付いたこと。
システムコールを発行すると、コンテキストスイッチが発生してカーネルスレッドが処理するのかと思っていたけど、CPU が特権モードに移行し、使用するスタックが切り替わるみたい。