trap.c: Why do we save tf_edx in sysmsg_fds[1]?

Matthew Dillon dillon at apollo.backplane.com
Mon Nov 10 02:10:35 PST 2003


:In syscall2(), why do we save tf_edx in sysmsg_fds[1] before calling the
:actual syscall?  sendsys2() doesn't look like it saves this register
:value either.
:
:Grep'ing sys/kern/* doesn't tell me much.
:
:-- 
:   David P. Reese, Jr.                                     daver at xxxxxxxxxxxx
:                                               http://www.gomerbud.com/daver/

    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
    be modified.

    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[1] 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.

					-Matt
					Matthew Dillon 
					<dillon at xxxxxxxxxxxxx>





More information about the Kernel mailing list