[okl4-developer] x86 syscall implementation
Carlos Eduardo Medaglia Dyonisio
medaglia at ok-labs.com
Fri Oct 31 21:25:52 EST 2008
On Fri, 31 Oct 2008 10:52:36 +0100
Harry Vennik <htvennik at zonnet.nl> wrote:
> Hi,
>
> While trying to understand the syscall meganism for x86 I ran into
> one remarkable line in the implementation of all syscalls in arch/
> ia32/libs/l4/include/syscall.h (okl4 version 2.1).
>
> It is the following assembly line:
>
> " movl $0f, %%edi\n"
>
> what does the $0f mean??? Is it a simple hex value? (should be $0xf
> then, i suppose) or is it something different?
> And why is that value loaded into the EDI register?
>
> Regards,
>
> Harry
>
Hello Harry,
Because of the way sysenter/sysexit works on ia-32, we have to pass the
user's return IP and SP to kernel space in registers. In our implementation
we chose to pass the user's return IP on %edi and the SP on %ebp. %eax
contains the syscall number.
Here is a piece of the code you are talking about:
__SYSCALL_SAVE_REGS
" movl $0f, %%edi\n"
" movl %%esp, %%ebp\n"
" movl $0x80000004, %%eax\n"
" sysenter\n"
"0:\n"
__SYSCALL_RESTORE_REGS
$0f is the address of the first tag 0, searching forward from the point where
0 was referenced (this is the reason of the 'f'. If it was for gcc to search
for the first tag 0 backwards, it would be a 'b'), which is the tag just
after sysenter, to where the syscall should return.
I hope I made it clear... :)
Cheers,
Carlos
--
Carlos Eduardo Medaglia Dyonisio
medaglia at ok-labs.com
http://ok-labs.com/
More information about the Developer
mailing list