Re: Intel P6 vs P7 system call performance

Linus Torvalds
2002-12-17T18:56:17Z

On Tue, 17 Dec 2002, Ulrich Drepper wrote:
>
> But it will eliminate the problem. Remember: the x86 (unlike x86-64)
> has no PC-relative data addressing mode. I.e., in a DSO to find a
> memory location with an address I need a base register which isn't
> available anymore at the time the call is made.

Actually, I see a more serious problem with the current "syscall"
interface: it doesn't allow six-argument system calls AT ALL, since it
needed %ebp to keep the stack pointer.

So a six-argument system call _has_ to use "int $0x80" anyway, which to
some degree simplifies your problem: you can only use the indirect call
approach for things where %ebp will be free for use anyway.

So then you can use %ebp as the indirection, and the code will look
something like

games, since that is guaranteed not to be ever used by a system call (it
wasn't guaranteed before, but since the sysenter really needs something to
hold the stack pointer I made %ebp do that, so there's no way we can ever
use %ebp for system calls on x86).

So you _can_ do something like this:

syscall_with_5_args:
pushl %ebx
pushl %esi
pushl %edi
pushl %ebp
movl syscall_ptr + GOT,%ebp // uses DSO ptr in %ebx or whatever
movl $__NR_xxxxxx,%eax
movl 20(%esp),%ebx
movl 24(%esp),%ecx
movl 28(%esp),%edx
movl 32(%esp),%esi
movl 36(%esp),%edi
call *%ebp
.. test for errno if needed ..
popl %ebp
popl %edi
popl %esi
popl %ebx
ret

> You have to assume that all the registers, including %ebp, are used at
> the time of the call.

See why this isn't possible right now anyway.

Hmm.. Which system calls have all six parameters? I'll have to see if I
can find any way to make those use the new interface too.

In the meantime, I do agree with you that the TLS approach should work
too, and might be better. It will allow all six arguments to be used if we
just find a good calling conventions (too bad sysenter is such a pig of an
instruction, it's really not very well designed since it loses
information).

Linus