DragonFly kernel List (threaded) for 2003-11
Re: trap.c: Why do we save tf_edx in sysmsg_fds?
:In syscall2(), why do we save tf_edx in sysmsg_fds before calling the
:actual syscall? sendsys2() doesn't look like it saves this register
:Grep'ing sys/kern/* doesn't tell me much.
: David P. Reese, Jr. daver@xxxxxxxxxxxx
Its historical. eax is the 32 bit result, eax & edx combined is the
64 bit result. The problem is that historically speaking clients making
system calls which expect 32 bit results might assume that %edx will not
In order to properly ensure that edx is not modified for system calls which
return 32 bit results, we have to store edx in sysmsg_fds because that
is where edx is going to be restored from when the system call returns.
sendsys2() stores the return value in the message structure so it doesn't
have this problem.
Now, practically speaking matter edx is not a saved-used register so it
shouldn't matter if it gets munged on return, so theoretically we can
get rid of the edx assigned. But that could break some obscure
bit of compatibility so I'd rather leave things as is.