mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-09 00:00:03 +01:00
optimizing system calls
- disable the option to call a system call via int 80 - reduce the number of instruction to store / restore the user-level context
This commit is contained in:
parent
b254df8afa
commit
8147a9b3bf
2 changed files with 20 additions and 61 deletions
|
@ -524,48 +524,14 @@ extern finish_task_switch
|
|||
extern syscall_handler
|
||||
extern get_kernel_stack
|
||||
|
||||
global int80_syscall
|
||||
align 8
|
||||
int80_syscall:
|
||||
cli
|
||||
|
||||
push r15
|
||||
push r14
|
||||
push r13
|
||||
push r12
|
||||
push r11
|
||||
push rbp
|
||||
push rdx
|
||||
push rcx
|
||||
push rbx
|
||||
push rdi
|
||||
push rsi
|
||||
sti
|
||||
|
||||
call syscall_handler
|
||||
|
||||
cli
|
||||
pop rsi
|
||||
pop rdi
|
||||
pop rbx
|
||||
pop rcx
|
||||
pop rdx
|
||||
pop rbp
|
||||
pop r11
|
||||
pop r12
|
||||
pop r13
|
||||
pop r14
|
||||
pop r15
|
||||
sti
|
||||
iretq
|
||||
|
||||
global isrsyscall
|
||||
align 8
|
||||
; used to realize system calls
|
||||
isrsyscall:
|
||||
cli
|
||||
; save register accross function call
|
||||
; save registers accross function call
|
||||
push r11
|
||||
push r10
|
||||
push rbp
|
||||
push rdx
|
||||
push rcx
|
||||
|
@ -577,28 +543,18 @@ isrsyscall:
|
|||
call get_kernel_stack
|
||||
|
||||
; restore registers
|
||||
pop rsi
|
||||
pop rdi
|
||||
pop rbx
|
||||
pop rcx
|
||||
pop rdx
|
||||
pop rbp
|
||||
pop r11
|
||||
mov rsi, [rsp+0]
|
||||
mov rdi, [rsp+8]
|
||||
mov rbx, [rsp+16]
|
||||
mov rcx, [rsp+24]
|
||||
mov rdx, [rsp+32]
|
||||
mov rbp, [rsp+40]
|
||||
mov r10, [rsp+48]
|
||||
mov r11, [rsp+56]
|
||||
|
||||
xchg rsp, rax ; => rax contains original rsp
|
||||
xchg rsp, rax ; => rax contains pointer to the kernel stack
|
||||
|
||||
push rax ; contains original rsp
|
||||
push r15
|
||||
push r14
|
||||
push r13
|
||||
push r12
|
||||
push r11
|
||||
push rbp
|
||||
push rdx
|
||||
push rcx
|
||||
push rbx
|
||||
push rdi
|
||||
push rsi
|
||||
sti
|
||||
|
||||
; syscall stores in rcx the return address
|
||||
|
@ -610,19 +566,18 @@ isrsyscall:
|
|||
call syscall_handler
|
||||
|
||||
cli
|
||||
; restore user-level stack
|
||||
pop r10
|
||||
mov rsp, r10
|
||||
|
||||
pop rsi
|
||||
pop rdi
|
||||
pop rbx
|
||||
pop rcx
|
||||
pop rdx
|
||||
pop rbp
|
||||
pop r11
|
||||
pop r12
|
||||
pop r13
|
||||
pop r14
|
||||
pop r15
|
||||
pop r10
|
||||
mov rsp, r10
|
||||
pop r11
|
||||
sti
|
||||
o64 sysret
|
||||
|
||||
|
|
|
@ -74,7 +74,9 @@ void idt_set_gate(unsigned char num, size_t base, unsigned short sel,
|
|||
configure_idt_entry(&idt[num], base, sel, flags);
|
||||
}
|
||||
|
||||
#if 0
|
||||
extern void int80_syscall(void);
|
||||
#endif
|
||||
|
||||
/* Installs the IDT */
|
||||
void idt_install(void)
|
||||
|
@ -88,9 +90,11 @@ void idt_install(void)
|
|||
idtp.limit = (sizeof(idt_entry_t) * 256) - 1;
|
||||
idtp.base = (size_t)&idt;
|
||||
|
||||
#if 0
|
||||
/* Add any new ISRs to the IDT here using idt_set_gate */
|
||||
idt_set_gate(INT_SYSCALL, (size_t)int80_syscall, KERNEL_CODE_SELECTOR,
|
||||
IDT_FLAG_PRESENT|IDT_FLAG_RING3|IDT_FLAG_32BIT|IDT_FLAG_TRAPGATE);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Points the processor's internal register to the new IDT */
|
||||
|
|
Loading…
Add table
Reference in a new issue