mirror of
https://github.com/justinian/jsix.git
synced 2025-12-11 08:54:31 -08:00
Implement fast syscall/sysret for sytem calls
This commit is contained in:
@@ -1,21 +1,44 @@
|
||||
%include "push_all.inc"
|
||||
|
||||
extern __counter_syscall_enter
|
||||
extern __counter_syscall_sysret
|
||||
|
||||
extern syscall_handler
|
||||
extern isr_handler_return
|
||||
global syscall_handler_prelude
|
||||
syscall_handler_prelude:
|
||||
push 0 ; ss, doesn't matter here
|
||||
swapgs
|
||||
mov [gs:0x08], rsp
|
||||
mov rsp, [gs:0x00]
|
||||
|
||||
push 0x23 ; ss
|
||||
push rsp
|
||||
pushf
|
||||
push 0 ; cs, doesn't matter here
|
||||
push 0x2b ; cs
|
||||
push rcx ; user rip
|
||||
push 0 ; bogus interrupt
|
||||
push 0 ; bogus errorcode
|
||||
push_all_and_segments
|
||||
|
||||
inc qword [rel __counter_syscall_enter]
|
||||
|
||||
mov rax, [gs:0x08]
|
||||
mov [rsp + 0x98], rax
|
||||
mov rax, [rsp + 0x70]
|
||||
|
||||
mov rdi, rsp
|
||||
call syscall_handler
|
||||
mov rsp, rax
|
||||
|
||||
mov rax, [rsp + 0x90]
|
||||
and rax, 0x3
|
||||
cmp rax, 0x3
|
||||
jne isr_handler_return
|
||||
|
||||
inc qword [rel __counter_syscall_sysret]
|
||||
|
||||
swapgs
|
||||
|
||||
pop_all_and_segments
|
||||
add rsp, 16 ; ignore bogus interrupt / error
|
||||
pop rcx ; user rip
|
||||
|
||||
Reference in New Issue
Block a user