Subject: Odd code in sys/amd64/amd64/syscall.c
To: None <port-amd64@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: port-amd64
Date: 10/27/2007 20:08:48
Browsing through the kernel code I spotted the following snippet in
the syscall return path for amd64:

        switch (error) {
        case 0:
                frame->tf_rax = rval[0];
#ifndef COMPAT_LINUX
                frame->tf_rdx = rval[1];
#endif
                frame->tf_rflags &= ~PSL_C;     /* carry bit */
                break;

The code always passes rval[0] back out to userland in %rax,
and passes out rval[1] in %rdx unless COMPAT_LINUX is defined!

This looks bogus, if netbsd needs to return rval[1] then it should
be doing it inconditionally, possibly netbsd doesn't need it - but
some linux syscall does?  In which case the test is reversed.

I don't off hand know which system calls might try to return rval[1].
Likely candidates are pipe() and lseek().
(I think both use %edx on i386.)

	David

-- 
David Laight: david@l8s.co.uk