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/