lkml.org 
[lkml]   [1999]   [Dec]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: 2.3.30pre1 syscall w/6 args support?


On Wed, 8 Dec 1999, Artur Skawina wrote:
>
> Is this really absolutely necessary? I have SYSENTER based syscalls
> mostly working, cutting the cost of a system call in half (currently
> from 281 cycles for a int80 based getpid to only 137, but the numbers
> will change a little as i finish it off). Supporting six args is not
> really an option however (not w/o extra kernel side translations --
> there are simply no registers left to pass the required info
> (esp/eip))..

Actually, if you require passing of eip, you're almost certainly doing
something wrong.

The thing about eip is that you can (and should) be able to run the same
library and binaries on both a kernel with and without SYSENTER. Without
having to test for SYSENTER in user mode and do different library things.

And THAT in turn means that to do SYSENTER right, the kernel should map a
magic page into each process' address space (use the FIXMAP capability -
we're already using that to map things like the IOAPIC at a fixed
address), and you do a system call simply by doing a "call" to that magic
page: the kernel can set up whatever it wants (be it "int 0x80" for
old-style system calls, SYSENTER for new system calls, or some magic trap
for Merced - you get the idea) at that address.

And that in turn means that you don't need to save the return EIP for
SYSENTER, because the only way to get the EIP anyway is just from the
stack that was required for the call to the magic address - the actual
address of the "sysenter" instruction is not even interesting.

In fact, I would argue that the proper way to handle this is:

- no sysenter capability on the CPU: use "int 0x80":

magic_address:
movl 4(%esp),%ebx
movl 8(%esp),%ecx
movl 12(%esp),%edx
movl 16(%esp),%esi
movl 20(%esp),%edi
movl 24(%esp),%ebp
int $0x80
ret

- sysenter:

magic_address:
movl %esp,%ebx
sysenter

and in both cases the magic address is just called with:

- arguments on the stack in user mode
- %eax contains the system call number

and in the sysenter case you'll just end up having to fetch the arguments
from the stack (you need to touch the stack anyway in order to get the
return address).

At least with the above, we can handle _any_ future calling convention.

Linus


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:55    [W:0.083 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site