mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-02 07:28:21 +00:00
syscall: do not use cr2 as a scratch register
This commit is contained in:
@@ -225,10 +225,7 @@ global arch_syscall_entry
|
|||||||
; rax has return value
|
; rax has return value
|
||||||
arch_syscall_entry:
|
arch_syscall_entry:
|
||||||
swapgs
|
swapgs
|
||||||
; saving the syscall number on cr2 is cursed but we need this extra register
|
mov [gs:40], rax ; save syscall number
|
||||||
; and taking a page fault here would result in a triple fault anyways
|
|
||||||
; because it's still using the user stack
|
|
||||||
mov cr2, rax
|
|
||||||
; rax can be used just fine now
|
; rax can be used just fine now
|
||||||
mov rax, [gs:0] ; thread pointer
|
mov rax, [gs:0] ; thread pointer
|
||||||
mov rax, [rax] ; kernel stack top
|
mov rax, [rax] ; kernel stack top
|
||||||
@@ -237,7 +234,7 @@ arch_syscall_entry:
|
|||||||
; push context
|
; push context
|
||||||
push qword 0x1b ; user SS
|
push qword 0x1b ; user SS
|
||||||
push qword rax ; user RSP
|
push qword rax ; user RSP
|
||||||
mov rax, cr2 ; restore syscall number
|
mov rax, [gs:40] ; restore syscall number
|
||||||
push r11 ; rflags is stored in r11
|
push r11 ; rflags is stored in r11
|
||||||
push qword 0x23 ; user CS
|
push qword 0x23 ; user CS
|
||||||
push qword rcx ; save return RIP
|
push qword rcx ; save return RIP
|
||||||
@@ -266,8 +263,7 @@ arch_syscall_entry:
|
|||||||
push rbx
|
push rbx
|
||||||
mov rbx, gs
|
mov rbx, gs
|
||||||
push rbx
|
push rbx
|
||||||
mov rbx, cr2
|
sub rsp, 8 ; cr2
|
||||||
push rbx
|
|
||||||
|
|
||||||
mov rbx, 0x10
|
mov rbx, 0x10
|
||||||
mov es, rbx
|
mov es, rbx
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ typedef struct cpu_t {
|
|||||||
long hardware_id; // expected to be here by other code
|
long hardware_id; // expected to be here by other code
|
||||||
long internal_id; // expected to be here by other code
|
long internal_id; // expected to be here by other code
|
||||||
|
|
||||||
|
uint64_t scratch; // expected to be here by other code
|
||||||
|
|
||||||
timekeeper_source_t *timekeeper_source;
|
timekeeper_source_t *timekeeper_source;
|
||||||
timekeeper_source_info_t *timekeeper_source_info;
|
timekeeper_source_info_t *timekeeper_source_info;
|
||||||
time_t timekeeper_source_base_ticks;
|
time_t timekeeper_source_base_ticks;
|
||||||
|
|||||||
Reference in New Issue
Block a user