28,14 → 28,14 |
|
.text |
|
/** Syscall wrapper. |
/** Syscall wrapper - INT $0x30 version. |
* |
* Mind the order of arguments. First two arguments and the syscall number go to |
* scratch registers. An optimized version of this wrapper for fewer arguments |
* could benefit from this and not save unused registers on the stack. |
*/ |
.global __syscall |
__syscall: |
.global __syscall_int |
__syscall_int: |
pushl %ebx |
pushl %esi |
pushl %edi |
54,3 → 54,37 |
popl %ebx |
ret |
|
|
/** Syscall wrapper - SYSENTER version. |
* |
* This is an optimized version of syscall for four or less arguments. Note |
* that EBP and EDI are used to remember user stack address and the return |
* address. The kernel part doesn't save DS, ES and FS so the handler restores |
* these to the selector immediately following CS (it must be the flat data |
* segment, otherwise the SYSENTER wouldn't work in the first place). |
*/ |
.global __syscall_sysenter |
__syscall_sysenter: |
pushl %ebx |
pushl %esi |
pushl %edi |
pushl %ebp |
mov %esp, %ebp |
lea ra, %edi |
movl 20(%esp), %edx # First argument. |
movl 24(%esp), %ecx # Second argument. |
movl 28(%esp), %ebx # Third argument. |
movl 32(%esp), %esi # Fourth argument. |
movl 44(%esp), %eax # Syscall number. |
sysenter |
ra: |
movw %cs, %cx |
addw $8, %cx |
movw %cx, %ds |
movw %cx, %es |
movw %cx, %fs |
popl %ebp |
popl %edi |
popl %esi |
popl %ebx |
ret |